.../lib/Drupal/menu/Tests/MenuCacheTagsTest.php | 26 +++++++++++--------- .../Tests/Cache/PageCacheTagsIntegrationTest.php | 16 +++++++----- .../system/Tests/Cache/PageCacheTagsTestBase.php | 2 +- .../Controller/EntityTestController.php | 4 +-- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuCacheTagsTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuCacheTagsTest.php index 14c6168..c09875c 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuCacheTagsTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuCacheTagsTest.php @@ -37,6 +37,8 @@ public static function getInfo() { * - "menu:" */ public function testMenuBlock() { + $path = 'test-page'; + // Create a Llama menu, add a link to it and place the corresponding block. $menu = entity_create('menu', array( 'id' => 'llama', @@ -53,30 +55,30 @@ public function testMenuBlock() { $block = $this->drupalPlaceBlock('system_menu_block:llama', array('label' => 'Llama', 'module' => 'system', 'region' => 'footer')); // Prime the page cache. - $this->verifyPageCache('test-page', 'MISS'); + $this->verifyPageCache($path, 'MISS'); // Verify a cache hit, but also the presence of the correct cache tags. - $this->verifyPageCache('test-page', 'HIT', array('content:1', 'menu:llama')); + $this->verifyPageCache($path, 'HIT', array('content:1', 'menu:llama')); // Verify that after modifying the menu, there is a cache miss. $this->pass('Test modification of menu.', 'Debug'); $menu->label = 'Awesome llama'; $menu->save(); - $this->verifyPageCache('test-page', 'MISS'); + $this->verifyPageCache($path, 'MISS'); // Verify a cache hit. - $this->verifyPageCache('test-page', 'HIT'); + $this->verifyPageCache($path, 'HIT'); // Verify that after modifying the menu link, there is a cache miss. $this->pass('Test modification of menu link.', 'Debug'); $menu_link->link_title = 'Guanaco'; $menu_link->save(); - $this->verifyPageCache('test-page', 'MISS'); + $this->verifyPageCache($path, 'MISS'); // Verify a cache hit. - $this->verifyPageCache('test-page', 'HIT'); + $this->verifyPageCache($path, 'HIT'); // Verify that after adding a menu link, there is a cache miss. @@ -87,28 +89,28 @@ public function testMenuBlock() { 'menu_name' => 'llama', )); $menu_link_2->save(); - $this->verifyPageCache('test-page', 'MISS'); + $this->verifyPageCache($path, 'MISS'); // Verify a cache hit. - $this->verifyPageCache('test-page', 'HIT'); + $this->verifyPageCache($path, 'HIT'); // Verify that after deleting the first menu link, there is a cache miss. $this->pass('Test deletion of menu link.', 'Debug'); $menu_link->delete(); - $this->verifyPageCache('test-page', 'MISS'); + $this->verifyPageCache($path, 'MISS'); // Verify a cache hit. - $this->verifyPageCache('test-page', 'HIT', array('content:1', 'menu:llama')); + $this->verifyPageCache($path, 'HIT', array('content:1', 'menu:llama')); // Verify that after deleting the menu, there is a cache miss. $this->pass('Test deletion of menu.', 'Debug'); $menu->delete(); - $this->verifyPageCache('test-page', 'MISS'); + $this->verifyPageCache($path, 'MISS'); // Verify a cache hit. - $this->verifyPageCache('test-page', 'HIT', array('content:1')); + $this->verifyPageCache($path, 'HIT', array('content:1')); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php b/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php index 4b4c799..b245c34 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php @@ -46,27 +46,29 @@ function setUp() { function testPageCacheTags() { // Create two nodes. $author_1 = $this->drupalCreateUser(); - $node_1_path = 'node/' . $this->drupalCreateNode(array( + $node_1 = $this->drupalCreateNode(array( 'uid' => $author_1->id(), 'title' => 'Node 1', 'body' => array( 0 => array('value' => 'Body 1', 'format' => 'basic_html'), ), 'promote' => NODE_PROMOTED, - ))->id(); + )); $author_2 = $this->drupalCreateUser(); - $node_2_path = 'node/' . $this->drupalCreateNode(array( + $node_2 = $this->drupalCreateNode(array( 'uid' => $author_2->id(), 'title' => 'Node 2', 'body' => array( 0 => array('value' => 'Body 2', 'format' => 'full_html'), ), 'promote' => NODE_PROMOTED, - ))->id(); + )); // Full node page 1. - $this->verifyPageCacheTags($node_1_path, array( + $this->verifyPageCacheTags('node/' . $node_1->id(), array( 'content:1', + 'node_view:1', + 'node:' . $node_1->id(), 'user:' . $author_1->id(), 'filter_format:basic_html', 'menu:footer', @@ -74,8 +76,10 @@ function testPageCacheTags() { )); // Full node page 2. - $this->verifyPageCacheTags($node_2_path, array( + $this->verifyPageCacheTags('node/' . $node_2->id(), array( 'content:1', + 'node_view:1', + 'node:' . $node_2->id(), 'user:' . $author_2->id(), 'filter_format:full_html', 'menu:footer', diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsTestBase.php index 3bc1ee2..194976a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsTestBase.php @@ -24,7 +24,7 @@ public function setUp() { // Enable page caching. $config = \Drupal::config('system.performance'); $config->set('cache.page.use_internal', 1); - $config->set('cache.page.max_age', 300); + $config->set('cache.page.max_age', 3600); $config->save(); } diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Controller/EntityTestController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Controller/EntityTestController.php index 126f08b..30dd485 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Controller/EntityTestController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Controller/EntityTestController.php @@ -38,7 +38,7 @@ public function testAdmin() { } /** - * List entity_test entities referencing the given entity + * List entity_test entities referencing the given entity. * * @param string $entity_reference_field_name * The name of the entity_reference field to use in the query. @@ -59,9 +59,7 @@ public function listReferencingEntities($entity_reference_field_name, $reference $query = \Drupal::service('entity.query') ->get('entity_test') ->condition($entity_reference_field_name . '.target_id', $referenced_entity_id); - $entities = entity_load_multiple('entity_test', $query->execute()); - return entity_view_multiple($entities, 'full'); }