function CasUserAdminTestCase::testCasUserAdd in CAS 7
Same name and namespace in other branches
- 6.3 cas.test \CasUserAdminTestCase::testCasUserAdd()
Tests adding a CAS user in the administrative interface.
File
- ./
cas.test, line 335 - Tests for cas.module.
Class
Code
function testCasUserAdd() {
$this
->drupalLogin($this->admin_user);
// Add 3 CAS users.
$edit = array();
for ($i = 0; $i < 3; $i++) {
$cas_names[] = $this
->randomName();
}
$edit['cas_name'] = implode("\n", $cas_names);
$this
->drupalPost('admin/people/cas/create', $edit, t('Create new account(s)'));
$this
->assertText(t('The following 3 CAS usernames were created: @cas_names', array(
'@cas_names' => implode(', ', $cas_names),
)), 'Users created');
// Verify the users show up in the list of all users.
$this
->drupalGet('admin/people');
foreach ($cas_names as $cas_name) {
$this
->assertNoUniqueText($cas_name, 'User and CAS username found in list of users');
}
// Attempt to add one of the users again and see that it fails.
$edit['cas_name'] = $cas_names[0];
$this
->drupalPost('admin/people/cas/create', $edit, t('Create new account(s)'));
$this
->assertText(t('The CAS username is already in use on this site.'), 'CAS username already in use.');
}