Skip to content

Commit 8167ac0

Browse files
author
Olga Kopylova
committed
Merge remote-tracking branch 'origin/MAGETWO-44635-Error-in-disabling-module' into PR_Branch
2 parents 23e5e4b + ee227f5 commit 8167ac0

File tree

4 files changed

+15
-22
lines changed

4 files changed

+15
-22
lines changed

lib/internal/Magento/Framework/App/DeploymentConfig.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Framework\App;
88

9+
use Magento\Framework\Config\ConfigOptionsListConstants;
10+
911
/**
1012
* Application deployment configuration
1113
*/
@@ -39,13 +41,6 @@ class DeploymentConfig
3941
*/
4042
private $overrideData;
4143

42-
/**
43-
* Availability of deployment config file
44-
*
45-
* @var bool
46-
*/
47-
private $isAvailable;
48-
4944
/**
5045
* Constructor
5146
*
@@ -65,7 +60,7 @@ public function __construct(DeploymentConfig\Reader $reader, $overrideData = [])
6560
*
6661
* @param string $key
6762
* @param mixed $defaultValue
68-
* @return array|null
63+
* @return mixed|null
6964
*/
7065
public function get($key = null, $defaultValue = null)
7166
{
@@ -85,7 +80,7 @@ public function isAvailable()
8580
{
8681
$this->data = null;
8782
$this->load();
88-
return $this->isAvailable;
83+
return isset($this->flatData[ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE]);
8984
}
9085

9186
/**
@@ -128,7 +123,6 @@ private function load()
128123
{
129124
if (null === $this->data) {
130125
$this->data = $this->reader->load();
131-
$this->isAvailable = !empty($this->data);
132126
if ($this->overrideData) {
133127
$this->data = array_replace($this->data, $this->overrideData);
134128
}

lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Framework\App\Test\Unit;
88

99
use \Magento\Framework\App\DeploymentConfig;
10+
use \Magento\Framework\Config\ConfigOptionsListConstants;
1011

1112
class DeploymentConfigTest extends \PHPUnit_Framework_TestCase
1213
{
@@ -88,7 +89,9 @@ public function testGetters()
8889

8990
public function testIsAvailable()
9091
{
91-
$this->reader->expects($this->once())->method('load')->willReturn(['a' => 1]);
92+
$this->reader->expects($this->once())->method('load')->willReturn([
93+
ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE => 1
94+
]);
9295
$object = new DeploymentConfig($this->reader);
9396
$this->assertTrue($object->isAvailable());
9497
}
@@ -103,7 +106,9 @@ public function testNotAvailable()
103106
public function testNotAvailableThenAvailable()
104107
{
105108
$this->reader->expects($this->at(0))->method('load')->willReturn([]);
106-
$this->reader->expects($this->at(1))->method('load')->willReturn(['a' => 1]);
109+
$this->reader->expects($this->at(1))->method('load')->willReturn([
110+
ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE => 1
111+
]);
107112
$object = new DeploymentConfig($this->reader);
108113
$this->assertFalse($object->isAvailable());
109114
$this->assertTrue($object->isAvailable());

lib/internal/Magento/Framework/Module/ModuleList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function isModuleInfoAvailable()
139139
*/
140140
private function loadConfigData()
141141
{
142-
if (null === $this->configData && ($this->config->isAvailable())) {
142+
if (null === $this->configData && null !== $this->config->get(ConfigOptionsListConstants::KEY_MODULES)) {
143143
$this->configData = $this->config->get(ConfigOptionsListConstants::KEY_MODULES);
144144
}
145145
}

lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ protected function setUp()
4747

4848
public function testGetAll()
4949
{
50-
$this->config->expects($this->once())->method('isAvailable')->willReturn(true);
5150
$this->setLoadAllExpectation();
5251
$this->setLoadConfigExpectation();
5352
$expected = ['foo' => self::$allFixture['foo']];
@@ -58,15 +57,13 @@ public function testGetAll()
5857
public function testGetAllNoData()
5958
{
6059
$this->loader->expects($this->exactly(2))->method('load')->willReturn([]);
61-
$this->config->expects($this->never())->method('isAvailable');
6260
$this->setLoadConfigExpectation(false);
6361
$this->assertEquals([], $this->model->getAll());
6462
$this->assertEquals([], $this->model->getAll());
6563
}
6664

6765
public function testGetOne()
6866
{
69-
$this->config->expects($this->once())->method('isAvailable')->willReturn(true);
7067
$this->setLoadAllExpectation();
7168
$this->setLoadConfigExpectation();
7269
$this->assertSame(['key' => 'value'], $this->model->getOne('foo'));
@@ -75,7 +72,6 @@ public function testGetOne()
7572

7673
public function testGetNames()
7774
{
78-
$this->config->expects($this->once())->method('isAvailable')->willReturn(true);
7975
$this->setLoadAllExpectation(false);
8076
$this->setLoadConfigExpectation();
8177
$this->assertSame(['foo'], $this->model->getNames());
@@ -84,7 +80,6 @@ public function testGetNames()
8480

8581
public function testHas()
8682
{
87-
$this->config->expects($this->once())->method('isAvailable')->willReturn(true);
8883
$this->setLoadAllExpectation(false);
8984
$this->setLoadConfigExpectation();
9085
$this->assertTrue($this->model->has('foo'));
@@ -93,15 +88,14 @@ public function testHas()
9388

9489
public function testIsModuleInfoAvailable()
9590
{
96-
$this->config->expects($this->once())->method('isAvailable')->willReturn(true);
9791
$this->setLoadConfigExpectation(true);
9892
$this->assertTrue($this->model->isModuleInfoAvailable());
9993
}
10094

10195
public function testIsModuleInfoAvailableNoConfig()
10296
{
103-
$this->config->expects($this->once())->method('isAvailable')->willReturn(true);
104-
$this->config->expects($this->once())->method('get')->willReturn(null);
97+
$this->config->expects($this->at(0))->method('get')->willReturn(['modules' => 'testModule']);
98+
$this->config->expects($this->at(1))->method('get')->willReturn(null);
10599
$this->assertFalse($this->model->isModuleInfoAvailable());
106100
}
107101

@@ -114,7 +108,7 @@ public function testIsModuleInfoAvailableNoConfig()
114108
private function setLoadConfigExpectation($isExpected = true)
115109
{
116110
if ($isExpected) {
117-
$this->config->expects($this->once())->method('get')->willReturn(self::$enabledFixture);
111+
$this->config->expects($this->exactly(2))->method('get')->willReturn(self::$enabledFixture);
118112
} else {
119113
$this->config->expects($this->never())->method('get');
120114
}

0 commit comments

Comments
 (0)