NodeCacheTagsTest.php in Drupal 10
File
core/modules/node/tests/src/Functional/NodeCacheTagsTest.php
View source
<?php
namespace Drupal\Tests\node\Functional;
use Drupal\Core\Entity\EntityInterface;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\system\Functional\Entity\EntityWithUriCacheTagsTestBase;
class NodeCacheTagsTest extends EntityWithUriCacheTagsTestBase {
protected static $modules = [
'node',
];
protected $defaultTheme = 'stark';
protected function createEntity() {
NodeType::create([
'name' => 'Camelids',
'type' => 'camelids',
])
->save();
$node = Node::create([
'type' => 'camelids',
]);
$node
->setTitle('Llama')
->setPublished()
->save();
return $node;
}
protected function getAdditionalCacheContextsForEntity(EntityInterface $entity) {
return [
'timezone',
];
}
protected function getAdditionalCacheTagsForEntity(EntityInterface $node) {
return [
'user:' . $node
->getOwnerId(),
'user_view',
];
}
protected function getAdditionalCacheContextsForEntityListing() {
return [
'user.node_grants:view',
];
}
}