You are here

public function TermstatusAccessTestCase::testAPIFunctionForUnpublishedTerms in Taxonomy Term Status 7

Test that api function for unpublished terms.

File

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

Class

TermstatusAccessTestCase
Tests the access control features.

Code

public function testAPIFunctionForUnpublishedTerms() {
  $guest = drupal_anonymous_user();
  $result = termstatus_term_access($this->publishedTerm, $guest);
  $this
    ->assertTrue($result, 'Anonymous is granted access to published term');
  $result = termstatus_term_access($this->unpublishedTerm, $guest);
  $this
    ->assertFalse($result, 'Anonymous is denied access to unpublished term');
  $editor = $this
    ->drupalCreateUser(array(
    'view unpublished taxonomy terms',
  ));
  $result = termstatus_term_access($this->publishedTerm, $editor);
  $this
    ->assertTrue($result, 'Privileged user is granted access to published term');
  $result = termstatus_term_access($this->unpublishedTerm, $editor);
  $this
    ->assertTrue($result, 'Privileged user is granted access to unpublished term');
  $admin = $this
    ->drupalCreateUser(array(
    'administer taxonomy',
  ));
  $result = termstatus_term_access($this->publishedTerm, $admin);
  $this
    ->assertTrue($result, 'Admin is granted access to published term');
  $result = termstatus_term_access($this->unpublishedTerm, $admin);
  $this
    ->assertTrue($result, 'Admin is granted access to unpublished term');
}