.../EntityResource/EntityResourceTestBase.php | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php index c25c787..843d15d 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -375,7 +375,7 @@ public function testGet() { // DX: 403 when unauthorized. $response = $this->request('GET', $url, $request_options); - $this->assertResourceErrorResponse(403, $this->getExpectedUnauthorizedAccessMessage('GET'), $response); + $this->assertResourceErrorResponse(403, $this->getExpectedUnauthorizedAccessMessage('GET'), $response, static::$auth ? ['4xx-response', 'http_response'] : ['4xx-response', 'config:user.role.anonymous', 'http_response'], ['user.permissions'], static::$auth ? FALSE : 'MISS', 'MISS'); $this->assertArrayNotHasKey('Link', $response->getHeaders()); @@ -385,7 +385,7 @@ public function testGet() { // 200 for well-formed HEAD request. $response = $this->request('HEAD', $url, $request_options); - $this->assertResourceResponse(200, '', $response); + $this->assertResourceResponse(200, '', $response, $this->getExpectedCacheTags(), $this->getExpectedCacheContexts(), static::$auth ? FALSE : 'MISS', 'MISS'); if (!$this->account) { $this->assertSame(['MISS'], $response->getHeader('X-Drupal-Cache')); } @@ -396,17 +396,7 @@ public function testGet() { // 200 for well-formed GET request. Page Cache hit because of HEAD request. $response = $this->request('GET', $url, $request_options); - $this->assertResourceResponse(200, FALSE, $response); - if (!static::$auth) { - $this->assertSame(['HIT'], $response->getHeader('X-Drupal-Cache')); - } - else { - $this->assertFalse($response->hasHeader('X-Drupal-Cache')); - } - $cache_tags_header_value = $response->getHeader('X-Drupal-Cache-Tags')[0]; - $this->assertEquals($this->getExpectedCacheTags(), empty($cache_tags_header_value) ? [] : explode(' ', $cache_tags_header_value)); - $cache_contexts_header_value = $response->getHeader('X-Drupal-Cache-Contexts')[0]; - $this->assertEquals($this->getExpectedCacheContexts(), empty($cache_contexts_header_value) ? [] : explode(' ', $cache_contexts_header_value)); + $this->assertResourceResponse(200, FALSE, $response, $this->getExpectedCacheTags(), $this->getExpectedCacheContexts(), static::$auth ? FALSE : 'HIT', static::$auth ? 'HIT' : 'MISS'); // Sort the serialization data first so we can do an identical comparison // for the keys with the array order the same (it needs to match with // identical comparison). @@ -464,7 +454,7 @@ public function testGet() { $response = $this->request('GET', $url, $request_options); - $this->assertResourceResponse(200, FALSE, $response); + $this->assertResourceResponse(200, FALSE, $response, $this->getExpectedCacheTags(), $this->getExpectedCacheContexts(), static::$auth ? FALSE : 'MISS', 'MISS'); // Again do an identical comparison, but this time transform the expected @@ -496,7 +486,7 @@ public function testGet() { // 200 for well-formed request. $response = $this->request('GET', $url, $request_options); - $this->assertResourceResponse(200, FALSE, $response); + $this->assertResourceResponse(200, FALSE, $response, $this->getExpectedCacheTags(), $this->getExpectedCacheContexts(), static::$auth ? FALSE : 'MISS', 'MISS'); $this->resourceConfigStorage->load(static::$resourceConfigId)->disable()->save(); @@ -513,7 +503,7 @@ public function testGet() { // DX: upon re-enabling a resource, immediate 200. $response = $this->request('GET', $url, $request_options); - $this->assertResourceResponse(200, FALSE, $response); + $this->assertResourceResponse(200, FALSE, $response, $this->getExpectedCacheTags(), $this->getExpectedCacheContexts(), static::$auth ? FALSE : 'MISS', 'MISS'); $this->resourceConfigStorage->load(static::$resourceConfigId)->delete();