public function CurrentSearchInterfaceTestCase::testFormAccess in Facet API 7
Same name and namespace in other branches
- 7.2 contrib/current_search/tests/current_search.test \CurrentSearchInterfaceTestCase::testFormAccess()
Tests access to callbacks.
File
- contrib/
current_search/ tests/ current_search.test, line 64 - Test cases for the Current Search Blocks module.
Class
- CurrentSearchInterfaceTestCase
- Test cases for operations taken through the admin UI.
Code
public function testFormAccess() {
$paths = array(
'admin/config/search/current_search' => t('list'),
'admin/config/search/current_search/list/standard/edit' => t('edit'),
'admin/config/search/current_search/list/standard/disable' => t('disable'),
'admin/config/search/current_search/list/standard/clone' => t('clone'),
'admin/config/search/current_search/list/standard/export' => t('export'),
'admin/config/search/current_search/item/standard/delete/results' => t('remove item'),
);
// Test wheter unprivileged user is denied access to forms.
$this
->drupalLogin($this->authenticatedUser);
foreach ($paths as $path => $form_name) {
$this
->drupalGet($path);
$this
->assertResponse(403, t('Unprivileged user does not have access to the @form-name form.', array(
'@form-name' => $form_name,
)), 'Facet API');
}
// Common message for privileged access checks.
$privileged_message = t('Privileged user with "@permission" permission is granted access to the @form-name form.');
// Test whether privileged user is granted access for forms.
// NOTE: $this->adminUser has "administer search" permission.
$this
->drupalLogin($this->adminUser);
foreach ($paths as $path => $form_name) {
$this
->drupalGet($path);
$args = array(
'@permission' => 'administer search',
'@form-name' => $form_name,
);
$this
->assertResponse(200, t($privileged_message, $args));
}
// Tests whether privileged user is granted access for forms.
// Create another user with the "administer facets" permission, test whether
$facet_admin_user = $this
->drupalCreateUser(array(
'administer facets',
));
$this
->drupalLogin($facet_admin_user);
foreach ($paths as $path => $form_name) {
$this
->drupalGet($path);
$args = array(
'@permission' => 'administer facets',
'@form-name' => $form_name,
);
$this
->assertResponse(200, t($privileged_message, $args));
}
}