You are here

public function TermstatusQueryTagTestCase::testGuestAccessToTermEFQ in Taxonomy Term Status 7

File

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

Class

TermstatusQueryTagTestCase
Tests for various entity field queries.

Code

public function testGuestAccessToTermEFQ() {
  global $user;
  $web_user = $this
    ->drupalCreateUser(array(
    'access content',
  ));
  $this
    ->drupalLogin($web_user);
  $user = $web_user;

  # 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.');

  # 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,
  );
  $actual_tids = array_keys($result['taxonomy_term']);
  $this
    ->assertEqual($expected_tids, $actual_tids, 'Only published taxonomy terms were retrieved by EntityFieldQuery with term_access tag.');
}