1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Menu Token tests.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
class MenuTokenTestCase extends DrupalWebTestCase {
|
10 |
|
|
public $admin_user;
|
11 |
|
|
|
12 |
|
|
public static function getInfo() {
|
13 |
|
|
return array(
|
14 |
|
|
'name' => 'Menu Token test',
|
15 |
|
|
'description' => 'Create tokenized menu item.',
|
16 |
|
|
'group' => 'Menu Token',
|
17 |
|
|
);
|
18 |
|
|
}
|
19 |
|
|
|
20 |
|
|
/**
|
21 |
|
|
* Enable modules and create users with specific permissions.
|
22 |
|
|
*/
|
23 |
|
|
function setUp() {
|
24 |
|
|
parent::setUp('token', 'menu_token');
|
25 |
|
|
|
26 |
|
|
// Create user and login.
|
27 |
|
|
$this->admin_user = $this->drupalCreateUser(array('administer menu'));
|
28 |
|
|
$this->drupalLogin($this->admin_user);
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
/**
|
32 |
|
|
* Create menu item and check it works properly.
|
33 |
|
|
*/
|
34 |
|
|
function testCreateMenuItem() {
|
35 |
|
|
// Add new menu item.
|
36 |
|
|
$edit = array(
|
37 |
|
|
'link_title' => '[current-user:name]',
|
38 |
|
|
'link_path' => 'user/[current-user:uid]',
|
39 |
|
|
'menu_token_enabled' => TRUE,
|
40 |
|
|
);
|
41 |
|
|
$this->drupalPost('admin/structure/menu/manage/user-menu/add', $edit, t('Save'));
|
42 |
|
|
|
43 |
|
|
// Go to front page and assert menu item exists.
|
44 |
|
|
$this->drupalGet('');
|
45 |
|
|
$admin_user = $this->admin_user;
|
46 |
|
|
$this->assertLink($admin_user->name, 0, t('Tokenized menu item found by title.'), 'Menu token');
|
47 |
|
|
$this->assertLinkByHref('user/' . $admin_user->uid, 0, t('Tokenized menu item found by href.'), 'Menu token');
|
48 |
|
|
|
49 |
|
|
// Logout and assert that our menu item is not shown to anonymous user.
|
50 |
|
|
$this->drupalLogout();
|
51 |
|
|
$this->drupalGet('');
|
52 |
|
|
$this->assertNoLinkByHref('user/0', t('Tokenized link user/[uid] not shown to anonymous user.'), 'Menu token');
|
53 |
|
|
}
|
54 |
|
|
} |