Skip to content

Commit 7feba6c

Browse files
Fix PageCache: async rendering of blocks can corrupt layout cache #8554 #9050
Adapted page cache tests
1 parent bf7df0d commit 7feba6c

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ protected function setUp()
8989
public function testExecute($blockClass, $shouldSetHeaders)
9090
{
9191
$block = 'block';
92-
$handles = ['handle1', 'handle2'];
92+
$requestHandles = ['handle1', 'handle2'];
93+
$additionalPageCacheHandle = 'additional_page_cache_handle';
94+
$pageCacheHandles = array_merge($requestHandles, [$additionalPageCacheHandle]);
9395
$html = 'some-html';
94-
$mapData = [['blocks', '', json_encode([$block])], ['handles', '', base64_encode(json_encode($handles))]];
96+
$mapData = [['blocks', '', json_encode([$block])], ['handles', '', base64_encode(json_encode($requestHandles))]];
9597

9698
$blockInstance1 = $this->getMock(
9799
$blockClass,
@@ -106,7 +108,7 @@ public function testExecute($blockClass, $shouldSetHeaders)
106108

107109
$this->requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap($mapData));
108110

109-
$this->viewMock->expects($this->once())->method('loadLayout')->with($this->equalTo($handles));
111+
$this->viewMock->expects($this->once())->method('loadLayout')->with($this->equalTo($pageCacheHandles));
110112

111113
$this->viewMock->expects($this->once())->method('getLayout')->will($this->returnValue($this->layoutMock));
112114

app/code/Magento/PageCache/Test/Unit/Controller/Block/RenderTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ public function testExecuteNoParams()
111111
public function testExecute()
112112
{
113113
$blocks = ['block1', 'block2'];
114-
$handles = ['handle1', 'handle2'];
114+
$requestHandles = ['handle1', 'handle2'];
115+
$additionalPageCacheHandle = 'additional_page_cache_handle';
116+
$pageCacheHandles = array_merge($requestHandles, [$additionalPageCacheHandle]);
117+
115118
$originalRequest = '{"route":"route","controller":"controller","action":"action","uri":"uri"}';
116119
$expectedData = ['block1' => 'data1', 'block2' => 'data2'];
117120

@@ -159,8 +162,8 @@ public function testExecute()
159162
$this->requestMock->expects($this->at(11))
160163
->method('getParam')
161164
->with($this->equalTo('handles'), $this->equalTo(''))
162-
->will($this->returnValue(base64_encode(json_encode($handles))));
163-
$this->viewMock->expects($this->once())->method('loadLayout')->with($this->equalTo($handles));
165+
->will($this->returnValue(base64_encode(json_encode($requestHandles))));
166+
$this->viewMock->expects($this->once())->method('loadLayout')->with($this->equalTo($pageCacheHandles));
164167
$this->viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($this->layoutMock));
165168
$this->layoutMock->expects($this->at(0))
166169
->method('getBlock')

0 commit comments

Comments
 (0)