function OgVocabTestCase::testOgVocabAccess in OG Vocabulary 6
Test access to vocabulary.
- User not a member of a group.
- User member of group but no permissions
- User member of group with correct permissions.
- User is admin in group.
- User has 'administer organic groups' permissions.
File
- ./
og_vocab.test, line 97
Class
Code
function testOgVocabAccess() {
$web_user1 = $this
->drupalCreateUser();
$this
->drupalLogin($web_user1);
// User is not a member of a group, and should have no access.
$this
->OgVocabTestPage(t('User not a member of a group'));
// User is a member of a group, but without permissions.
$web_user2 = $this
->drupalCreateUser();
$this
->drupalLogin($web_user2);
// Assign user to group.
og_save_subscription($this->gid1, $web_user2->uid, array(
'is_active' => 1,
));
$this
->OgVocabTestPage(t('User a member of a group without permissions'));
// User is a member of a group, and has all permissions.
$web_user3 = $this
->drupalCreateUser(array(
'administer own group vocabulary',
'add own group vocabulary',
'edit own group vocabulary',
'edit own group term',
));
$this
->drupalLogin($web_user3);
// Assign user to group.
og_save_subscription($this->gid1, $web_user3->uid, array(
'is_active' => 1,
));
$responses = array(
'group taxonomy tab' => TRUE,
'add group vocabulary' => TRUE,
'edit group vocabulary' => TRUE,
'list terms of group vocabulary' => TRUE,
'add new group term' => TRUE,
'edit group term' => TRUE,
);
$this
->OgVocabTestPage(t('User member of a group with permissions'), $responses);
// User is admin in group.
$web_user4 = $this
->drupalCreateUser();
$this
->drupalLogin($web_user4);
// Assign user to group.
og_save_subscription($this->gid1, $web_user4->uid, array(
'is_active' => 1,
'is_admin' => 1,
));
// Use same responses as previous user.
$this
->OgVocabTestPage(t('User admin of a group'), $responses);
// User has 'administer organic groups' permission.
$this
->drupalLogin($this->admin_user);
// Use same responses as previous user.
$this
->OgVocabTestPage(t('User has "administer organic groups" permission'), $responses);
}