public function FlushTest::testSectionFlush in Workbench Access 8
Tests sections are flushed when a scheme is deleted.
File
- tests/
src/ Kernel/ FlushTest.php, line 74
Class
- FlushTest
- Defines a class for testing that deleting schemes flushes privileges.
Namespace
Drupal\Tests\workbench_access\KernelCode
public function testSectionFlush() {
$userStorage = $this->container
->get('workbench_access.user_section_storage');
$roleStorage = $this->container
->get('workbench_access.role_section_storage');
$role = $this
->createRole([
'access content',
'create page content',
'edit any page content',
'delete any page content',
]);
$section = Term::create([
'vid' => $this->vocabulary
->id(),
'name' => 'Some section',
]);
$section
->save();
$user = $this
->createUser();
$user
->addRole($role);
$user
->save();
$roleStorage
->addRole($this->scheme, $role, [
$section
->id(),
]);
$this
->assertEquals([
$section
->id(),
], $roleStorage
->getRoleSections($this->scheme, $user));
$userStorage
->addUser($this->scheme, $user, [
$section
->id(),
]);
$this
->assertEquals([
$section
->id(),
], $userStorage
->getUserSections($this->scheme, $user, FALSE));
$this->scheme
->delete();
$this
->assertEmpty($userStorage
->getUserSections($this->scheme, $user, FALSE));
$this
->assertEmpty($roleStorage
->getRoleSections($this->scheme, $user));
}