Loading core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +4 −9 Original line number Diff line number Diff line Loading @@ -519,19 +519,18 @@ public function testGet() { // @see \Drupal\rest\EventSubscriber\ResourceResponseSubscriber::flattenResponse() $cache_items = $this->container->get('database') ->select('cache_dynamic_page_cache', 'c') ->fields('c', ['cid', 'data']) ->fields('c', ['data']) ->condition('c.cid', '%[route]=rest.%', 'LIKE') ->execute() ->fetchAllAssoc('cid'); ->fetchAll(); if (!$is_cacheable_by_dynamic_page_cache) { $this->assertCount(0, $cache_items); } else { $this->assertCount(2, $cache_items); $found_cache_redirect = FALSE; $this->assertLessThanOrEqual(2, count($cache_items)); $found_cached_200_response = FALSE; $other_cached_responses_are_4xx = TRUE; foreach ($cache_items as $cid => $cache_item) { foreach ($cache_items as $cache_item) { $cached_data = unserialize($cache_item->data); if (!isset($cached_data['#cache_redirect'])) { $cached_response = $cached_data['#response']; Loading @@ -544,11 +543,7 @@ public function testGet() { $this->assertNotInstanceOf(ResourceResponseInterface::class, $cached_response); $this->assertInstanceOf(CacheableResponseInterface::class, $cached_response); } else { $found_cache_redirect = TRUE; } } $this->assertTrue($found_cache_redirect); $this->assertTrue($found_cached_200_response); $this->assertTrue($other_cached_responses_are_4xx); } Loading Loading
core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +4 −9 Original line number Diff line number Diff line Loading @@ -519,19 +519,18 @@ public function testGet() { // @see \Drupal\rest\EventSubscriber\ResourceResponseSubscriber::flattenResponse() $cache_items = $this->container->get('database') ->select('cache_dynamic_page_cache', 'c') ->fields('c', ['cid', 'data']) ->fields('c', ['data']) ->condition('c.cid', '%[route]=rest.%', 'LIKE') ->execute() ->fetchAllAssoc('cid'); ->fetchAll(); if (!$is_cacheable_by_dynamic_page_cache) { $this->assertCount(0, $cache_items); } else { $this->assertCount(2, $cache_items); $found_cache_redirect = FALSE; $this->assertLessThanOrEqual(2, count($cache_items)); $found_cached_200_response = FALSE; $other_cached_responses_are_4xx = TRUE; foreach ($cache_items as $cid => $cache_item) { foreach ($cache_items as $cache_item) { $cached_data = unserialize($cache_item->data); if (!isset($cached_data['#cache_redirect'])) { $cached_response = $cached_data['#response']; Loading @@ -544,11 +543,7 @@ public function testGet() { $this->assertNotInstanceOf(ResourceResponseInterface::class, $cached_response); $this->assertInstanceOf(CacheableResponseInterface::class, $cached_response); } else { $found_cache_redirect = TRUE; } } $this->assertTrue($found_cache_redirect); $this->assertTrue($found_cached_200_response); $this->assertTrue($other_cached_responses_are_4xx); } Loading