You are here

public function TermstatusQueryTagTestCase::testPrivilegedAccessToTermEFQ in Taxonomy Term Status 7

File

./termstatus.test, line 458
Tests for termstatus.module

Class

TermstatusQueryTagTestCase
Tests for various entity field queries.

Code

public function testPrivilegedAccessToTermEFQ() {
  global $user;
  $editor = $this
    ->drupalCreateUser(array(
    'view unpublished taxonomy terms',
  ));
  $this
    ->drupalLogin($editor);
  $user = $editor;

  # Without term_access tag.
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'taxonomy_term');
  $result = $query
    ->execute();
  $expected_tids = array(
    $this->publishedTerm->tid,
    $this->unpublishedTerm->tid,
  );
  sort($expected_tids);
  $actual_tids = array_keys($result['taxonomy_term']);
  sort($actual_tids);
  $this
    ->assertEqual($expected_tids, $actual_tids, 'All taxonomy terms were retrieved by EntityFieldQuery without term_access tag for privileged user.');

  # With term_access tag.
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'taxonomy_term');
  $query
    ->addTag('term_access');
  $result = $query
    ->execute();
  $expected_tids = array(
    $this->publishedTerm->tid,
    $this->unpublishedTerm->tid,
  );
  sort($expected_tids);
  $actual_tids = array_keys($result['taxonomy_term']);
  sort($actual_tids);
  $this
    ->assertEqual($expected_tids, $actual_tids, 'All taxonomy terms were retrieved by EntityFieldQuery with term_access tag for privileged user.');
}