private function BookAccessTestCase::caseAuthorVsAdminDefaults in Book access 7.2
1 call to BookAccessTestCase::caseAuthorVsAdminDefaults()
File
- ./
book_access_test_case.test, line 243
Class
Code
private function caseAuthorVsAdminDefaults() {
$adminGrantsToCheck = drupal_map_assoc(BookAccess::grantIDs());
$authorGrantsToCheck = drupal_map_assoc(BookAccess::grantIDs());
$authorGrantsToCheck['grant_admin_access'] = FALSE;
$user = $this
->drupalCreateUser(array(
'access content',
));
$userBooks = array();
$userNodes = array();
$this
->createBook($userBooks, $userNodes, $user);
foreach ($authorGrantsToCheck as $grant => $value) {
$this
->assertEqual($value, BookAccess::checkGrant($userBooks[0]->nid, $grant, $user), t('Author (no admin role) should have @grant set to @value', array(
'@grant' => $grant,
'@value' => $value ? "TRUE" : "FALSE",
)));
}
$adminRole = user_role_load_by_name('administrator');
if ($adminRole === FALSE) {
$this
->fail(t('Couldn\'t load role \'administrator\''));
}
user_multiple_role_edit(array(
$user->uid,
), 'add_role', $adminRole->rid);
$user = user_load($user->uid);
foreach ($adminGrantsToCheck as $grant => $value) {
$this
->assertEqual($value, BookAccess::checkGrant($userBooks[0]->nid, $grant, $user), t('Author (with admin role) should have @grant set to @value', array(
'@grant' => $grant,
'@value' => $value ? "TRUE" : "FALSE",
)));
}
}