function OgUiManagePeopleTestCase::testOgUiAddPeople in Organic groups 7.2
Same name and namespace in other branches
- 7 og_ui/og_ui.test \OgUiManagePeopleTestCase::testOgUiAddPeople()
Test adding people via group/[entity_type]/[etid]/admin/people/add-user.
File
- og_ui/
og_ui.test, line 254
Class
Code
function testOgUiAddPeople() {
$this
->drupalLogin($this->user1);
// Add user2 to the group.
$this
->assertFalse(og_is_member('entity_test', $this->entity->pid, 'user', $this->user2), 'User is not a group member');
$edit = array();
$edit['name'] = $this->user2->name;
$this
->drupalPost('group/entity_test/' . $this->entity->pid . '/admin/people/add-user', $edit, t('Add users'));
// Reload user.
og_invalidate_cache();
$this
->assertTrue(og_is_member('entity_test', $this->entity->pid, 'user', $this->user2), 'User was added to the group.');
// Add the same user twice.
$this
->drupalPost('group/entity_test/' . $this->entity->pid . '/admin/people/add-user', $edit, t('Add users'));
$this
->assertText(t('User @name is already subscribed to group.', array(
'@name' => format_username($this->user2),
)), 'User can not be added twice.');
// Add non-existing user.
$edit = array();
$edit['name'] = $this
->randomName();
$this
->drupalPost('group/entity_test/' . $this->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.'));
}