You are here

public function FacetapiApiFunctions::testAccessCallback in Facet API 7

Same name and namespace in other branches
  1. 7.2 tests/facetapi.test \FacetapiApiFunctions::testAccessCallback()

Tests the facetapi_access_callback() access callback.

See also

facetapi_access_callback().

File

tests/facetapi.test, line 584
Tests for the Facet API module.

Class

FacetapiApiFunctions
Test cases for low level API functions.

Code

public function testAccessCallback() {

  // The $this->adminUser has the "administer search" permission.
  $this
    ->drupalLogin($this->adminUser);
  $access = facetapi_access_callback($this->loggedInUser);
  $this
    ->assertTrue($access, t('The facetapi_access_callback() function returns TRUE for users with the "administer search" permission.'), 'Facet API');

  // Create another user with the "administer facets" permission.
  $facet_admin_user = $this
    ->drupalCreateUser(array(
    'administer facets',
  ));
  $this
    ->drupalLogin($facet_admin_user);
  $access = facetapi_access_callback($this->loggedInUser);
  $this
    ->assertTrue($access, t('The facetapi_access_callback() function returns TRUE for users with the "administer facets" permission.'), 'Facet API');

  // Users without either permission should be denied access.
  $this
    ->drupalLogin($this->authenticatedUser);
  $access = facetapi_access_callback($this->loggedInUser);
  $this
    ->assertFalse($access, t('The facetapi_access_callback() function returns FALSE for users with neither the "administer search" nor "administer facets" permissions.'), 'Facet API');
}