public function ContentAccessTestHelperTrait::changeAccessNodeKeyword in Content Access 8
Access keyword for node.
Change access permissions for a node by a given keyword (view, update or delete).
3 calls to ContentAccessTestHelperTrait::changeAccessNodeKeyword()
- ContentAccessModuleTest::testDeleteAccess in tests/
src/ Functional/ ContentAccessModuleTest.php - Test for deleting nodes.
- ContentAccessModuleTest::testEditAccess in tests/
src/ Functional/ ContentAccessModuleTest.php - Test for editing nodes.
- ContentAccessModuleTest::testViewAccess in tests/
src/ Functional/ ContentAccessModuleTest.php - Test for viewing nodes.
File
- tests/
src/ Functional/ ContentAccessTestHelperTrait.php, line 79
Class
- ContentAccessTestHelperTrait
- Helper class with auxiliary functions for content access module tests.
Namespace
Drupal\Tests\content_access\FunctionalCode
public function changeAccessNodeKeyword(NodeInterface $node, $keyword, $access = TRUE) {
$user = $this->testUser;
$userRoles = $user
->getRoles();
foreach ($userRoles as $rid) {
$role = Role::load($rid);
$roles[$role
->id()] = $role
->get('label');
}
$accessSettings = [
$keyword . '[' . key($roles) . ']' => $access,
];
$this
->changeAccessNode($node, $accessSettings);
}