diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php index d9bad8d..5c7f928 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -217,4 +217,13 @@ public function __sleep() { return []; } + /** + * Reset statically cached variables. + * + * This is only used by tests. + */ + public function reset() { + $this->cache = []; + } + } diff --git a/core/modules/user/src/Tests/UserPermissionsTest.php b/core/modules/user/src/Tests/UserPermissionsTest.php index 19dd429..e5baa49 100644 --- a/core/modules/user/src/Tests/UserPermissionsTest.php +++ b/core/modules/user/src/Tests/UserPermissionsTest.php @@ -7,7 +7,6 @@ namespace Drupal\user\Tests; -use Drupal\Core\Cache\Cache; use Drupal\simpletest\WebTestBase; use Drupal\user\RoleInterface; use Drupal\user\Entity\Role; @@ -57,7 +56,6 @@ function testUserPermissionChanges() { // Create an additional role and mark it as admin role. Role::create(['is_admin' => TRUE, 'id' => 'administrator', 'label' => 'Administrator'])->save(); $storage->resetCache(); - Cache::invalidateTags(["config:user.role.$this->rid"]); $this->drupalLogin($this->adminUser); $rid = $this->rid; @@ -72,7 +70,6 @@ function testUserPermissionChanges() { $this->drupalPostForm('admin/people/permissions', $edit, t('Save permissions')); $this->assertText(t('The changes have been saved.'), 'Successful save message displayed.'); $storage->resetCache(); - Cache::invalidateTags(["config:user.role.$this->rid"]); $this->assertTrue($account->hasPermission('administer users'), 'User now has "administer users" permission.'); $current_permissions_hash = $permissions_hash_generator->generate($account); $this->assertIdentical($current_permissions_hash, $permissions_hash_generator->generate($this->loggedInUser)); @@ -86,7 +83,6 @@ function testUserPermissionChanges() { $this->drupalPostForm('admin/people/permissions', $edit, t('Save permissions')); $this->assertText(t('The changes have been saved.'), 'Successful save message displayed.'); $storage->resetCache(); - Cache::invalidateTags(["config:user.role.$this->rid"]); $this->assertFalse($account->hasPermission('access user profiles'), 'User no longer has "access user profiles" permission.'); $current_permissions_hash = $permissions_hash_generator->generate($account); $this->assertIdentical($current_permissions_hash, $permissions_hash_generator->generate($this->loggedInUser));