Skip to content

Commit 345a88f

Browse files
author
Ivan Gavryshko
committed
MAGETWO-43265: An exception if try to get to the Web Wizard without writable file permissions
- instantiating DeploymentConfig via Zend Service Locator - Changed tests according to changes
1 parent 37b746f commit 345a88f

File tree

5 files changed

+25
-51
lines changed

5 files changed

+25
-51
lines changed

setup/src/Magento/Setup/Controller/Index.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Zend\Mvc\Controller\AbstractActionController;
1010
use Zend\View\Model\ViewModel;
1111
use Magento\Setup\Model\ObjectManagerProvider;
12-
use Magento\Setup\Model\ApplicationStatus;
12+
use Magento\Framework\App\DeploymentConfig;
1313

1414
/**
1515
* Main controller of the Setup Wizard
@@ -22,28 +22,28 @@ class Index extends AbstractActionController
2222
private $objectManagerProvider;
2323

2424
/**
25-
* @var \Magento\Setup\Model\ApplicationStatus
25+
* @var \Magento\Framework\App\DeploymentConfig
2626
*/
27-
private $applicationStatus;
27+
private $deploymentConfig;
2828

2929
/**
3030
* @param ObjectManagerProvider $objectManagerProvider
31-
* @param ApplicationStatus $applicationStatus
31+
* @param DeploymentConfig $deploymentConfig
3232
*/
3333
public function __construct(
3434
ObjectManagerProvider $objectManagerProvider,
35-
ApplicationStatus $applicationStatus
35+
DeploymentConfig $deploymentConfig
3636
) {
3737
$this->objectManagerProvider = $objectManagerProvider;
38-
$this->applicationStatus = $applicationStatus;
38+
$this->deploymentConfig = $deploymentConfig;
3939
}
4040

4141
/**
4242
* @return ViewModel|\Zend\Http\Response
4343
*/
4444
public function indexAction()
4545
{
46-
if ($this->applicationStatus->isApplicationInstalled()) {
46+
if ($this->deploymentConfig->isAvailable()) {
4747
$objectManager = $this->objectManagerProvider->get();
4848
/** @var \Magento\Framework\App\State $adminAppState */
4949
$adminAppState = $objectManager->get('Magento\Framework\App\State');

setup/src/Magento/Setup/Model/ApplicationStatus.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

setup/src/Magento/Setup/Model/Navigation.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Setup\Model;
88

99
use Zend\ServiceManager\ServiceLocatorInterface;
10+
use Magento\Framework\App\DeploymentConfig;
1011

1112
class Navigation
1213
{
@@ -34,10 +35,11 @@ class Navigation
3435

3536
/**
3637
* @param ServiceLocatorInterface $serviceLocator
38+
* @param DeploymentConfig $deploymentConfig
3739
*/
38-
public function __construct(ServiceLocatorInterface $serviceLocator, ApplicationStatus $applicationStatus)
40+
public function __construct(ServiceLocatorInterface $serviceLocator, DeploymentConfig $deploymentConfig)
3941
{
40-
if ($applicationStatus->isApplicationInstalled()) {
42+
if ($deploymentConfig->isAvailable()) {
4143
$this->navStates = $serviceLocator->get('config')[self::NAV_UPDATER];
4244
$this->navType = self::NAV_UPDATER;
4345
$this->titles = $serviceLocator->get('config')[self::NAV_UPDATER . 'Titles'];

setup/src/Magento/Setup/Test/Unit/Controller/IndexTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ class IndexTest extends \PHPUnit_Framework_TestCase
2121
private $objectManager;
2222

2323
/**
24-
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Model\ApplicationStatus
24+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\DeploymentConfig
2525
*/
26-
private $applicationStatus;
26+
private $deploymentConfig;
27+
2728

2829
/**
2930
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\State
@@ -45,8 +46,8 @@ public function setUp()
4546
'',
4647
false
4748
);
48-
$this->applicationStatus = $this->getMock(
49-
'Magento\Setup\Model\ApplicationStatus',
49+
$this->deploymentConfig = $this->getMock(
50+
'Magento\Framework\App\DeploymentConfig',
5051
[],
5152
[],
5253
'',
@@ -70,7 +71,7 @@ public function setUp()
7071

7172
public function testIndexActionInstalled()
7273
{
73-
$this->applicationStatus->expects($this->once())->method('isApplicationInstalled')->willReturn(true);
74+
$this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true);
7475
$this->objectManagerProvider->expects($this->once())->method('get')->willReturn($this->objectManager);
7576
$this->appState->expects($this->once())->method('setAreaCode');
7677
$this->auth->expects($this->once())->method('isLoggedIn');
@@ -85,18 +86,18 @@ public function testIndexActionInstalled()
8586
)
8687
);
8788
/** @var $controller Index */
88-
$controller = new Index($this->objectManagerProvider, $this->applicationStatus);
89+
$controller = new Index($this->objectManagerProvider, $this->deploymentConfig);
8990
$viewModel = $controller->indexAction();
9091
$this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel);
9192
$this->assertFalse($viewModel->terminate());
9293
}
9394

9495
public function testIndexActionNotInstalled()
9596
{
96-
$this->applicationStatus->expects($this->once())->method('isApplicationInstalled')->willReturn(false);
97+
$this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(false);
9798
$this->objectManagerProvider->expects($this->exactly(0))->method('get');
9899
/** @var $controller Index */
99-
$controller = new Index($this->objectManagerProvider, $this->applicationStatus);
100+
$controller = new Index($this->objectManagerProvider, $this->deploymentConfig);
100101
$viewModel = $controller->indexAction();
101102
$this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel);
102103
$this->assertFalse($viewModel->terminate());

setup/src/Magento/Setup/Test/Unit/Model/NavigationTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class NavigationTest extends \PHPUnit_Framework_TestCase
1616
private $serviceLocatorMock;
1717

1818
/**
19-
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Model\ApplicationStatus
19+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\DeploymentConfig
2020
*/
21-
private $applicationStatus;
21+
private $deploymentConfig;
2222

2323
/**
2424
* @var Navigation
@@ -48,14 +48,14 @@ public function setUp()
4848
['main' => false],
4949
]
5050
]));
51-
$this->applicationStatus = $this->getMock(
52-
'Magento\Setup\Model\ApplicationStatus',
51+
$this->deploymentConfig = $this->getMock(
52+
'Magento\Framework\App\DeploymentConfig',
5353
[],
5454
[],
5555
'',
5656
false
5757
);
58-
$this->navigation = new Navigation($this->serviceLocatorMock, $this->applicationStatus);
58+
$this->navigation = new Navigation($this->serviceLocatorMock, $this->deploymentConfig);
5959
}
6060

6161
public function testGetType()

0 commit comments

Comments
 (0)