You are here

function CasAttributesTokenTestCase::testAttributeTokens in CAS Attributes 7

Same name and namespace in other branches
  1. 6.3 cas_attributes.test \CasAttributesTokenTestCase::testAttributeTokens()

Test the CAS attribute tokens.

File

./cas_attributes.test, line 42
Tests for CAS Attributes.

Class

CasAttributesTokenTestCase
Test case for CAS attribute tokens.

Code

function testAttributeTokens() {
  $account = $this
    ->casCreateUser();
  $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',
    ),
  );
  $this
    ->casLogin($account, $attributes);
  $this
    ->assertToken('[cas:name]', $account->cas_name);
  $this
    ->assertToken('[cas:attribute:surname]', $attributes['surname']);
  $this
    ->assertToken('[cas:attribute:memberOf:first]', $attributes['memberOf'][0]);
  $this
    ->assertToken('[cas:attribute:memberOf:last]', $attributes['memberOf'][1]);
  $keys = array_merge(array(
    'attraStyle',
  ), array_keys($attributes));
  $keys = array_map('drupal_strtolower', $keys);
  $this
    ->assertToken('[cas:attribute:?]', t('Available attributes: %keys', array(
    '%keys' => implode(', ', $keys),
  )));
}