1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Tests for contextual.module.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Tests accessible links after inaccessible links on dynamic context.
|
10 |
|
|
*/
|
11 |
|
|
class ContextualDynamicContextTestCase extends DrupalWebTestCase {
|
12 |
|
|
protected $profile = 'testing';
|
13 |
|
|
|
14 |
|
|
public static function getInfo() {
|
15 |
|
|
return array(
|
16 |
|
|
'name' => 'Contextual links on node lists',
|
17 |
|
|
'description' => 'Tests if contextual links are showing on the front page depending on permissions.',
|
18 |
|
|
'group' => 'Contextual',
|
19 |
|
|
);
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
function setUp() {
|
23 |
|
|
parent::setUp(array('contextual', 'node'));
|
24 |
|
|
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
|
25 |
|
|
$this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
|
26 |
|
|
$web_user = $this->drupalCreateUser(array('access content', 'access contextual links', 'edit any article content'));
|
27 |
|
|
$this->drupalLogin($web_user);
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
/**
|
31 |
|
|
* Tests contextual links on node lists with different permissions.
|
32 |
|
|
*/
|
33 |
|
|
function testNodeLinks() {
|
34 |
|
|
// Create three nodes in the following order:
|
35 |
|
|
// - An article, which should be user-editable.
|
36 |
|
|
// - A page, which should not be user-editable.
|
37 |
|
|
// - A second article, which should also be user-editable.
|
38 |
|
|
$node1 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
|
39 |
|
|
$node2 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1));
|
40 |
|
|
$node3 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
|
41 |
|
|
|
42 |
|
|
// Now, on the front page, all article nodes should have contextual edit
|
43 |
|
|
// links. The page node in between should not.
|
44 |
|
|
$this->drupalGet('node');
|
45 |
|
|
$this->assertRaw('node/' . $node1->nid . '/edit', 'Edit link for oldest article node showing.');
|
46 |
|
|
$this->assertNoRaw('node/' . $node2->nid . '/edit', 'No edit link for page nodes.');
|
47 |
|
|
$this->assertRaw('node/' . $node3->nid . '/edit', 'Edit link for most recent article node showing.');
|
48 |
|
|
}
|
49 |
|
|
} |