Skip to content

Commit f5f33fe

Browse files
committed
Merge remote-tracking branch 'origin/2.1-develop' into 2.1-develop-pr46
2 parents a9ad9a0 + 84f32b9 commit f5f33fe

File tree

6 files changed

+66
-28
lines changed

6 files changed

+66
-28
lines changed

app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
<argument name="at_call" xsi:type="string">getShortDescription</argument>
9595
<argument name="at_code" xsi:type="string">short_description</argument>
9696
<argument name="css_class" xsi:type="string">overview</argument>
97-
<argument name="at_label" translate="true" xsi:type="string">none</argument>
97+
<argument name="at_label" xsi:type="string">none</argument>
9898
<argument name="title" translate="true" xsi:type="string">Overview</argument>
9999
<argument name="add_attribute" xsi:type="string">itemprop="description"</argument>
100100
</arguments>
@@ -109,7 +109,7 @@
109109
<argument name="at_call" xsi:type="string">getDescription</argument>
110110
<argument name="at_code" xsi:type="string">description</argument>
111111
<argument name="css_class" xsi:type="string">description</argument>
112-
<argument name="at_label" translate="true" xsi:type="string">none</argument>
112+
<argument name="at_label" xsi:type="string">none</argument>
113113
<argument name="title" translate="true" xsi:type="string">Details</argument>
114114
</arguments>
115115
</block>

app/code/Magento/Catalog/view/frontend/templates/product/view/attribute.phtml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ $_attributeLabel = $block->getAtLabel();
2222
$_attributeType = $block->getAtType();
2323
$_attributeAddAttribute = $block->getAddAttribute();
2424

25+
$renderLabel = true;
26+
// if defined as 'none' in layout, do not render
27+
if ($_attributeLabel == 'none') {
28+
$renderLabel = false;
29+
}
30+
2531
if ($_attributeLabel && $_attributeLabel == 'default') {
2632
$_attributeLabel = $_product->getResource()->getAttribute($_code)->getFrontendLabel();
2733
}
@@ -34,7 +40,7 @@ if ($_attributeType && $_attributeType == 'text') {
3440

3541
<?php if ($_attributeValue): ?>
3642
<div class="product attribute <?php /* @escapeNotVerified */ echo $_className?>">
37-
<?php if ($_attributeLabel != __('none')): ?><strong class="type"><?php /* @escapeNotVerified */ echo $_attributeLabel?></strong><?php endif; ?>
43+
<?php if ($renderLabel): ?><strong class="type"><?php /* @escapeNotVerified */ echo $_attributeLabel?></strong><?php endif; ?>
3844
<div class="value" <?php /* @escapeNotVerified */ echo $_attributeAddAttribute;?>><?php /* @escapeNotVerified */ echo $_attributeValue; ?></div>
3945
</div>
4046
<?php endif; ?>

app/code/Magento/Config/App/Config/Source/RuntimeConfigSource.php

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

89
use Magento\Framework\App\Config\ConfigSourceInterface;
@@ -84,12 +85,12 @@ private function loadConfig()
8485
}
8586
}
8687

