Skip to content

Commit 66cbfaf

Browse files
committed
MC-30786: [Escalation] Re: Magento 2.3.4 | serious issues with local storage if custom sections.xml invalidations are active
1 parent c23904b commit 66cbfaf

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Customer\Test\Unit\CustomerData;
88

9+
use Magento\Framework\App\Arguments\ValidationState;
910
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1011

1112
class SectionConfigConverterTest extends \PHPUnit\Framework\TestCase
@@ -19,28 +20,66 @@ class SectionConfigConverterTest extends \PHPUnit\Framework\TestCase
1920
/** @var \DOMDocument */
2021
protected $source;
2122

23+
/** @var \Magento\Framework\Config\Dom config merger */
24+
private $configMergerClass;
25+
26+
/** @var ValidationState */
27+
private $validationStateMock;
28+
2229
protected function setUp()
2330
{
2431
$this->source = new \DOMDocument();
2532
$this->objectManagerHelper = new ObjectManagerHelper($this);
2633
$this->converter = $this->objectManagerHelper->getObject(
2734
\Magento\Customer\CustomerData\SectionConfigConverter::class
2835
);
36+
$this->validationStateMock = $this->createMock(ValidationState::class);
37+
}
38+
39+
/**
40+
* Return newly created instance of a config merger
41+
*
42+
* @param string $mergerClass
43+
* @param string $initialContents
44+
* @return \Magento\Framework\Config\Dom
45+
* @throws \UnexpectedValueException
46+
*/
47+
private function createConfig($mergerClass, $initialContents)
48+
{
49+
$this->validationStateMock->method('isValidationRequired')->willReturn(\false);
50+
return new $mergerClass(
51+
$initialContents,
52+
$this->validationStateMock,
53+
[
54+
'/config/action' => 'name',
55+
'/config/action/section' => 'name',
56+
],
57+
null,
58+
null
59+
);
2960
}
3061

3162
public function testConvert()
3263
{
3364
$this->source->loadXML(file_get_contents(__DIR__ . '/_files/sections.xml'));
3465

66+
$this->configMergerClass = $this->createConfig(
67+
'Magento\Framework\Config\Dom',
68+
file_get_contents(__DIR__ . '/_files/sections.xml')
69+
);
70+
71+
$this->configMergerClass->merge(file_get_contents(__DIR__ . '/_files/sections2.xml'));
72+
3573
$this->assertEquals(
3674
[
3775
'sections' => [
3876
'customer/account/logout' => ['*'],
77+
'empty/test' => ['account'],
3978
'customer/account/editpost' => ['account'],
4079
'customer/account/createpost' => ['account', 'acc'],
4180
],
4281
],
43-
$this->converter->convert($this->source)
82+
$this->converter->convert($this->configMergerClass->getDom())
4483
);
4584
}
4685
}

app/code/Magento/Customer/Test/Unit/CustomerData/_files/sections.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
<section name="account"/>
2121
<section name="acc"/>
2222
</action>
23+
<action name="empty/test"/>
2324
</config>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
10+
<action name="empty/test">
11+
<section name="account"/>
12+
</action>
13+
</config>

0 commit comments

Comments
 (0)