Skip to content

Commit b33d324

Browse files
MAGETWO-69535: Error during importing new list of scopes through shared file
1 parent b6c9f4a commit b33d324

File tree

4 files changed

+94
-8
lines changed

4 files changed

+94
-8
lines changed

app/code/Magento/Store/App/Config/InitialConfigSource.php renamed to app/code/Magento/Store/App/Config/Source/InitialConfigSource.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,43 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Store\App\Config;
6+
namespace Magento\Store\App\Config\Source;
77

88
use Magento\Framework\App\Config\ConfigSourceInterface;
99
use Magento\Framework\App\DeploymentConfig;
1010
use Magento\Framework\App\DeploymentConfig\Reader;
1111
use Magento\Framework\DataObject;
1212

13+
/**
14+
* Config source to retrieve configuration from files.
15+
*/
1316
class InitialConfigSource implements ConfigSourceInterface
1417
{
1518
/**
19+
* The file reader
20+
*
1621
* @var Reader
1722
*/
1823
private $reader;
1924

2025
/**
26+
* The deployment config reader
27+
*
2128
* @var DeploymentConfig
2229
*/
2330
private $deploymentConfig;
2431

2532
/**
33+
* The config type
34+
*
2635
* @var string
2736
*/
2837
private $configType;
2938

3039
/**
31-
* DataProvider constructor.
32-
*
33-
* @param Reader $reader
34-
* @param DeploymentConfig $deploymentConfig
35-
* @param string $configType
40+
* @param Reader $reader The file reader
41+
* @param DeploymentConfig $deploymentConfig The deployment config reader
42+
* @param string $configType The config type
3643
*/
3744
public function __construct(Reader $reader, DeploymentConfig $deploymentConfig, $configType)
3845
{
@@ -57,7 +64,9 @@ public function get($path = '')
5764
}
5865

5966
$data = new DataObject($this->reader->load());
67+
6068
if ($path !== '' && $path !== null) {
69+
$path = ltrim($path, '/');
6170
$path = '/' . $path;
6271
}
6372

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Store\Test\Unit\App\Config\Source;
7+
8+
use Magento\Framework\App\DeploymentConfig;
9+
use Magento\Framework\App\DeploymentConfig\Reader;
10+
use Magento\Store\App\Config\Source\InitialConfigSource;
11+
use PHPUnit_Framework_MockObject_MockObject as Mock;
12+
13+
/**
14+
* @inheritdoc
15+
*/
16+
class InitialConfigSourceTest extends \PHPUnit_Framework_TestCase
17+
{
18+
/**
19+
* @var Reader|Mock
20+
*/
21+
private $readerMock;
22+
23+
/**
24+
* @var DeploymentConfig|Mock
25+
*/
26+
private $deploymentConfigMock;
27+
28+
/**
29+
* @var InitialConfigSource
30+
*/
31+
private $source;
32+
33+
/**
34+
* @inheritdoc
35+
*/
36+
public function setUp()
37+
{
38+
$this->readerMock = $this->getMockBuilder(Reader::class)
39+
->disableOriginalConstructor()
40+
->getMock();
41+
$this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)
42+
->disableOriginalConstructor()
43+
->getMock();
44+
45+
$this->source = new InitialConfigSource(
46+
$this->readerMock,
47+
$this->deploymentConfigMock,
48+
'configType'
49+
);
50+
}
51+
52+
public function testGet()
53+
{
54+
$path = 'path';
55+
56+
$this->readerMock->expects($this->once())
57+
->method('load')
58+
->willReturn(['configType' => [$path => 'value']]);
59+
$this->deploymentConfigMock->expects($this->once())
60+
->method('isAvailable')
61+
->willReturn(true);
62+
63+
$this->assertEquals('value', $this->source->get($path));
64+
}
65+
66+
public function testGetNotInstalled()
67+
{
68+
$path = 'path';
69+
70+
$this->readerMock->expects($this->never())
71+
->method('load');
72+
$this->deploymentConfigMock->expects($this->once())
73+
->method('isAvailable')
74+
->willReturn(false);
75+
76+
$this->assertEquals([], $this->source->get($path));
77+
}
78+
}

app/code/Magento/Store/Test/Unit/Model/Config/Importer/Processor/CreateTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ public function testRunWebsite()
110110
'name' => 'Main Website',
111111
'sort_order' => '0',
112112
'is_default' => '1',
113-
'default_group_id' => '1',
114113
];
115114
$data = [
116115
'websites' => $websites,

app/code/Magento/Store/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@
346346
</argument>
347347
</arguments>
348348
</virtualType>
349-
<virtualType name="scopesConfigInitialDataProvider" type="Magento\Store\App\Config\InitialConfigSource">
349+
<virtualType name="scopesConfigInitialDataProvider" type="Magento\Store\App\Config\Source\InitialConfigSource">
350350
<arguments>
351351
<argument name="reader" xsi:type="object">Magento\Framework\App\DeploymentConfig\Reader</argument>
352352
<argument name="configType" xsi:type="const">Magento\Store\App\Config\Type\Scopes::CONFIG_TYPE</argument>

0 commit comments

Comments
 (0)