MergeTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\PageCache\Model\Layout;
  7. use Magento\Framework\View\EntitySpecificHandlesList;
  8. class MergeTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @magentoAppArea frontend
  12. * @expectedException \LogicException
  13. * @expectedExceptionMessage Handle 'default' must not contain blocks with 'ttl' attribute specified
  14. */
  15. public function testLoadEntitySpecificHandleWithEsiBlock()
  16. {
  17. $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  18. // Mock cache to avoid layout being read from existing cache
  19. $cacheMock = $this->createMock(\Magento\Framework\Cache\FrontendInterface::class);
  20. /** @var \Magento\Framework\View\Model\Layout\Merge $layoutMerge */
  21. $layoutMerge = $objectManager->create(
  22. \Magento\Framework\View\Model\Layout\Merge::class,
  23. ['cache' => $cacheMock]
  24. );
  25. /** @var EntitySpecificHandlesList $entitySpecificHandleList */
  26. $entitySpecificHandleList = $objectManager->get(EntitySpecificHandlesList::class);
  27. // Add 'default' handle, which has declarations of blocks with ttl, to the list of entity specific handles.
  28. // This allows to simulate a situation, when block with ttl attribute
  29. // is declared e.g. in 'catalog_product_view_id_1' handle
  30. $entitySpecificHandleList->addHandle('default');
  31. $layoutMerge->load(['default']);
  32. }
  33. }