.../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 41d9eec..ca7424d 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -430,14 +430,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; + } + elseif (!$cached_response->isClientError()) { + $other_cached_responses_are_4xx = FALSE; + } $this->assertNotInstanceOf(ResourceResponseInterface::class, $cached_response); $this->assertInstanceOf(CacheableResponseInterface::class, $cached_response); } @@ -446,7 +452,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 {