10
10
11
11
class DiCompileCommandTest extends \PHPUnit_Framework_TestCase
12
12
{
13
- /**
14
- * @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject
15
- */
13
+ /** @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject */
16
14
private $ deploymentConfig ;
17
15
18
- /**
19
- * @var \Magento\Setup\Module\Di\App\Task\Manager|\PHPUnit_Framework_MockObject_MockObject
20
- */
16
+ /** @var \Magento\Setup\Module\Di\App\Task\Manager|\PHPUnit_Framework_MockObject_MockObject */
21
17
private $ manager ;
22
18
23
- /**
24
- * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
25
- */
19
+ /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
26
20
private $ objectManager ;
27
21
28
- /**
29
- * @var DiCompileCommand
30
- */
22
+ /** @var DiCompileCommand|\PHPUnit_Framework_MockObject_MockObject */
31
23
private $ command ;
32
24
25
+ /** @var \Magento\Framework\App\Cache|\PHPUnit_Framework_MockObject_MockObject */
26
+ private $ cacheMock ;
27
+
28
+ /** @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject */
29
+ private $ filesystem ;
30
+
33
31
public function setUp ()
34
32
{
35
33
$ this ->deploymentConfig = $ this ->getMock ('Magento\Framework\App\DeploymentConfig ' , [], [], '' , false );
@@ -46,15 +44,22 @@ public function setUp()
46
44
'' ,
47
45
false
48
46
);
47
+ $ this ->cacheMock = $ this ->getMockBuilder ('Magento\Framework\App\Cache ' )
48
+ ->disableOriginalConstructor ()
49
+ ->getMock ();
50
+
49
51
$ objectManagerProvider ->expects ($ this ->once ())->method ('get ' )->willReturn ($ this ->objectManager );
50
52
$ this ->manager = $ this ->getMock ('Magento\Setup\Module\Di\App\Task\Manager ' , [], [], '' , false );
51
53
$ directoryList = $ this ->getMock ('Magento\Framework\App\Filesystem\DirectoryList ' , [], [], '' , false );
54
+ $ this ->filesystem = $ this ->getMockBuilder ('Magento\Framework\Filesystem ' )->disableOriginalConstructor ()->getMock ();
55
+
52
56
$ directoryList ->expects ($ this ->exactly (3 ))->method ('getPath ' );
53
57
$ this ->command = new DiCompileCommand (
54
58
$ this ->deploymentConfig ,
55
59
$ directoryList ,
56
60
$ this ->manager ,
57
- $ objectManagerProvider
61
+ $ objectManagerProvider ,
62
+ $ this ->filesystem
58
63
);
59
64
}
60
65
@@ -71,6 +76,15 @@ public function testExecuteNotInstalled()
71
76
72
77
public function testExecute ()
73
78
{
79
+ $ this ->objectManager ->expects ($ this ->once ())
80
+ ->method ('get ' )
81
+ ->with ('Magento\Framework\App\Cache ' )
82
+ ->willReturn ($ this ->cacheMock );
83
+ $ this ->cacheMock ->expects ($ this ->once ())->method ('clean ' );
84
+ $ writeDirectory = $ this ->getMock ('Magento\Framework\Filesystem\Directory\WriteInterface ' );
85
+ $ writeDirectory ->expects ($ this ->atLeastOnce ())->method ('delete ' );
86
+ $ this ->filesystem ->expects ($ this ->atLeastOnce ())->method ('getDirectoryWrite ' )->willReturn ($ writeDirectory );
87
+
74
88
$ this ->deploymentConfig ->expects ($ this ->once ())->method ('isAvailable ' )->willReturn (true );
75
89
$ this ->objectManager ->expects ($ this ->once ())->method ('configure ' );
76
90
$ this ->manager ->expects ($ this ->exactly (6 ))->method ('addOperation ' );
0 commit comments