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 #9560

Adapted PageCache and Framework tests
  • Loading branch information
adrian-martinez-interactiv4 committed Sep 22, 2017
1 parent 3cc51dc commit 2ae9c26
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class MergeTest extends \PHPUnit\Framework\TestCase
*/
protected $pageConfig;

/**
* @var \Magento\Framework\View\Layout\LayoutCacheKeyInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $layoutCacheKeyMock;

protected function setUp()
{
$files = [];
Expand Down Expand Up @@ -119,6 +124,11 @@ function ($filename) use ($fileDriver) {
)
);

$this->layoutCacheKeyMock = $this->getMockForAbstractClass(\Magento\Framework\View\Layout\LayoutCacheKeyInterface::class);
$this->layoutCacheKeyMock->expects($this->any())
->method('getCacheKeys')
->willReturn([]);

$this->_model = $objectHelper->getObject(
\Magento\Framework\View\Model\Layout\Merge::class,
[
Expand All @@ -134,6 +144,7 @@ function ($filename) use ($fileDriver) {
'logger' => $this->_logger,
'readFactory' => $readFactory,
'pageConfig' => $this->pageConfig,
'layoutCacheKey' => $this->layoutCacheKeyMock,
]
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class MergeTest extends \PHPUnit\Framework\TestCase
*/
protected $model;

/**
* @var \Magento\Framework\View\Layout\LayoutCacheKeyInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $layoutCacheKeyMock;

protected function setUp()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
Expand Down Expand Up @@ -62,9 +67,17 @@ protected function setUp()
$link2->setLayoutUpdateId($layoutUpdate2->getId());
$link2->save();

$this->layoutCacheKeyMock = $this->getMockForAbstractClass(\Magento\Framework\View\Layout\LayoutCacheKeyInterface::class);
$this->layoutCacheKeyMock->expects($this->any())
->method('getCacheKeys')
->willReturn([]);

$this->model = $objectManager->create(
\Magento\Framework\View\Model\Layout\Merge::class,
['theme' => $theme]
[
'theme' => $theme,
'layoutCacheKey' => $this->layoutCacheKeyMock,
]
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ protected function setUp()
$this->appState = $this->getMockBuilder(\Magento\Framework\App\State::class)
->disableOriginalConstructor()
->getMock();

$this->layoutCacheKeyMock = $this->getMockForAbstractClass(\Magento\Framework\View\Layout\LayoutCacheKeyInterface::class);
$this->layoutCacheKeyMock->expects($this->any())
->method('getCacheKeys')
->willReturn([]);

$this->model = $this->objectManagerHelper->getObject(
\Magento\Framework\View\Model\Layout\Merge::class,
Expand All @@ -68,7 +72,7 @@ protected function setUp()
'layoutValidator' => $this->layoutValidator,
'logger' => $this->logger,
'appState' => $this->appState,
'layoutCacheKey' => $this->layoutCacheKeyMock
'layoutCacheKey' => $this->layoutCacheKeyMock,
]
);
}
Expand All @@ -83,9 +87,6 @@ public function testValidateMergedLayoutThrowsException()
'Please correct the XSD data and try again.',
];
$this->scope->expects($this->once())->method('getId')->willReturn(1);
$this->layoutCacheKeyMock->expects($this->once())
->method('getCacheKeys')
->willReturn([]);
$this->layoutValidator->expects($this->once())
->method('isValid')
->willThrowException(
Expand Down

0 comments on commit 2ae9c26

Please sign in to comment.