Skip to content

Commit 3140ec6

Browse files
authored
Merge pull request #740 from magento-falcons/MAGETWO-62964
[Falcons] Sprint 4 delivery - MAGETWO-62964 [PR] Delivery of stories (sprint 4) - MAGETWO-62655 [GitHub] CLI won't work without write permissions #7933 - MAGETWO-62198 [Deployment] Move var/di var/generate to git checkin-able directory - MAGETWO-60166 [2.2] Support Environment Specific Configuration File for env/sensitive configuration variables - MAGETWO-61876 Remove admin - store/configuration/advanced/advanced
2 parents 1856c28 + 6ac0e7e commit 3140ec6

File tree

78 files changed

+2892
-522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2892
-522
lines changed

app/code/Magento/Backend/Block/Template.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,12 @@ public function getFormKey()
7070
*
7171
* @param string $moduleName Full module name
7272
* @return boolean
73+
* @deprecated
74+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
7375
*/
7476
public function isOutputEnabled($moduleName = null)
7577
{
76-
if ($moduleName === null) {
77-
$moduleName = $this->getModuleName();
78-
}
79-
80-
return !$this->_scopeConfig->isSetFlag(
81-
'advanced/modules_disable_output/' . $moduleName,
82-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
83-
);
78+
return true;
8479
}
8580

8681
/**

app/code/Magento/Backend/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<tab id="advanced" translate="label" sortOrder="999999">
1717
<label>Advanced</label>
1818
</tab>
19-
<section id="advanced" translate="label" type="text" sortOrder="910" showInDefault="1" showInWebsite="1" showInStore="1">
19+
<section id="advanced" translate="label" type="text" sortOrder="910" showInDefault="0" showInWebsite="0" showInStore="0">
2020
<label>Advanced</label>
2121
<tab>advanced</tab>
2222
<resource>Magento_Backend::advanced</resource>

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ public function testToHtml()
5555
->getMock();
5656
$eventManager->expects($this->exactly(2))->method('dispatch')->will($this->returnValue(true));
5757

58-
$scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config::class)
59-
->setMethods(['getValue'])
60-
->disableOriginalConstructor()->getMock();
61-
$scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()
62-
->will($this->returnValue(false));
63-
6458
$product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()
6559
->setMethods(['setStoreId', 'load', 'getId', '__wakeup', '__sleep'])
6660
->getMock();
@@ -93,8 +87,6 @@ public function testToHtml()
9387

9488
$this->context->expects($this->once())->method('getEventManager')
9589
->will($this->returnValue($eventManager));
96-
$this->context->expects($this->once())->method('getScopeConfig')
97-
->will($this->returnValue($scopeConfig));
9890
$this->context->expects($this->once())->method('getLayout')
9991
->will($this->returnValue($layout));
10092
$this->context->expects($this->once())->method('getRequest')

app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function setUp()
6363
false,
6464
false
6565
);
66-
$this->scopeConfig = $this->getMock(\Magento\Framework\App\Config::class, ['getValue'], [], '', false, false);
66+
$this->scopeConfig = $this->getMock(\Magento\Framework\App\Config::class, [], [], '', false, false);
6767
$this->cacheState = $this->getMock(
6868
\Magento\Framework\App\Cache\State::class,
6969
['isEnabled'],
@@ -188,8 +188,6 @@ protected function generalGetProductCollection()
188188
{
189189
$this->eventManager->expects($this->exactly(2))->method('dispatch')
190190
->will($this->returnValue(true));
191-
$this->scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()
192-
->willReturn(false);
193191
$this->cacheState->expects($this->atLeastOnce())->method('isEnabled')->withAnyParameters()
194192
->willReturn(false);
195193
$this->catalogConfig->expects($this->once())->method('getProductAttributes')

app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/ActionsTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ public function testToHtml()
6565
$childNameTwo = 'child.2';
6666
$childNames = [$childNameOne, $childNameTwo];
6767

68-
$this->scopeConfigMock->expects($this->once())
69-
->method('getValue')
70-
->willReturn(false);
71-
7268
/**
7369
* @var Item|\PHPUnit_Framework_MockObject_MockObject $itemMock
7470
*/

app/code/Magento/Config/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
*/
1010
namespace Magento\Config\Block\System\Config\Form\Fieldset\Modules;
1111

