public function NodeaccesssGrantTabTestCase::testGrantTabVisbility in Nodeaccess 7
Make sure the 'Grant' tab is available from the node view when appropriate. @test
File
- tests/
nodeaccess_grant.test, line 35 - Tests for the nodeaccess module.
Class
- NodeaccesssGrantTabTestCase
- Tests the functionality of the nodeaccess module.
Code
public function testGrantTabVisbility() {
// Create a test user, and a node with nodeaccess enabled for its type.
$user = $this
->drupalCreateUser(array(
'grant node permissions',
));
$node = $this
->drupalCreateNode();
nodeaccess_add_type_grant($node->type);
// First, before logging in, we shouldn't see a link.
$this
->drupalGet("node/{$node->nid}");
$this
->assertNoLinkByHref("node/{$node->nid}/grant");
// Log in and the grant tab should appear.
$this
->drupalLogin($user);
$this
->drupalGet("node/{$node->nid}");
$this
->assertLinkByHref("node/{$node->nid}/grant");
// Disable nodeaccess for this content type, and the tab should be gone.
nodeaccess_delete_type_grant($node->type);
$this
->drupalGet("node/{$node->nid}");
$this
->assertNoLinkByHref("node/{$node->nid}/grant");
// Confirm that the anonymous user still doesn't see the grant tab.
$this
->drupalLogout();
$this
->drupalGet("node/{$node->nid}");
$this
->assertNoLinkByHref("node/{$node->nid}/grant");
}