You are here

public function AuthcacheFieldTest::testAuthcacheFieldFragmentNoEntityAccess in Authenticated User Page Caching (Authcache) 7.2

Ensure that fields are not rendered when user has no access to the entity.

Covers AuthcacheFieldFragment

File

modules/authcache_field/authcache_field.test, line 201
Test cases for the Authcache Field module.

Class

AuthcacheFieldTest
Tests for markup substitution.

Code

public function testAuthcacheFieldFragmentNoEntityAccess() {

  // Revoke access content permission for anonymous user.
  user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array(
    'access content',
  ));
  $request_id = 'asm/field/node/body';
  $params = array(
    "{$this->node1->nid}:full:en",
    "{$this->node2->nid}:full:en",
  );
  $url = authcache_p13n_request_get_callback($request_id, array(
    'field' => $params,
  ));
  $this
    ->assertTrue($url);
  $result = $this
    ->drupalGetAJAX($GLOBALS['base_root'] . $url['path'], $url['options'], array(
    'X-Authcache: 1',
  ));
  $this
    ->assertResponse(200);
  $this
    ->assertFalse($result);
}