You are here

function EntityFieldQueryTestCase::testEntityFieldQueryAccess in Drupal 7

Tests EntityFieldQuery access on non-node entities.

File

modules/simpletest/tests/entity_query.test, line 1612
Unit test file for the entity API.

Class

EntityFieldQueryTestCase
Tests EntityFieldQuery.

Code

function testEntityFieldQueryAccess() {

  // Test as a user with ability to bypass node access.
  $privileged_user = $this
    ->drupalCreateUser(array(
    'bypass node access',
    'access content',
  ));
  $this
    ->drupalLogin($privileged_user);
  $this
    ->drupalGet('entity-query-access/test/' . $this->fields[0]['field_name']);
  $this
    ->assertText('Found entity', 'Returned access response with entities.');
  $this
    ->drupalLogout();

  // Test as a user that does not have ability to bypass node access or view
  // all nodes.
  $regular_user = $this
    ->drupalCreateUser(array(
    'access content',
  ));
  $this
    ->drupalLogin($regular_user);
  $this
    ->drupalGet('entity-query-access/test/' . $this->fields[0]['field_name']);
  $this
    ->assertText('Found entity', 'Returned access response with entities.');
  $this
    ->drupalLogout();
}