@@ -35,13 +35,19 @@ 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 );
@@ -51,6 +57,11 @@ public function setUp()
51
57
$ this ->progressFactory ,
52
58
$ this ->sampleDataState
53
59
);
60
+
61
+ $ deploymentConfigReflection = new \ReflectionClass (get_class ($ this ->controller ));
62
+ $ deploymentConfigReflectionProperty = $ deploymentConfigReflection ->getProperty ('deploymentConfig ' );
63
+ $ deploymentConfigReflectionProperty ->setAccessible (true );
64
+ $ deploymentConfigReflectionProperty ->setValue ($ this ->controller , $ this ->deploymentConfig );
54
65
}
55
66
56
67
public function testIndexAction ()
@@ -65,6 +76,7 @@ public function testStartAction()
65
76
$ this ->webLogger ->expects ($ this ->once ())->method ('clear ' );
66
77
$ this ->installer ->expects ($ this ->once ())->method ('install ' );
67
78
$ this ->installer ->expects ($ this ->exactly (2 ))->method ('getInstallInfo ' );
79
+ $ this ->deploymentConfig ->expects ($ this ->once ())->method ('isAvailable ' )->willReturn (false );
68
80
$ jsonModel = $ this ->controller ->startAction ();
69
81
$ this ->assertInstanceOf ('\Zend\View\Model\JsonModel ' , $ jsonModel );
70
82
$ variables = $ jsonModel ->getVariables ();
@@ -74,9 +86,23 @@ public function testStartAction()
74
86
$ this ->assertTrue ($ variables ['success ' ]);
75
87
}
76
88
77
- public function testStartActionException ()
89
+ public function testStartActionPriorInstallException ()
90
+ {
91
+ $ this ->webLogger ->expects ($ this ->once ())->method ('clear ' );
92
+ $ this ->installer ->expects ($ this ->never ())->method ('install ' );
93
+ $ this ->installer ->expects ($ this ->never ())->method ('getInstallInfo ' );
94
+ $ this ->deploymentConfig ->expects ($ this ->once ())->method ('isAvailable ' )->willReturn (true );
95
+ $ jsonModel = $ this ->controller ->startAction ();
96
+ $ this ->assertInstanceOf ('\Zend\View\Model\JsonModel ' , $ jsonModel );
97
+ $ variables = $ jsonModel ->getVariables ();
98
+ $ this ->assertArrayHasKey ('success ' , $ variables );
99
+ $ this ->assertArrayHasKey ('messages ' , $ variables );
100
+ $ this ->assertFalse ($ variables ['success ' ]);
101
+ }
102
+ public function testStartActionInstallException ()
78
103
{
79
104
$ this ->webLogger ->expects ($ this ->once ())->method ('clear ' );
105
+ $ this ->deploymentConfig ->expects ($ this ->once ())->method ('isAvailable ' )->willReturn (false );
80
106
$ this ->installer ->expects ($ this ->once ())->method ('install ' )
81
107
->willThrowException ($ this ->getMock ('\Exception ' ));
82
108
$ jsonModel = $ this ->controller ->startAction ();
@@ -87,6 +113,7 @@ public function testStartActionWithSampleDataError()
87
113
{
88
114
$ this ->webLogger ->expects ($ this ->once ())->method ('clear ' );
89
115
$ this ->webLogger ->expects ($ this ->never ())->method ('logError ' );
116
+ $ this ->deploymentConfig ->expects ($ this ->once ())->method ('isAvailable ' )->willReturn (false );
90
117
$ this ->installer ->method ('install ' );
91
118
$ this ->sampleDataState ->expects ($ this ->once ())->method ('hasError ' )->willReturn (true );
92
119
$ jsonModel = $ this ->controller ->startAction ();
0 commit comments