You are here

protected function EntityResourceTestBase::getExpectedCacheTags in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getExpectedCacheTags()
  2. 9 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getExpectedCacheTags()

The expected cache tags for the GET/HEAD response of the test entity.

Return value

string[]

See also

::testGet

3 calls to EntityResourceTestBase::getExpectedCacheTags()
BlockContentResourceTestBase::getExpectedCacheTags in core/modules/block_content/tests/src/Functional/Rest/BlockContentResourceTestBase.php
The expected cache tags for the GET/HEAD response of the test entity.
EntityResourceTestBase::testGet in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Tests a GET request for an entity, plus edge cases to ensure good DX.
TermResourceTestBase::getExpectedCacheTags in core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php
The expected cache tags for the GET/HEAD response of the test entity.
2 methods override EntityResourceTestBase::getExpectedCacheTags()
BlockContentResourceTestBase::getExpectedCacheTags in core/modules/block_content/tests/src/Functional/Rest/BlockContentResourceTestBase.php
The expected cache tags for the GET/HEAD response of the test entity.
TermResourceTestBase::getExpectedCacheTags in core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php
The expected cache tags for the GET/HEAD response of the test entity.

File

core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php, line 376

Class

EntityResourceTestBase
Even though there is the generic EntityResource, it's necessary for every entity type to have its own test, because they each have different fields, validation constraints, et cetera. It's not because the generic case works, that every case…

Namespace

Drupal\Tests\rest\Functional\EntityResource

Code

protected function getExpectedCacheTags() {
  $expected_cache_tags = [
    'config:rest.resource.entity.' . static::$entityTypeId,
  ];
  if (!static::$auth) {
    $expected_cache_tags[] = 'config:user.role.anonymous';
  }
  $expected_cache_tags[] = 'http_response';
  return Cache::mergeTags($expected_cache_tags, $this->entity
    ->getCacheTags());
}