private function PatternsUserTestCase::testPermissionCreate in Patterns 7
File
- tests/
user/ user.test, line 41 - SimpleTests for the User component of Patterns. TODO: permissions.
Class
- PatternsUserTestCase
- @file SimpleTests for the User component of Patterns. TODO: permissions.
Code
private function testPermissionCreate() {
$added_perms = array(
'administer nodes',
'access comments',
'administer comments',
);
$rid = db_select('role', 'r')
->fields('r', array(
'rid',
))
->condition('name', 'test_role')
->execute()
->fetchField();
$this
->assertIdentical($rid, '5', t('The role id should be 5 here.'));
$role_permissions = user_role_permissions(array(
$rid => 'a',
));
$role_permissions = $role_permissions[$rid];
//$this->verbose(print_r($role_permissions, true));
$permission_count = count($role_permissions);
$this
->assertIdentical($permission_count, 0, t('The permission count to role %rid should be zero at this point.', array(
'%rid' => $rid,
)));
parent::runFile('user_permission_create.yaml', 'Permissions (create)', $this->user_tests_dir);
$role_permissions = user_role_permissions(array(
$rid => 'a',
));
$this
->verbose(print_r($role_permissions, true));
$role_permissions = $role_permissions[$rid];
$role_permissions = array_keys($role_permissions);
$equals = $this
->arrayEquals($added_perms, $role_permissions);
// TODO: the arrays should be equal, not false
$this
->assertIdentical($equals, false, t('The role should contain the added permissions here.'));
}