1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Tests for the nodeaccess module.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Tests the functionality of the nodeaccess module.
|
10
|
*/
|
11
|
class NodeaccesssGrantTabTestCase extends DrupalWebTestCase {
|
12
|
|
13
|
/**
|
14
|
* Enable the nodeaccess module.
|
15
|
*/
|
16
|
public function setUp() {
|
17
|
parent::setUp('nodeaccess');
|
18
|
}
|
19
|
|
20
|
/**
|
21
|
* Provide some information about this test case.
|
22
|
*/
|
23
|
public static function getInfo() {
|
24
|
return array(
|
25
|
'name' => 'Nodeaccess Grant Tab visibility',
|
26
|
'description' => 'Tests whether the Grant tab appears correctly..',
|
27
|
'group' => 'Nodeaccess',
|
28
|
);
|
29
|
}
|
30
|
|
31
|
/**
|
32
|
* Make sure the 'Grant' tab is available from the node view when appropriate.
|
33
|
* @test
|
34
|
*/
|
35
|
public function testGrantTabVisbility() {
|
36
|
// Create a test user, and a node with nodeaccess enabled for its type.
|
37
|
$user = $this->drupalCreateUser(array('grant node permissions'));
|
38
|
$node = $this->drupalCreateNode();
|
39
|
nodeaccess_add_type_grant($node->type);
|
40
|
|
41
|
// First, before logging in, we shouldn't see a link.
|
42
|
$this->drupalGet("node/{$node->nid}");
|
43
|
$this->assertNoLinkByHref("node/{$node->nid}/grant");
|
44
|
|
45
|
// Log in and the grant tab should appear.
|
46
|
$this->drupalLogin($user);
|
47
|
$this->drupalGet("node/{$node->nid}");
|
48
|
$this->assertLinkByHref("node/{$node->nid}/grant");
|
49
|
|
50
|
// Disable nodeaccess for this content type, and the tab should be gone.
|
51
|
nodeaccess_delete_type_grant($node->type);
|
52
|
$this->drupalGet("node/{$node->nid}");
|
53
|
$this->assertNoLinkByHref("node/{$node->nid}/grant");
|
54
|
|
55
|
// Confirm that the anonymous user still doesn't see the grant tab.
|
56
|
$this->drupalLogout();
|
57
|
$this->drupalGet("node/{$node->nid}");
|
58
|
$this->assertNoLinkByHref("node/{$node->nid}/grant");
|
59
|
|
60
|
}
|
61
|
|
62
|
}
|