function CasAttributesTestCase::testNewUserLogin in CAS Attributes 6.3
Same name and namespace in other branches
- 7 cas_attributes.test \CasAttributesTestCase::testNewUserLogin()
Test the CAS attribute tokens.
File
- ./
cas_attributes.test, line 95 - Tests for CAS Attributes.
Class
- CasAttributesTestCase
- Test case for CAS attribute setting.
Code
function testNewUserLogin() {
// Create a new CAS user.
$cas_name = $this
->randomName();
$attributes = array(
'surname' => 'Smith',
'givenName' => 'John',
'memberOf' => array(
'CN=Staff,OU=Groups,DC=example,DC=edu',
'CN=Spanish Department,OU=Departments,OU=Groups,DC=example,DC=edu',
),
);
$cas_user = array(
'name' => $cas_name,
'attributes' => $attributes,
);
variable_set('cas_test_cas_user', $cas_user);
// Set up the relationship mappings.
$this
->drupalLogin($this->admin_user);
$edit = array(
'cas_attributes[sync_every_login]' => 0,
'cas_attributes[relations][name]' => '[cas-attribute-NAME]',
'cas_attributes[relations][mail]' => '[cas-name]@example.com',
'cas_attributes[relations][1]' => '[cas-attribute-memberof]',
'cas_attributes[relations][2]' => '[cas-attribute-givenname] [cas-attribute-surname]',
);
$this
->drupalPost('admin/user/cas/attributes', $edit, t('Save configuration'));
$this
->drupalGet('user/' . $this->admin_user->uid . '/edit');
$this
->drupalGet('admin/user/cas/attributes/cas');
$this
->drupalGet('user/' . $this->admin_user->uid . '/edit');
$this
->drupalLogout();
// Log in as the new CAS user.
$this
->casLogin($cas_name, $attributes);
// After login, the account is reloaded into $this->loggedInUser.
// The account name should not have been changed, since the token should
// evaluate to nothing.
$this
->assertEqual($this->loggedInUser->name, $cas_name);
$this
->assertEqual($this->loggedInUser->mail, "{$cas_name}@example.com");
$this
->assertEqual($this->loggedInUser->test_user_memberof, 'CN=Staff,OU=Groups,DC=example,DC=edu');
$this
->assertEqual($this->loggedInUser->test_user_name, 'John Smith');
}