1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
<?php
// $Id$
/**
* @file
* Dummy module implementing hook menu.
*/
/**
* Implement hook_menu().
*/
function menu_test_menu() {
// The name of the menu changes during the course of the test. Using a $_GET.
$items['menu_name_test'] = array(
'title' => 'Test menu_name router item',
'page callback' => 'node_save',
'menu_name' => menu_test_menu_name(),
);
// Use FALSE as 'title callback' to bypass t().
$items['menu_no_title_callback'] = array(
'title' => 'A title with @placeholder',
'title callback' => FALSE,
'title arguments' => array('@placeholder' => 'some other text'),
'page callback' => 'menu_test_callback',
'access arguments' => array('access content'),
);
// Hidden link for menu_link_maintain tests
$items['menu_test_maintain/%'] = array(
'title' => 'Menu maintain test',
'page callback' => 'node_page_default',
'access arguments' => array('access content'),
);
// Hierarchical tests.
$items['menu-test/hierarchy/parent'] = array(
'title' => 'Parent menu router',
'page callback' => 'node_page_default',
);
$items['menu-test/hierarchy/parent/child'] = array(
'title' => 'Child menu router',
'page callback' => 'node_page_default',
);
$items['menu-test/hierarchy/parent/child2/child'] = array(
'title' => 'Unattached subchild router',
'page callback' => 'node_page_default',
);
return $items;
}
/**
* Dummy callback for hook_menu() to point to.
*
* @return
* A random string.
*/
function menu_test_callback() {
return $this->randomName();
}
/**
* Helper function for the testMenuName() test. Used to change the menu_name
* parameter of a menu.
*
* @param $new_name
* If set, will change the menu_name value.
* @return
* The menu_name value to use.
*/
function menu_test_menu_name($new_name = '') {
static $name = 'original';
if ($new_name) {
$name = $new_name;
}
return $name;
}
/**
* Implement hook_menu_link_insert().
*
* @return
* A random string.
*/
function menu_test_menu_link_insert($item) {
menu_test_static_variable('insert');
}
/**
* Implement hook_menu_link_update().
*
* @return
* A random string.
*/
function menu_test_menu_link_update($item) {
menu_test_static_variable('update');
}
/**
* Implement hook_menu_link_delete().
*
* @return
* A random string.
*/
function menu_test_menu_link_delete($item) {
menu_test_static_variable('delete');
}
/**
* Static function for testing hook results.
*
* @param $value
* The value to set or NULL to return the current value.
* @return
* A text string for comparison to test assertions.
*/
function menu_test_static_variable($value = NULL) {
static $variable;
if (!empty($value)) {
$variable = $value;
}
return $variable;
}
|