Skip to content

Commit 28879fd

Browse files
Merge branches 'MAGETWO-64317', 'MAGETWO-66322' and 'MAGETWO-66969' of https://github.com/magento-falcons/magento2ce into MAGETWO-67099
3 parents abf8312 + 3cd5d3b + 8bef8f5 commit 28879fd

File tree

120 files changed

+3855
-942
lines changed

Some content is hidden

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

120 files changed

+3855
-942
lines changed

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@
1616
<argument name="storage" xsi:type="object">Magento\Authorizenet\Model\Directpost\Session\Storage</argument>
1717
</arguments>
1818
</type>
19-
<type name="Magento\Config\Model\Config\Export\ExcludeList">
20-
<arguments>
21-
<argument name="configs" xsi:type="array">
22-
<item name="payment/authorizenet_directpost/login" xsi:type="string">1</item>
23-
<item name="payment/authorizenet_directpost/trans_key" xsi:type="string">1</item>
24-
<item name="payment/authorizenet_directpost/trans_md5" xsi:type="string">1</item>
25-
<item name="payment/authorizenet_directpost/merchant_email" xsi:type="string">1</item>
26-
</argument>
27-
</arguments>
28-
</type>
2919
<type name="Magento\Config\Model\Config\TypePool">
3020
<arguments>
3121
<argument name="sensitive" xsi:type="array">

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -171,24 +171,6 @@
171171
</argument>
172172
</arguments>
173173
</type>
174-
<type name="Magento\Config\Model\Config\Export\ExcludeList">
175-
<arguments>
176-
<argument name="configs" xsi:type="array">
177-
<item name="trans_email/ident_general/name" xsi:type="string">1</item>
178-
<item name="trans_email/ident_general/email" xsi:type="string">1</item>
179-
<item name="trans_email/ident_sales/name" xsi:type="string">1</item>
180-
<item name="trans_email/ident_sales/email" xsi:type="string">1</item>
181-
<item name="trans_email/ident_support/name" xsi:type="string">1</item>
182-
<item name="trans_email/ident_support/email" xsi:type="string">1</item>
183-
<item name="trans_email/ident_custom1/name" xsi:type="string">1</item>
184-
<item name="trans_email/ident_custom1/email" xsi:type="string">1</item>
185-
<item name="trans_email/ident_custom2/name" xsi:type="string">1</item>
186-
<item name="trans_email/ident_custom2/email" xsi:type="string">1</item>
187-
<item name="admin/url/custom" xsi:type="string">1</item>
188-
<item name="admin/url/custom_path" xsi:type="string">1</item>
189-
</argument>
190-
</arguments>
191-
</type>
192174
<type name="Magento\Config\Model\Config\TypePool">
193175
<arguments>
194176
<argument name="sensitive" xsi:type="array">

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -544,18 +544,6 @@
544544
</arguments>
545545
</type>
546546
<!-- END Settlement Report Section -->
547-
<type name="Magento\Config\Model\Config\Export\ExcludeList">
548-
<arguments>
549-
<argument name="configs" xsi:type="array">
550-
<item name="payment/braintree/merchant_id" xsi:type="string">1</item>
551-
<item name="payment/braintree/public_key" xsi:type="string">1</item>
552-
<item name="payment/braintree/private_key" xsi:type="string">1</item>
553-
<item name="payment/braintree/merchant_account_id" xsi:type="string">1</item>
554-
<item name="payment/braintree/kount_id" xsi:type="string">1</item>
555-
<item name="payment/braintree_paypal/merchant_name_override" xsi:type="string">1</item>
556-
</argument>
557-
</arguments>
558-
</type>
559547
<type name="Magento\Config\Model\Config\TypePool">
560548
<arguments>
561549
<argument name="sensitive" xsi:type="array">

app/code/Magento/Catalog/Block/Product/ListProduct.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,15 @@ public function getProductPrice(\Magento\Catalog\Model\Product $product)
317317
}
318318

