public function AutologoutAjaxTestCase::testAutologoutByAjax in Automated Logout 6.4
Same name and namespace in other branches
- 7.4 tests/autologout.test \AutologoutAjaxTestCase::testAutologoutByAjax()
Test ajax logout callbacks work as expected.
File
- tests/
autologout.test, line 357 - Simpletest tests for autologout.
Class
- AutologoutAjaxTestCase
- Test the Autologout ajax endpoints.
Code
public function testAutologoutByAjax() {
variable_set('autologout_timeout', 100);
variable_set('autologout_padding', 10);
// Check that the user can access the page after login.
$this
->drupalGet('node');
$this
->assertResponse(200, t('Homepage is accessible'));
$this
->assertText(t('Log out'), t('User is still logged in.'));
// Test the time remaining callback works as expected.
$this
->drupalGet('autologout_ajax_get_time_left');
$this
->assertResponse(200, t('autologout_ajax_get_time_left is accessible when logged in'));
// Test that ajax logout works as expected.
$this
->drupalGet('autologout_ahah_logout');
$this
->assertResponse(200, t('autologout_ahah_logout is accessible when logged in'));
// Check we are now logged out.
$this
->drupalGet('node');
$this
->assertResponse(200, t('Homepage is accessible'));
$this
->assertNoText(t('Log out'), t('User is no longer logged in.'));
// Check further get time remaining requests return access denied.
$this
->drupalGet('autologout_ajax_get_time_left');
$this
->assertResponse(403, t('autologout_ajax_get_time_left is not accessible when logged out.'));
// Check further logout requests result in access denied.
$this
->drupalGet('autologout_ahah_logout');
$this
->assertResponse(403, t('autologout_ahah logout is not accessible when logged out.'));
}