public function ContentAccessTestHelperTrait::changeAccessContentTypeKeyword in Content Access 8
Access keyword for content type.
Change access permissions for a content type by a given keyword for the role of the user.
4 calls to ContentAccessTestHelperTrait::changeAccessContentTypeKeyword()
- 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::testOwnViewAccess in tests/
src/ Functional/ ContentAccessModuleTest.php - Test own view access.
- ContentAccessModuleTest::testViewAccess in tests/
src/ Functional/ ContentAccessModuleTest.php - Test for viewing nodes.
File
- tests/
src/ Functional/ ContentAccessTestHelperTrait.php, line 41
Class
- ContentAccessTestHelperTrait
- Helper class with auxiliary functions for content access module tests.
Namespace
Drupal\Tests\content_access\FunctionalCode
public function changeAccessContentTypeKeyword($keyword, $access = TRUE, AccountInterface $user = NULL) {
$roles = [];
if ($user === NULL) {
$role = Role::load($this->rid);
$roles[$role
->id()] = $role
->id();
}
else {
$userRoles = $user
->getRoles();
foreach ($userRoles as $role) {
$roles[$role] = $role;
break;
}
}
$accessSettings = [
$keyword . '[' . key($roles) . ']' => $access,
];
$this
->changeAccessContentType($accessSettings);
}