319319
/**
320+
* Specifies that price rendering should be done for the list of products
321+
* i.e. rendering happens in the scope of product list, but not single product
322+
*
320323
* @return \Magento\Framework\Pricing\Render
321324
*/
322325
protected function getPriceRender()
323326
{
324-
return $this->getLayout()->getBlock('product.price.render.default');
327+
return $this->getLayout()->getBlock('product.price.render.default')
328+
->setData('is_product_list', true);
325329
}
326330

327331
/**

app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,19 @@ public function getCacheKeyInfo()
193193
{
194194
$cacheKeys = parent::getCacheKeyInfo();
195195
$cacheKeys['display_minimal_price'] = $this->getDisplayMinimalPrice();
196+
$cacheKeys['is_product_list'] = $this->isProductList();
196197
return $cacheKeys;
197198
}
199+
200+
/**
201+
* Get flag that price rendering should be done for the list of products
202+
* By default (if flag is not set) is false
203+
*
204+
* @return bool
205+
*/
206+
public function isProductList()
207+
{
208+
$isProductList = $this->getData('is_product_list');
209+
return $isProductList === true;
210+
}
198211
}

app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
*/
66
namespace Magento\Catalog\Test\Unit\Block\Product;
77

8+
use Magento\Catalog\Block\Product\Context;
9+
use Magento\Framework\Event\ManagerInterface;
10+
use Magento\Framework\Pricing\Render;
11+
use Magento\Framework\Url\Helper\Data;
12+
use Magento\Framework\View\LayoutInterface;
13+
814
/**
915
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1016
*/
@@ -46,7 +52,7 @@ class ListProductTest extends \PHPUnit_Framework_TestCase
4652
protected $typeInstanceMock;
4753

4854
/**
49-
* @var \Magento\Framework\Url\Helper\Data | \PHPUnit_Framework_MockObject_MockObject
55+
* @var Data | \PHPUnit_Framework_MockObject_MockObject
5056
*/
5157
protected $urlHelperMock;
5258

@@ -70,6 +76,16 @@ class ListProductTest extends \PHPUnit_Framework_TestCase
7076
*/
7177
protected $toolbarMock;
7278

79+
/**
80+
* @var Context|\PHPUnit_Framework_MockObject_MockObject
81+
*/
82+
private $context;
83+
84+
/**
85+
* @var Render|\PHPUnit_Framework_MockObject_MockObject
86+
*/
87+
private $renderer;
88+
7389
protected function setUp()
7490
{
7591
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -141,20 +157,28 @@ protected function setUp()
141157
false
142158
);
143159

144-
$this->urlHelperMock = $this->getMockBuilder(\Magento\Framework\Url\Helper\Data::class)
145-
->disableOriginalConstructor()->getMock();
160+
$this->urlHelperMock = $this->getMockBuilder(Data::class)->disableOriginalConstructor()->getMock();
161+
$this->context = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
162+
$this->renderer = $this->getMockBuilder(Render::class)->disableOriginalConstructor()->getMock();
163+
$eventManager = $this->getMockForAbstractClass(ManagerInterface::class, [], '', false);
164+
165+
$this->context->expects($this->any())->method('getRegistry')->willReturn($this->registryMock);
166+
$this->context->expects($this->any())->method('getCartHelper')->willReturn($this->cartHelperMock);
167+
$this->context->expects($this->any())->method('getLayout')->willReturn($this->layoutMock);
168+
$this->context->expects($this->any())->method('getEventManager')->willReturn($eventManager);
169+
146170
$this->block = $objectManager->getObject(
147171
\Magento\Catalog\Block\Product\ListProduct::class,
148172
[
149173
'registry' => $this->registryMock,
174+
'context' => $this->context,
150175
'layerResolver' => $layerResolver,
151176
'cartHelper' => $this->cartHelperMock,
152177
'postDataHelper' => $this->postDataHelperMock,
153178
'urlHelper' => $this->urlHelperMock,
154179
]
155180
);
156181
$this->block->setToolbarBlockName('mock');
157-
$this->block->setLayout($this->layoutMock);
158182
}
159183

