function AutoassignroleAdminAssignFromPathTestCase::testAdminSettings in Auto Assign Role 6
Same name and namespace in other branches
- 6.2 tests/autoassignrole.test \AutoassignroleAdminAssignFromPathTestCase::testAdminSettings()
File
- tests/
autoassignrole.test, line 185 - Autoassignrole functionality tests.
Class
Code
function testAdminSettings() {
// Create a new user who can access the administration settings
$this
->drupalLogin($this->admin_user);
// Check that the user can see the admin settings page.
$this
->drupalGet('admin/user/autoassignrole');
$this
->assertRaw('Automatic Role Assignment', 'The Automatic Role Assignment section exists on the AAR admin page');
// Check that each role has the correct fields in existence
foreach ($this->roles as $rid => $role) {
$this
->assertField("path_active_{$rid}", "Assign from Path: {$role} has an Enable/Disable option", $group);
$this
->assertField("path_display_{$rid}", "Assign from Path: {$role} has a Display Method option", $group);
$this
->assertField("path_weight_{$rid}", "Assign from Path: {$role} has a Weight option", $group);
$this
->assertField("path_{$rid}", "Assign from Path: {$role} has a Path option", $group);
$this
->assertField("path_title_{$rid}", "Assign from Path: {$role} has a Path Title option", $group);
$this
->assertField("path_description_{$rid}", "Assign from Path: {$role} has a Path Description option", $group);
}
$edit = $this
->getEditValues('assign_from_path');
$this
->drupalPost('admin/user/autoassignrole', $edit, t('Save'));
// verify that our changes were saved
foreach ($edit as $key => $value) {
$this
->assertEqual($value, _autoassignrole_get_settings($key), 'Assign From Path: ' . $key . ' was set properly');
}
// verify that a title is only required when a menu based choice is selected
foreach ($this->roles as $rid => $role) {
$edit["path_title_{$rid}"] = '';
$edit["path_display_{$rid}"] = 0;
}
$this
->drupalPost('admin/user/autoassignrole', $edit, t('Save'));
// verify that our changes were not saved
foreach ($edit as $key => $value) {
if (preg_match('/path_title_/', $key)) {
$this
->assertNotEqual($value, _autoassignrole_get_settings($key), 'Assign From Path: ' . $key . ' failed validation correctly when Menu Items is selected');
}
}
foreach ($this->roles as $rid => $role) {
// display 1 is Tabs on Registration Page
$edit["path_display_{$rid}"] = 1;
}
$this
->drupalPost('admin/user/autoassignrole', $edit, t('Save'));
foreach ($edit as $key => $value) {
if (preg_match('/path_title_/', $key)) {
$this
->assertNotEqual($value, _autoassignrole_get_settings($key), 'Assign From Path: ' . $key . ' failed validation correctly when Tabs on registration page is selected');
}
}
foreach ($this->roles as $rid => $role) {
// display 1 is Pages with no navigation
$edit["path_display_{$rid}"] = 2;
}
$this
->drupalPost('admin/user/autoassignrole', $edit, t('Save'));
foreach ($edit as $key => $value) {
if (preg_match('/path_title_/', $key)) {
$this
->assertEqual($value, _autoassignrole_get_settings($key), 'Assign From Path: ' . $key . ' was set with an empty title when Pages with no navigation is selected');
}
}
}