Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / user / tests / src / Functional / UserCacheTagsTest.php
1 <?php
2
3 namespace Drupal\Tests\user\Functional;
4
5 use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
6 use Drupal\user\Entity\Role;
7 use Drupal\user\Entity\User;
8 use Drupal\user\RoleInterface;
9
10 /**
11  * Tests the User entity's cache tags.
12  *
13  * @group user
14  */
15 class UserCacheTagsTest extends EntityWithUriCacheTagsTestBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   public static $modules = ['user'];
21
22   /**
23    * {@inheritdoc}
24    */
25   protected function setUp() {
26     parent::setUp();
27
28     // Give anonymous users permission to view user profiles, so that we can
29     // verify the cache tags of cached versions of user profile pages.
30     $user_role = Role::load(RoleInterface::ANONYMOUS_ID);
31     $user_role->grantPermission('access user profiles');
32     $user_role->save();
33   }
34
35   /**
36    * {@inheritdoc}
37    */
38   protected function createEntity() {
39     // Create a "Llama" user.
40     $user = User::create([
41       'name' => 'Llama',
42       'status' => TRUE,
43     ]);
44     $user->save();
45
46     return $user;
47   }
48
49   /**
50    * {@inheritdoc}
51    */
52   protected function getAdditionalCacheTagsForEntityListing() {
53     return ['user:0', 'user:1'];
54   }
55
56 }