160184
protected function tearDown()
@@ -257,4 +281,18 @@ public function testGetAddToCartPostParams()
257281
$result = $this->block->getAddToCartPostParams($this->productMock);
258282
$this->assertEquals($expectedPostData, $result);
259283
}
284+
285+
public function testSetIsProductListFlagOnGetProductPrice()
286+
{
287+
$this->renderer->expects($this->once())
288+
->method('setData')
289+
->with('is_product_list', true)
290+
->willReturnSelf();
291+
$this->layoutMock->expects($this->once())
292+
->method('getBlock')
293+
->with('product.price.render.default')
294+
->willReturn($this->renderer);
295+
296+
$this->block->getProductPrice($this->productMock);
297+
}
260298
}

app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,63 @@ public function testGetCacheKey()
401401
$this->assertStringEndsWith('list-category-page', $result);
402402
}
403403

404-
public function testGetCacheKeyInfo()
404+
public function testGetCacheKeyInfoContainsDisplayMinimalPrice()
405405
{
406406
$this->assertArrayHasKey('display_minimal_price', $this->object->getCacheKeyInfo());
407407
}
408+
409+
/**
410+
* Test when is_product_list flag is not specified
411+
*/
412+
public function testGetCacheKeyInfoContainsIsProductListFlagByDefault()
413+
{
414+
$cacheInfo = $this->object->getCacheKeyInfo();
415+
self::assertArrayHasKey('is_product_list', $cacheInfo);
416+
self::assertFalse($cacheInfo['is_product_list']);
417+
}
418+
419+
/**
420+
* Test when is_product_list flag is specified
421+
*
422+
* @param bool $flag
423+
* @dataProvider isProductListDataProvider
424+
*/
425+
public function testGetCacheKeyInfoContainsIsProductListFlag($flag)
426+
{
427+
$this->object->setData('is_product_list', $flag);
428+
$cacheInfo = $this->object->getCacheKeyInfo();
429+
self::assertArrayHasKey('is_product_list', $cacheInfo);
430+
self::assertEquals($flag, $cacheInfo['is_product_list']);
431+
}
432+
433+
/**
434+
* Test when is_product_list flag is not specified
435+
*/
436+
public function testIsProductListByDefault()
437+
{
438+
self::assertFalse($this->object->isProductList());
439+
}
440+
441+
/**
442+
* Test when is_product_list flag is specified
443+
*
444+
* @param bool $flag
445+
* @dataProvider isProductListDataProvider
446+
*/
447+
public function testIsProductList($flag)
448+
{
449+
$this->object->setData('is_product_list', $flag);
450+
self::assertEquals($flag, $this->object->isProductList());
451+
}
452+
453+
/**
454+
* @return array
455+
*/
456+
public function isProductListDataProvider()
457+
{
458+
return [
459+
'is_not_product_list' => [false],
460+
'is_product_list' => [true],
461+
];
462+
}
408463
}

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@
4242
</argument>
4343
</arguments>
4444
</type>
45-
<type name="Magento\Config\Model\Config\Export\ExcludeList">
46-
<arguments>
47-
<argument name="configs" xsi:type="array">
48-
<item name="checkout/payment_failed/copy_to" xsi:type="string">1</item>
49-
</argument>
50-
</arguments>
51-
</type>
5245
<type name="Magento\Config\Model\Config\TypePool">
5346
<arguments>
5447
<argument name="sensitive" xsi:type="array">

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

