public function TermstatusAccessTestCase::testPrivilegedAccessToUnpublishedTerms in Taxonomy Term Status 7
Test that access to unpublished terms is only granted to privileged users.
File
- ./
termstatus.test, line 291 - Tests for termstatus.module
Class
- TermstatusAccessTestCase
- Tests the access control features.
Code
public function testPrivilegedAccessToUnpublishedTerms() {
$editor = $this
->drupalCreateUser(array(
'view unpublished taxonomy terms',
));
$this
->drupalLogin($editor);
$this
->drupalGet('taxonomy/term/' . $this->publishedTerm->tid);
$this
->assertResponse(200, 'Privileged user can access published term');
$this
->drupalGet('taxonomy/term/' . $this->unpublishedTerm->tid);
$this
->assertResponse(200, 'Privileged user can access unpublished term');
$this
->drupalGet('termstatus-test-term-list/' . $this->vocabulary->vid);
$this
->assertLinkByHref('taxonomy/term/' . $this->publishedTerm->tid, 0, 'Published term is in term listing for privileged user');
$this
->assertLinkByHref('taxonomy/term/' . $this->unpublishedTerm->tid, 0, 'Unpublished term is in term listing for privileged user');
$admin = $this
->drupalCreateUser(array(
'administer taxonomy',
));
$this
->drupalLogin($admin);
$this
->drupalGet('taxonomy/term/' . $this->publishedTerm->tid);
$this
->assertResponse(200, 'Admin can access published term');
$this
->drupalGet('taxonomy/term/' . $this->unpublishedTerm->tid);
$this
->assertResponse(200, 'Admin can access unpublished term');
$this
->drupalGet('termstatus-test-term-list/' . $this->vocabulary->vid);
$this
->assertLinkByHref('taxonomy/term/' . $this->publishedTerm->tid, 0, 'Published term is in term listing for admin');
$this
->assertLinkByHref('taxonomy/term/' . $this->unpublishedTerm->tid, 0, 'Unpublished term is in term listing for admin');
}