public function TermstatusAccessTestCase::testVisibilityOfMenuLinksForPrivilegedUser in Taxonomy Term Status 7
Test visibility of unpublished terms in menu.
File
- ./
termstatus.test, line 343 - Tests for termstatus.module
Class
- TermstatusAccessTestCase
- Tests the access control features.
Code
public function testVisibilityOfMenuLinksForPrivilegedUser() {
$published_menu_link = array(
'link_path' => 'taxonomy/term/' . $this->publishedTerm->tid,
'link_title' => $this->publishedTerm->name,
'menu_name' => 'main-menu',
);
$unpublished_menu_link = array(
'link_path' => 'taxonomy/term/' . $this->unpublishedTerm->tid,
'link_title' => $this->unpublishedTerm->name,
'menu_name' => 'main-menu',
);
menu_link_save($published_menu_link);
menu_link_save($unpublished_menu_link);
$editor = $this
->drupalCreateUser(array(
'view unpublished taxonomy terms',
));
$this
->drupalLogin($editor);
$this
->drupalGet('node');
$this
->assertLinkByHref('taxonomy/term/' . $this->publishedTerm->tid, 0, 'Menu link for published term is visible');
$this
->assertLinkByHref('taxonomy/term/' . $this->unpublishedTerm->tid, 0, 'Menu link for unpublished term is visible');
$admin = $this
->drupalCreateUser(array(
'administer taxonomy',
));
$this
->drupalLogin($admin);
$this
->drupalGet('node');
$this
->assertLinkByHref('taxonomy/term/' . $this->publishedTerm->tid, 0, 'Menu link for published term is visible');
$this
->assertLinkByHref('taxonomy/term/' . $this->unpublishedTerm->tid, 0, 'Menu link for unpublished term is visible');
}