Lines changed: 72 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@
1717
class DumpConfigSourceAggregated implements DumpConfigSourceInterface
1818
{
1919
/**
20-
* @var ExcludeList
20+
* Rule name for include configuration data.
2121
*/
22-
private $excludeList;
22+
const RULE_TYPE_INCLUDE = 'include';
23+
24+
/**
25+
* Rule name for exclude configuration data.
26+
*/
27+
const RULE_TYPE_EXCLUDE = 'exclude';
2328

2429
/**
2530
* Checker for config type.
@@ -44,15 +49,49 @@ class DumpConfigSourceAggregated implements DumpConfigSourceInterface
4449
private $data;
4550

4651
/**
47-
* @param ExcludeList $excludeList
52+
* Array of rules for filtration the configuration data.
53+
*
54+
* For example:
55+
* ```php
56+
* [
57+
* 'default' => 'include',
58+
* 'sensitive' => 'exclude',
59+
* 'environment' => 'exclude',
60+
* ]
61+
* ```
62+
* It means that all aggregated configuration data will be included in result but configurations
63+
* that relates to 'sensitive' or 'environment' will be excluded.
64+
*
65+
*
66+
* ```php
67+
* [
68+
* 'default' => 'exclude',
69+
* 'sensitive' => 'include',
70+
* 'environment' => 'include',
71+
* ]
72+
* ```
73+
* It means that result will contains only 'sensitive' and 'environment' configurations.
74+
*
75+
* @var array
76+
*/
77+
private $rules;
78+
79+
/**
80+
* @param ExcludeList $excludeList Is not used anymore as it was deprecated, use TypePool instead.
4881
* @param array $sources
4982
* @param TypePool|null $typePool
83+
* @param array $rules Rules for filtration the configuration data.
84+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5085
*/
51-
public function __construct(ExcludeList $excludeList, array $sources = [], TypePool $typePool = null)
52-
{
53-
$this->excludeList = $excludeList;
86+
public function __construct(
87+
ExcludeList $excludeList,
88+
array $sources = [],
89+
TypePool $typePool = null,
90+
array $rules = []
91+
) {
5492
$this->sources = $sources;
5593
$this->typePool = $typePool ?: ObjectManager::getInstance()->get(TypePool::class);
94+
$this->rules = $rules;
5695
}
5796

5897
/**
@@ -97,30 +136,45 @@ private function filterChain($path, &$data)
97136
$newPath = $path ? $path . '/' . $subKey : $subKey;
98137
$filteredPath = $this->filterPath($newPath);
99138

100-
if ($filteredPath
101-
&& !is_array($data[$subKey])
102-
&& $this->isExcludePath($filteredPath)
103-
) {
139+
if (is_array($subData)) {
140+
$this->filterChain($newPath, $subData);
141+
} elseif ($this->isExcludedPath($filteredPath)) {
104142
$this->excludedFields[$newPath] = $filteredPath;
143+
unset($data[$subKey]);
144+
}
105145

146+
if (empty($subData) && isset($data[$subKey]) && is_array($data[$subKey])) {
106147
unset($data[$subKey]);
107-
} elseif (is_array($subData)) {
108-
$this->filterChain($newPath, $subData);
109148
}
110149
}
111150
}
112151

113152
/**
114-
* Checks if the configuration field belongs to a sensitive type.
153+
* Checks if the configuration field needs to be excluded.
115154
*
116155
* @param string $path Configuration field path. For example 'contact/email/recipient_email'
117-
* @return boolean
156+
* @return boolean Return true if path should be excluded
118157
*/
119-
private function isExcludePath($path)
158+
private function isExcludedPath($path)
120159
{
121-
return $this->excludeList->isPresent($path)
122-
|| $this->typePool->isPresent($path, TypePool::TYPE_ENVIRONMENT)
123-
|| $this->typePool->isPresent($path, TypePool::TYPE_SENSITIVE);
160+
if (empty($path)) {
161+
return false;
162+
}
163+
164+
$defaultRule = isset($this->rules['default']) ?
165+
$this->rules['default'] : self::RULE_TYPE_INCLUDE;
166+
167+
foreach ($this->rules as $type => $rule) {
168+
if ($type === 'default') {
169+
continue;
170+
}
171+
172+
if ($this->typePool->isPresent($path, $type)) {
173+
return $rule === self::RULE_TYPE_EXCLUDE;
174+
}
175+
}
176+
177+
return $defaultRule === self::RULE_TYPE_EXCLUDE;
124178
}
125179

126180
/**

0 commit comments

Comments
 (0)