@@ -35,21 +35,28 @@ class InstallTest extends \PHPUnit_Framework_TestCase
35
35
*/
36
36
private $ sampleDataState ;
37
37
38
+ /**
39
+ * @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject
40
+ */
41
+ private $ deploymentConfig ;
42
+
38
43
public function setUp ()
39
44
{
40
45
$ this ->webLogger = $ this ->getMock ('\Magento\Setup\Model\WebLogger ' , [], [], '' , false );
41
46
$ installerFactory = $ this ->getMock ('\Magento\Setup\Model\InstallerFactory ' , [], [], '' , false );
42
47
$ this ->installer = $ this ->getMock ('\Magento\Setup\Model\Installer ' , [], [], '' , false );
43
48
$ this ->progressFactory = $ this ->getMock ('\Magento\Setup\Model\Installer\ProgressFactory ' , [], [], '' , false );
44
49
$ this ->sampleDataState = $ this ->getMock ('\Magento\Framework\Setup\SampleData\State ' , [], [], '' , false );
50
+ $ this ->deploymentConfig = $ this ->getMock ('\Magento\Framework\App\DeploymentConfig ' , [], [], '' , false );
45
51
46
52
$ installerFactory ->expects ($ this ->once ())->method ('create ' )->with ($ this ->webLogger )
47
53
->willReturn ($ this ->installer );
48
54
$ this ->controller = new Install (
49
55
$ this ->webLogger ,
50
56
$ installerFactory ,
51
57
$ this ->progressFactory ,
52
- $ this ->sampleDataState
58
+ $ this ->sampleDataState ,
59
+ $ this ->deploymentConfig
53
60
);
54
61
}
55
62
@@ -65,6 +72,7 @@ public function testStartAction()
65
72
$ this ->webLogger ->expects ($ this ->once ())->method ('clear ' );
66
73
$ this ->installer ->expects ($ this ->once ())->method ('install ' );
67
74
$ this ->installer ->expects ($ this ->exactly (2 ))->method ('getInstallInfo ' );
75
+ $ this ->deploymentConfig ->expects ($ this ->once ())->method ('isAvailable ' )->willReturn (false );
68
76
$ jsonModel = $ this ->controller ->startAction ();
69
77
$ this ->assertInstanceOf ('\Zend\View\Model\JsonModel ' , $ jsonModel );
70
78
$ variables = $ jsonModel ->getVariables ();
@@ -74,9 +82,23 @@ public function testStartAction()
74
82
$ this ->assertTrue ($ variables ['success ' ]);
75
83
}
76
84
77
- public function testStartActionException ()
85
+ public function testStartActionPriorInstallException ()
86
+ {
87
+ $ this ->webLogger ->expects ($ this ->once ())->method ('clear ' );
88
+ $ this ->installer ->expects ($ this ->never ())->method ('install ' );
89
+ $ this ->installer ->expects ($ this ->never ())->method ('getInstallInfo ' );
90
+ $ this ->deploymentConfig ->expects ($ this ->once ())->method ('isAvailable ' )->willReturn (true );
91
+ $ jsonModel = $ this ->controller ->startAction ();
92
+ $ this ->assertInstanceOf ('\Zend\View\Model\JsonModel ' , $ jsonModel );
93
+ $ variables = $ jsonModel ->getVariables ();
94
+ $ this ->assertArrayHasKey ('success ' , $ variables );
95
+ $ this ->assertArrayHasKey ('messages ' , $ variables );
96
+ $ this ->assertFalse ($ variables ['success ' ]);
97
+ }
98
+ public function testStartActionInstallException ()
78
99
{
79
100
$ this ->webLogger ->expects ($ this ->once ())->method ('clear ' );
101
+ $ this ->deploymentConfig ->expects ($ this ->once ())->method ('isAvailable ' )->willReturn (false );
80
102
$ this ->installer ->expects ($ this ->once ())->method ('install ' )
81
103
->willThrowException ($ this ->getMock ('\Exception ' ));
82
104
$ jsonModel = $ this ->controller ->startAction ();
@@ -87,6 +109,7 @@ public function testStartActionWithSampleDataError()
87
109
{
88
110
$ this ->webLogger ->expects ($ this ->once ())->method ('clear ' );
89
111
$ this ->webLogger ->expects ($ this ->never ())->method ('logError ' );
112
+ $ this ->deploymentConfig ->expects ($ this ->once ())->method ('isAvailable ' )->willReturn (false );
90
113
$ this ->installer ->method ('install ' );
91
114
$ this ->sampleDataState ->expects ($ this ->once ())->method ('hasError ' )->willReturn (true );
92
115
$ jsonModel = $ this ->controller ->startAction ();
0 commit comments