@@ -35,13 +35,19 @@ class InstallTest extends \PHPUnit_Framework_TestCase
3535 */
3636 private $ sampleDataState ;
3737
38+ /**
39+ * @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject
40+ */
41+ private $ deploymentConfig ;
42+
3843 public function setUp ()
3944 {
4045 $ this ->webLogger = $ this ->getMock ('\Magento\Setup\Model\WebLogger ' , [], [], '' , false );
4146 $ installerFactory = $ this ->getMock ('\Magento\Setup\Model\InstallerFactory ' , [], [], '' , false );
4247 $ this ->installer = $ this ->getMock ('\Magento\Setup\Model\Installer ' , [], [], '' , false );
4348 $ this ->progressFactory = $ this ->getMock ('\Magento\Setup\Model\Installer\ProgressFactory ' , [], [], '' , false );
4449 $ this ->sampleDataState = $ this ->getMock ('\Magento\Framework\Setup\SampleData\State ' , [], [], '' , false );
50+ $ this ->deploymentConfig = $ this ->getMock ('\Magento\Framework\App\DeploymentConfig ' , [], [], '' , false );
4551
4652 $ installerFactory ->expects ($ this ->once ())->method ('create ' )->with ($ this ->webLogger )
4753 ->willReturn ($ this ->installer );
@@ -51,6 +57,11 @@ public function setUp()
5157 $ this ->progressFactory ,
5258 $ this ->sampleDataState
5359 );
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 );
5465 }
5566
5667 public function testIndexAction ()
@@ -65,6 +76,7 @@ public function testStartAction()
6576 $ this ->webLogger ->expects ($ this ->once ())->method ('clear ' );
6677 $ this ->installer ->expects ($ this ->once ())->method ('install ' );
6778 $ this ->installer ->expects ($ this ->exactly (2 ))->method ('getInstallInfo ' );
79+ $ this ->deploymentConfig ->expects ($ this ->once ())->method ('isAvailable ' )->willReturn (false );
6880 $ jsonModel = $ this ->controller ->startAction ();
6981 $ this ->assertInstanceOf ('\Zend\View\Model\JsonModel ' , $ jsonModel );
7082 $ variables = $ jsonModel ->getVariables ();
@@ -74,9 +86,23 @@ public function testStartAction()
7486 $ this ->assertTrue ($ variables ['success ' ]);
7587 }
7688
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 ()
78103 {
79104 $ this ->webLogger ->expects ($ this ->once ())->method ('clear ' );
105+ $ this ->deploymentConfig ->expects ($ this ->once ())->method ('isAvailable ' )->willReturn (false );
80106 $ this ->installer ->expects ($ this ->once ())->method ('install ' )
81107 ->willThrowException ($ this ->getMock ('\Exception ' ));
82108 $ jsonModel = $ this ->controller ->startAction ();
@@ -87,6 +113,7 @@ public function testStartActionWithSampleDataError()
87113 {
88114 $ this ->webLogger ->expects ($ this ->once ())->method ('clear ' );
89115 $ this ->webLogger ->expects ($ this ->never ())->method ('logError ' );
116+ $ this ->deploymentConfig ->expects ($ this ->once ())->method ('isAvailable ' )->willReturn (false );
90117 $ this ->installer ->method ('install ' );
91118 $ this ->sampleDataState ->expects ($ this ->once ())->method ('hasError ' )->willReturn (true );
92119 $ jsonModel = $ this ->controller ->startAction ();
0 commit comments