class NodeCacheTagsTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/node/tests/src/Functional/NodeCacheTagsTest.php \Drupal\Tests\node\Functional\NodeCacheTagsTest
- 9 core/modules/node/tests/src/Functional/NodeCacheTagsTest.php \Drupal\Tests\node\Functional\NodeCacheTagsTest
Tests the Node entity's cache tags.
@group node
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, FunctionalTestSetupTrait, TestSetupTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\system\Functional\Cache\PageCacheTagsTestBase
- class \Drupal\Tests\system\Functional\Entity\EntityCacheTagsTestBase
- class \Drupal\Tests\system\Functional\Entity\EntityWithUriCacheTagsTestBase
- class \Drupal\Tests\node\Functional\NodeCacheTagsTest
- class \Drupal\Tests\system\Functional\Entity\EntityWithUriCacheTagsTestBase
- class \Drupal\Tests\system\Functional\Entity\EntityCacheTagsTestBase
- class \Drupal\Tests\system\Functional\Cache\PageCacheTagsTestBase
Expanded class hierarchy of NodeCacheTagsTest
File
- core/
modules/ node/ tests/ src/ Functional/ NodeCacheTagsTest.php, line 15
Namespace
Drupal\Tests\node\FunctionalView source
class NodeCacheTagsTest extends EntityWithUriCacheTagsTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function createEntity() {
// Create a "Camelids" node type.
NodeType::create([
'name' => 'Camelids',
'type' => 'camelids',
])
->save();
// Create a "Llama" node.
$node = Node::create([
'type' => 'camelids',
]);
$node
->setTitle('Llama')
->setPublished()
->save();
return $node;
}
/**
* {@inheritdoc}
*/
protected function getAdditionalCacheContextsForEntity(EntityInterface $entity) {
return [
'timezone',
];
}
/**
* {@inheritdoc}
*
* Each node must have an author.
*/
protected function getAdditionalCacheTagsForEntity(EntityInterface $node) {
return [
'user:' . $node
->getOwnerId(),
'user_view',
];
}
/**
* {@inheritdoc}
*/
protected function getAdditionalCacheContextsForEntityListing() {
return [
'user.node_grants:view',
];
}
}