Skip to content

Commit 2ae9c26

Browse files
Fix PageCache: async rendering of blocks can corrupt layout cache #8554 #9050 #9560
Adapted PageCache and Framework tests
1 parent 3cc51dc commit 2ae9c26

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

dev/tests/integration/testsuite/Magento/Framework/View/Layout/MergeTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class MergeTest extends \PHPUnit\Framework\TestCase
6565
*/
6666
protected $pageConfig;
6767

68+
/**
69+
* @var \Magento\Framework\View\Layout\LayoutCacheKeyInterface|\PHPUnit_Framework_MockObject_MockObject
70+
*/
71+
protected $layoutCacheKeyMock;
72+
6873
protected function setUp()
6974
{
7075
$files = [];
@@ -119,6 +124,11 @@ function ($filename) use ($fileDriver) {
119124
)
120125
);
121126

127+
$this->layoutCacheKeyMock = $this->getMockForAbstractClass(\Magento\Framework\View\Layout\LayoutCacheKeyInterface::class);
128+
$this->layoutCacheKeyMock->expects($this->any())
129+
->method('getCacheKeys')
130+
->willReturn([]);
131+
122132
$this->_model = $objectHelper->getObject(
123133
\Magento\Framework\View\Model\Layout\Merge::class,
124134
[
@@ -134,6 +144,7 @@ function ($filename) use ($fileDriver) {
134144
'logger' => $this->_logger,
135145
'readFactory' => $readFactory,
136146
'pageConfig' => $this->pageConfig,
147+
'layoutCacheKey' => $this->layoutCacheKeyMock,
137148
]
138149
);
139150
}

dev/tests/integration/testsuite/Magento/Framework/View/Model/Layout/MergeTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class MergeTest extends \PHPUnit\Framework\TestCase
1818
*/
1919
protected $model;
2020

21+
/**
22+
* @var \Magento\Framework\View\Layout\LayoutCacheKeyInterface|\PHPUnit_Framework_MockObject_MockObject
23+
*/
24+
protected $layoutCacheKeyMock;
25+
2126
protected function setUp()
2227
{
2328
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
@@ -62,9 +67,17 @@ protected function setUp()
6267
$link2->setLayoutUpdateId($layoutUpdate2->getId());
6368
$link2->save();
6469

70+
$this->layoutCacheKeyMock = $this->getMockForAbstractClass(\Magento\Framework\View\Layout\LayoutCacheKeyInterface::class);
71+
$this->layoutCacheKeyMock->expects($this->any())
72+
->method('getCacheKeys')
73+
->willReturn([]);
74+
6575
$this->model = $objectManager->create(
6676
\Magento\Framework\View\Model\Layout\Merge::class,
67-
['theme' => $theme]
77+
[
78+
'theme' => $theme,
79+
'layoutCacheKey' => $this->layoutCacheKeyMock,
80+
]
6881
);
6982
}
7083

lib/internal/Magento/Framework/View/Test/Unit/Model/Layout/MergeTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ protected function setUp()
5959
$this->appState = $this->getMockBuilder(\Magento\Framework\App\State::class)
6060
->disableOriginalConstructor()
6161
->getMock();
62+
6263
$this->layoutCacheKeyMock = $this->getMockForAbstractClass(\Magento\Framework\View\Layout\LayoutCacheKeyInterface::class);
64+
$this->layoutCacheKeyMock->expects($this->any())
65+
->method('getCacheKeys')
66+
->willReturn([]);
6367

6468
$this->model = $this->objectManagerHelper->getObject(
6569
\Magento\Framework\View\Model\Layout\Merge::class,
@@ -68,7 +72,7 @@ protected function setUp()
6872
'layoutValidator' => $this->layoutValidator,
6973
'logger' => $this->logger,
7074
'appState' => $this->appState,
71-
'layoutCacheKey' => $this->layoutCacheKeyMock
75+
'layoutCacheKey' => $this->layoutCacheKeyMock,
7276
]
7377
);
7478
}
@@ -83,9 +87,6 @@ public function testValidateMergedLayoutThrowsException()
8387
'Please correct the XSD data and try again.',
8488
];
8589
$this->scope->expects($this->once())->method('getId')->willReturn(1);
86-
$this->layoutCacheKeyMock->expects($this->once())
87-
->method('getCacheKeys')
88-
->willReturn([]);
8990
$this->layoutValidator->expects($this->once())
9091
->method('isValid')
9192
->willThrowException(

0 commit comments

Comments
 (0)