public function AutologoutTestCase::testAutologoutSettingsForm in Automated Logout 6.4
Same name and namespace in other branches
- 7.4 tests/autologout.test \AutologoutTestCase::testAutologoutSettingsForm()
Test the behaviour of the settings for submission.
File
- tests/
autologout.test, line 142 - Simpletest tests for autologout.
Class
- AutologoutTestCase
- Tests the autologout's features.
Code
public function testAutologoutSettingsForm() {
$edit = array();
// Set an initial (low) value of max_timeout.
variable_set('autologout_max_timeout', 1000);
// Test that it is possible to set a value above the max_timeout threshold.
$edit['autologout_timeout'] = 1500;
$edit['autologout_max_timeout'] = 2000;
$edit['autologout_padding'] = 60;
$edit['autologout_role_logout'] = TRUE;
$edit['autologout_role_2'] = TRUE;
$edit['autologout_role_2_timeout'] = 1200;
$edit['autologout_role_3'] = TRUE;
$edit['autologout_role_3_timeout'] = 1200;
$edit['autologout_redirect_url'] = TRUE;
$this
->drupalPost('admin/settings/autologout', $edit, t('Save configuration'));
$this
->assertText(t('The configuration options have been saved.'), t('Unable to save autologout config when modifying the max timeout.'));
// Test that out of range values are picked up.
$edit['autologout_timeout'] = 2500;
$edit['autologout_max_timeout'] = 2000;
$edit['autologout_padding'] = 60;
$edit['autologout_role_logout'] = TRUE;
$edit['autologout_role_2'] = TRUE;
$edit['autologout_role_2_timeout'] = 1200;
$edit['autologout_role_3'] = TRUE;
$edit['autologout_role_3_timeout'] = 1200;
$edit['autologout_redirect_url'] = TRUE;
$this
->drupalPost('admin/settings/autologout', $edit, t('Save configuration'));
$this
->assertNoText(t('The configuration options have been saved.'), t('Saved configuration despite the autologout_timeout being too large.'));
// Test that out of range values are picked up.
$edit['autologout_timeout'] = 1500;
$edit['autologout_max_timeout'] = 2000;
$edit['autologout_padding'] = 60;
$edit['autologout_role_logout'] = TRUE;
$edit['autologout_role_2'] = TRUE;
$edit['autologout_role_2_timeout'] = 2500;
$edit['autologout_role_3'] = TRUE;
$edit['autologout_role_3_timeout'] = 1200;
$edit['autologout_redirect_url'] = TRUE;
$this
->drupalPost('admin/settings/autologout', $edit, t('Save configuration'));
$this
->assertNoText(t('The configuration options have been saved.'), t('Saved configuration despite a role timeout being too large.'));
// Test that role timeouts are not validated for disabled roles.
$edit['autologout_timeout'] = 1500;
$edit['autologout_max_timeout'] = 2000;
$edit['autologout_padding'] = 60;
$edit['autologout_role_logout'] = TRUE;
$edit['autologout_role_2'] = FALSE;
$edit['autologout_role_2_timeout'] = 4000;
$edit['autologout_role_3'] = TRUE;
$edit['autologout_role_3_timeout'] = 1200;
$edit['autologout_redirect_url'] = TRUE;
$this
->drupalPost('admin/settings/autologout', $edit, t('Save configuration'));
$this
->assertText(t('The configuration options have been saved.'), t('Unable to save autologout due to out of range role timeout for a role which is not enabled.'));
}