.../Functional/EntityResource/EntityResourceTestBase.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php index 0eab9d7..1c1c83c 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -440,14 +440,20 @@ public function testGet() { ':pattern' => '%[route]=rest.%', ]) ->fetchAllAssoc('cid'); - $this->assertCount(2, $cache_items); + $this->assertTrue(count($cache_items) >= 2); $found_cache_redirect = FALSE; - $found_cached_response = FALSE; + $found_cached_200_response = FALSE; + $other_cached_responses_are_4xx = TRUE; foreach ($cache_items as $cid => $cache_item) { $cached_data = unserialize($cache_item->data); if (!isset($cached_data['#cache_redirect'])) { - $found_cached_response = TRUE; $cached_response = $cached_data['#response']; + if ($cached_response->getStatusCode() === 200) { + $found_cached_200_response = TRUE; + } + else if (!$cached_response->isClientError()) { + $other_cached_responses_are_4xx = FALSE; + } $this->assertNotInstanceOf(ResourceResponseInterface::class, $cached_response); $this->assertInstanceOf(CacheableResponseInterface::class, $cached_response); } @@ -456,7 +462,8 @@ public function testGet() { } } $this->assertTrue($found_cache_redirect); - $this->assertTrue($found_cached_response); + $this->assertTrue($found_cached_200_response); + $this->assertTrue($other_cached_responses_are_4xx); } else { $this->assertResourceResponse(200, FALSE, $response, $this->getExpectedCacheTags(), $this->getExpectedCacheContexts(), static::$auth ? FALSE : 'HIT', FALSE);