12+
/**
13+
* @deprecated
14+
*/
1215
class DisableOutput extends \Magento\Config\Block\System\Config\Form\Fieldset
1316
{
1417
/**
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Config\Model\Config\Parser;
7+
8+
use Magento\Config\Model\Placeholder\Environment;
9+
use Magento\Config\Model\Placeholder\PlaceholderInterface;
10+
use Magento\Framework\App\Config\CommentParserInterface;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Framework\App\Filesystem\DirectoryList;
13+
use Magento\Framework\Exception\FileSystemException;
14+
use Magento\Framework\Filesystem;
15+
16+
/**
17+
* Class Comment. It is used to parse config paths from comment section.
18+
*/
19+
class Comment implements CommentParserInterface
20+
{
21+
/**
22+
* @var Filesystem
23+
*/
24+
private $filesystem;
25+
26+
/**
27+
* @var PlaceholderInterface
28+
*/
29+
private $placeholder;
30+
31+
/**
32+
* @param Filesystem $filesystem
33+
* @param PlaceholderInterface $placeholder
34+
*/
35+
public function __construct(
36+
Filesystem $filesystem,
37+
PlaceholderInterface $placeholder
38+
) {
39+
$this->filesystem = $filesystem;
40+
$this->placeholder = $placeholder;
41+
}
42+
43+
/**
44+
* Retrieves config paths from comment section of the file.
45+
* Example of comment:
46+
* * CONFIG__DEFAULT__SOME__CONF__PATH_ONE
47+
* * CONFIG__DEFAULT__SOME__CONF__PATH_TWO
48+
* This method will return:
49+
* array(
50+
* 'CONFIG__DEFAULT__SOME__CONF__PATH_ONE' => 'some/conf/path_one',
51+
* 'CONFIG__DEFAULT__SOME__CONF__PATH_TWO' => 'some/conf/path_two'
52+
* );
53+
*
54+
* @param string $fileName
55+
* @return array
56+
* @throws FileSystemException
57+
*/
58+
public function execute($fileName)
59+
{
60+
$fileContent = $this->filesystem
61+
->getDirectoryRead(DirectoryList::CONFIG)
62+
->readFile($fileName);
63+
64+
$pattern = sprintf('/\s+\*\s+(?P<placeholder>%s.*?)\s/', preg_quote(Environment::PREFIX));
65+
preg_match_all($pattern, $fileContent, $matches);
66+
67+
if (!isset($matches['placeholder'])) {
68+
return [];
69+
}
70+
71+
$configs = [];
72+
foreach ($matches['placeholder'] as $placeholder) {
73+
$path = $this->placeholder->restore($placeholder);
74+
$path = preg_replace('/^' . ScopeConfigInterface::SCOPE_TYPE_DEFAULT . '\//', '', $path);
75+
$configs[$placeholder] = $path;
76+
}
77+
78+
return $configs;
79+
}
80+
}

app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
/**
99
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
10+
* @deprecated
1011
*/
1112
class DisableOutputTest extends \PHPUnit_Framework_TestCase
1213
{
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Config\Test\Unit\Model\Config\Parser;
7+
8+
use Magento\Config\Model\Config\Parser\Comment;
9+
use Magento\Config\Model\Placeholder\PlaceholderInterface;
10+
use Magento\Framework\App\Filesystem\DirectoryList;
11+
use Magento\Framework\Filesystem;
12+
use Magento\Framework\Filesystem\Directory\ReadInterface;
13+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
14+
15+
class CommentTest extends \PHPUnit_Framework_TestCase
16+
{
17+
/**
18+
* @var PlaceholderInterface|MockObject
19+
*/
20+
private $placeholderMock;
21+
22+
/**
23+
* @var Filesystem|MockObject
24+
*/
25+
private $fileSystemMock;
26+
27+
/**
28+
* @var Comment
29+
*/
30+
private $model;
31+
32+
protected function setUp()
33+
{
34+
$this->placeholderMock = $this->getMockBuilder(PlaceholderInterface::class)
35+
->disableOriginalConstructor()
36+
->getMockForAbstractClass();
37+
$this->fileSystemMock = $this->getMockBuilder(Filesystem::class)
38+
->disableOriginalConstructor()
39+
->getMock();
40+
41+
$this->model = new Comment(
42+
$this->fileSystemMock,
43+
$this->placeholderMock
44+
);
45+
}
46+
47+
public function testExecute()
48+
{
49+
$fileName = 'config.local.php';
50+
$directoryReadMock = $this->getMockBuilder(ReadInterface::class)
51+
->disableOriginalConstructor()
52+
->getMockForAbstractClass();
53+
$directoryReadMock->expects($this->once())
54+
->method('readFile')
55+
->with($fileName)
56+
->willReturn(file_get_contents(__DIR__ . '/../_files/' . $fileName));
57+
$this->fileSystemMock->expects($this->once())
58+
->method('getDirectoryRead')
59+
->with(DirectoryList::CONFIG)
60+
->willReturn($directoryReadMock);
61+
$this->placeholderMock->expects($this->any())
62+
->method('restore')
63+
->withConsecutive(
64+
['CONFIG__DEFAULT__SOME__PAYMENT__PASSWORD'],
65+
['CONFIG__DEFAULT__SOME__PAYMENT__TOKEN']
66+
)
67+
->willReturnOnConsecutiveCalls(
68+
'some/payment/password',
69+
'some/payment/token'
70+
);
71+
72+
$this->assertEquals(
73+
$this->model->execute($fileName),
74+
[
75+
'CONFIG__DEFAULT__SOME__PAYMENT__PASSWORD' => 'some/payment/password',
76+
'CONFIG__DEFAULT__SOME__PAYMENT__TOKEN' => 'some/payment/token'
77+
]
78+
);
79+
}
80+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
return [
7+
'scopes' => [
8+
'websites' => [
9+
'admin' => [
10+
'website_id' => '0'
11+
],
12+
],
13+
],
14+
/**
15+
* The configuration file doesn't contain sensitive data for security reasons.
16+
* Sensitive data can be stored in the following environment variables:
17+
* CONFIG__DEFAULT__SOME__PAYMENT__PASSWORD for some/payment/password
18+
*/
19+
'system' => []
20+
/**
21+
* CONFIG__DEFAULT__SOME__PAYMENT__TOKEN for some/payment/token
22+
* test phrase CONFIG__DEFAULT__SOME__PAYMENT__TOKEN for some/payment/token
23+
*/
24+
];

0 commit comments

Comments
 (0)