function CasRequiredLoginTestCase::testCasPages in CAS 7
Same name and namespace in other branches
- 6.3 cas.test \CasRequiredLoginTestCase::testCasPages()
Test redirection forced by cas_access and cas_pages variables.
File
- ./
cas.test, line 755 - Tests for cas.module.
Class
- CasRequiredLoginTestCase
- Test case for CAS force login feature.
Code
function testCasPages() {
$node1 = $this
->drupalCreateNode();
$node2 = $this
->drupalCreateNode();
$account = $this
->casCreateUser();
$this
->setCasUser($account);
$this
->drupalGet("node/{$node2->nid}");
// Enable required login for $node.
variable_set('cas_access', 0);
variable_set('cas_pages', "node/{$node1->nid}\nnode/{$node2->nid}");
// Visit the node and verify we are logged in.
$this
->drupalGet("node/{$node2->nid}");
$this
->assertLoggedIn($account);
$this
->assertUrl("node/{$node2->nid}");
$this
->drupalLogout();
// Invert the access restrictions. Verify we can get the access the node
// without restriction.
variable_set('cas_access', 1);
$this
->drupalGet("node/{$node1->nid}");
$this
->assertField('name', t('Username field found.'), t('Logout'));
$this
->assertField('pass', t('Password field found.'), t('Logout'));
// Verify that accessing any other page redirects to the login page.
$this
->clearCasUser();
$this
->drupalGet('node');
$this
->assertText('No CAS name provided.');
}