Skip to content

Commit

Permalink
Fix PageCache: async rendering of blocks can corrupt layout cache #8554
Browse files Browse the repository at this point in the history
#9050

Adapted page cache tests
  • Loading branch information
adrian-martinez-interactiv4 committed May 9, 2017
1 parent bf7df0d commit 7feba6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ protected function setUp()
public function testExecute($blockClass, $shouldSetHeaders)
{
$block = 'block';
$handles = ['handle1', 'handle2'];
$requestHandles = ['handle1', 'handle2'];
$additionalPageCacheHandle = 'additional_page_cache_handle';
$pageCacheHandles = array_merge($requestHandles, [$additionalPageCacheHandle]);
$html = 'some-html';
$mapData = [['blocks', '', json_encode([$block])], ['handles', '', base64_encode(json_encode($handles))]];
$mapData = [['blocks', '', json_encode([$block])], ['handles', '', base64_encode(json_encode($requestHandles))]];

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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ public function testExecuteNoParams()
public function testExecute()
{
$blocks = ['block1', 'block2'];
$handles = ['handle1', 'handle2'];
$requestHandles = ['handle1', 'handle2'];
$additionalPageCacheHandle = 'additional_page_cache_handle';
$pageCacheHandles = array_merge($requestHandles, [$additionalPageCacheHandle]);

$originalRequest = '{"route":"route","controller":"controller","action":"action","uri":"uri"}';
$expectedData = ['block1' => 'data1', 'block2' => 'data2'];

Expand Down Expand Up @@ -159,8 +162,8 @@ public function testExecute()
$this->requestMock->expects($this->at(11))
->method('getParam')
->with($this->equalTo('handles'), $this->equalTo(''))
->will($this->returnValue(base64_encode(json_encode($handles))));
$this->viewMock->expects($this->once())->method('loadLayout')->with($this->equalTo($handles));
->will($this->returnValue(base64_encode(json_encode($requestHandles))));
$this->viewMock->expects($this->once())->method('loadLayout')->with($this->equalTo($pageCacheHandles));
$this->viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($this->layoutMock));
$this->layoutMock->expects($this->at(0))
->method('getBlock')
Expand Down

0 comments on commit 7feba6c

Please sign in to comment.