function CasUserTestCase::testUserEdit in CAS 7
Same name and namespace in other branches
- 6.3 cas.test \CasUserTestCase::testUserEdit()
File
- ./
cas.test, line 408 - Tests for cas.module.
Class
- CasUserTestCase
- Test case to test user editing behavior.
Code
function testUserEdit() {
$cas_name = $this
->randomName();
$account = $this
->casCreateUser($cas_name, array(
'change own username',
));
$this
->casLogin($cas_name);
// Standard user page.
variable_set('cas_hide_email', FALSE);
variable_set('cas_hide_password', FALSE);
$this
->drupalGet("user/{$account->uid}/edit");
$this
->assertField('mail', 'E-mail field is present.');
$this
->assertField('current_pass', 'Current password field is present.');
$this
->assertField('pass[pass1]', 'Existing password field 1 is present.');
$this
->assertField('pass[pass2]', 'Existing password field 2 is present.');
$edit = array(
'mail' => $mail = $this
->randomName() . '@example.com',
'current_pass' => $account->pass_raw,
);
$this
->drupalPost("user/{$account->uid}/edit", $edit, t('Save'));
$this
->assertFieldByName('mail', $mail);
// Hide the password, ensure edits can be made without providing
// the current password.
variable_set('cas_hide_password', TRUE);
$this
->drupalGet("user/{$account->uid}/edit");
$this
->assertNoField('current_pass', 'Current password field is not present.');
$this
->assertNoField('pass[pass1]', 'Existing password field 1 is not present.');
$this
->assertNoField('pass[pass2]', 'Existing password field 2 is not present.');
$edit = array(
'mail' => $mail = $this
->randomName() . '@example.com',
);
$this
->drupalPost("user/{$account->uid}/edit", $edit, t('Save'));
$this
->assertFieldByName('mail', $mail);
// Hide the e-mail field as well, ensure that it is not visible.
variable_set('cas_hide_email', TRUE);
$this
->drupalGet("user/{$account->uid}/edit");
$this
->assertNoField('mail', 'E-mail field is not present.');
}