function OgUiManagePeopleTestCase::testOgUiAddPeople in Organic groups 7
Same name and namespace in other branches
- 7.2 og_ui/og_ui.test \OgUiManagePeopleTestCase::testOgUiAddPeople()
Testing adding people via group/[entity_type]/[etid]/admin/people/add-user.
File
- og_ui/
og_ui.test, line 158
Class
Code
function testOgUiAddPeople() {
$admin_user = $this
->drupalCreateUser();
$this
->drupalLogin($admin_user);
// Create an entity.
$entity = entity_create('entity_test', array(
'name' => 'main',
'uid' => $admin_user->uid,
));
$entity->{OG_GROUP_FIELD}[LANGUAGE_NONE][0]['value'] = 1;
$entity
->save();
$group = og_get_group('entity_test', $entity->pid);
// Add users to the group, with different states.
foreach (og_group_content_states() as $state => $name) {
$web_user = $this
->drupalCreateUser();
$edit = array();
$edit['og_add_user'] = $web_user->name;
$edit['og_add_user_state'] = $state;
$this
->drupalPost('group/entity_test/' . $entity->pid . '/admin/people/add-user', $edit, t('Add users'));
// Reload user, just to make sure field was updated.
$web_user = user_load($web_user->uid, TRUE);
$this
->assertTrue(og_is_member($group->gid, 'user', $web_user, array(
$state,
)), t('User was added to the group with @name state.', array(
'@name' => $name,
)));
}
// Add non-existing user.
$edit = array();
$edit['og_add_user'] = $this
->randomName();
$this
->drupalPost('group/entity_test/' . $entity->pid . '/admin/people/add-user', $edit, t('Add users'));
$this
->assertText(t('You have entered an invalid user name.'), t('Invalid user name not added to group.'));
}