87-
foreach ($config as $scope => &$item) {
88+
foreach ($config as $scope => $item) {
8889
if ($scope === ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
89-
$item = $this->converter->convert($item);
90+
$config[$scope] = $this->converter->convert($item);
9091
} else {
91-
foreach ($item as &$scopeItems) {
92-
$scopeItems = $this->converter->convert($scopeItems);
92+
foreach ($item as $scopeCode => $scopeItems) {
93+
$config[$scope][$scopeCode] = $this->converter->convert($scopeItems);
9394
}
9495
}
9596
}

dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTreeTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Catalog\Model;
78

9+
use Magento\TestFramework\Helper\Bootstrap;
10+
811
/**
912
* Test class for \Magento\Catalog\Model\Category.
1013
* - tree knowledge is tested
@@ -23,9 +26,7 @@ class CategoryTreeTest extends \PHPUnit_Framework_TestCase
2326

2427
protected function setUp()
2528
{
26-
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
27-
'Magento\Catalog\Model\Category'
28-
);
29+
$this->_model = Bootstrap::getObjectManager()->create(Category::class);
2930
}
3031

3132
/**
@@ -125,7 +126,7 @@ public function testGetParentIds()
125126
public function testGetChildren()
126127
{
127128
$this->_model->load(3);
128-
$this->assertEquals('4,13', $this->_model->getChildren());
129+
$this->assertEquals([], array_diff([4, 13], explode(',', $this->_model->getChildren())));
129130
}
130131

131132
public function testGetPathInStore()
@@ -172,28 +173,28 @@ public function testGetParentCategories()
172173
{
173174
$this->_model->load(5);
174175
$parents = $this->_model->getParentCategories();
175-
$this->assertEquals(3, count($parents));
176+
$this->assertCount(3, $parents);
176177
}
177178

178179
public function testGetParentCategoriesEmpty()
179180
{
180181
$this->_model->load(1);
181182
$parents = $this->_model->getParentCategories();
182-
$this->assertEquals(0, count($parents));
183+
$this->assertCount(0, $parents);
183184
}
184185

185186
public function testGetChildrenCategories()
186187
{
187188
$this->_model->load(3);
188189
$children = $this->_model->getChildrenCategories();
189-
$this->assertEquals(2, count($children));
190+
$this->assertCount(2, $children);
190191
}
191192

192193
public function testGetChildrenCategoriesEmpty()
193194
{
194195
$this->_model->load(5);
195196
$children = $this->_model->getChildrenCategories();
196-
$this->assertEquals(0, count($children));
197+
$this->assertCount(0, $children);
197198
}
198199

199200
public function testGetParentDesignCategory()

lib/internal/Magento/Framework/App/Config/Scope/Converter.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Copyright © Magento, Inc. All rights reserved.
66
* See COPYING.txt for license details.
77
*/
8+
89
namespace Magento\Framework\App\Config\Scope;
910

1011
class Converter implements \Magento\Framework\Config\ConverterInterface
@@ -19,29 +20,36 @@ public function convert($source)
1920
{
2021
$output = [];
2122
foreach ($source as $key => $value) {
22-
$this->_setArrayValue($output, $key, $value);
23+
$output = $this->_setArrayValue($output, $key, $value);
2324
}
2425
return $output;
2526
}
2627

2728
/**
2829
* Set array value by path
2930
*
30-
* @param array &$container
31+
* @param array $container
3132
* @param string $path
3233
* @param string $value
33-
* @return void
34+
* @return array
3435
*/
35-
protected function _setArrayValue(array &$container, $path, $value)
36+
protected function _setArrayValue(array $container, $path, $value)
3637
{
37-
$segments = explode('/', $path);
38-
$currentPointer = & $container;
39-
foreach ($segments as $segment) {
40-
if (!isset($currentPointer[$segment])) {
41-
$currentPointer[$segment] = [];
38+
$parts = explode('/', $path);
39+
40+
if (count($parts) > 0) {
41+
$parts = array_reverse($parts);
42+
43+
$result = $value;
44+
foreach ($parts as $part) {
45+
$part = trim($part);
46+
if ($part !== '') {
47+
$result = [$part => $result];
48+
}
4249
}
43-
$currentPointer = & $currentPointer[$segment];
50+
51+
$container = array_merge_recursive($container, $result);
4452
}
45-
$currentPointer = $value;
53+
return $container;
4654
}
4755
}

lib/internal/Magento/Framework/App/Test/Unit/Config/Scope/ConverterTest.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Framework\App\Test\Unit\Config\Scope;
78

89
class ConverterTest extends \PHPUnit_Framework_TestCase
@@ -19,8 +20,29 @@ protected function setUp()
1920

2021
public function testConvert()
2122
{
22-
$data = ['some/config/path1' => 'value1', 'some/config/path2' => 'value2'];
23-
$expectedResult = ['some' => ['config' => ['path1' => 'value1', 'path2' => 'value2']]];
23+
$data = [
24+
'some/config/path1' => 'value1',
25+
'some/config/path2' => 'value2',
26+
'some/config/path2' => 'value3',
27+
'some2/config/path2' => 'value4',
28+
'some/bad/path////' => 'value5',
29+
];
30+
$expectedResult = [
31+
'some' => [
32+
'config' => [
33+
'path1' => 'value1',
34+
'path2' => 'value3',
35+
],
36+
'bad' => [
37+
'path' => 'value5',
38+
],
39+
],
40+
'some2' => [
41+
'config' => [
42+
'path2' => 'value4',
43+
]
44+
]
45+
];
2446
$this->assertEquals($expectedResult, $this->_model->convert($data));
2547
}
2648
}

0 commit comments

Comments
 (0)