Révision 7e72b748
Ajouté par Assos Assos il y a plus de 6 ans
drupal7/sites/all/modules/ctools/tests/ctools.plugins.test | ||
---|---|---|
1 | 1 |
<?php |
2 |
/** |
|
3 |
* @file |
|
4 |
* Tests for different parts of the ctools plugin system. |
|
5 |
*/ |
|
6 | 2 |
|
7 | 3 |
/** |
8 | 4 |
* Test menu links depending on user permissions. |
9 | 5 |
*/ |
10 | 6 |
class CtoolsPluginsGetInfoTestCase extends DrupalWebTestCase { |
7 |
|
|
8 |
/** |
|
9 |
* {@inheritDoc} |
|
10 |
*/ |
|
11 | 11 |
public static function getInfo() { |
12 | 12 |
return array( |
13 | 13 |
'name' => 'Get plugin info', |
14 | 14 |
'description' => 'Verify that plugin type definitions can properly set and overide values.', |
15 | 15 |
'group' => 'ctools', |
16 |
'dependencies' => array('ctools'), |
|
16 | 17 |
); |
17 | 18 |
} |
18 | 19 |
|
19 |
function setUp() { |
|
20 |
// Additionally enable contact module. |
|
21 |
parent::setUp('ctools', 'ctools_plugin_test'); |
|
20 |
/** |
|
21 |
* {@inheritDoc} |
|
22 |
*/ |
|
23 |
function setUp(array $modules = array()) { |
|
24 |
$modules[] = 'ctools'; |
|
25 |
$modules[] = 'ctools_plugin_test'; |
|
26 |
parent::setUp($modules); |
|
22 | 27 |
} |
23 | 28 |
|
29 |
/** |
|
30 |
* Assert helper to check that a specific plugin function exists. |
|
31 |
* |
|
32 |
* @param $module |
|
33 |
* The module that owns the plugin. |
|
34 |
* @param $type |
|
35 |
* The type of plugin. |
|
36 |
* @param $id |
|
37 |
* The id of the specific plugin to load. |
|
38 |
* @param $function |
|
39 |
* The identifier of the function. For example, 'settings form'. |
|
40 |
*/ |
|
24 | 41 |
protected function assertPluginFunction($module, $type, $id, $function = 'function') { |
25 | 42 |
$func = ctools_plugin_load_function($module, $type, $id, $function); |
26 | 43 |
$this->assertTrue(function_exists($func), t('Plugin @plugin of plugin type @module:@type successfully retrieved @retrieved for @function.', array( |
... | ... | |
32 | 49 |
))); |
33 | 50 |
} |
34 | 51 |
|
52 |
/** |
|
53 |
* Assert helper to check that a specific plugin function does NOT exist. |
|
54 |
* |
|
55 |
* @param $module |
|
56 |
* The module that owns the plugin. |
|
57 |
* @param $type |
|
58 |
* The type of plugin. |
|
59 |
* @param $id |
|
60 |
* The id of the specific plugin to load. |
|
61 |
* @param $function |
|
62 |
* The identifier of the function. For example, 'settings form'. |
|
63 |
*/ |
|
35 | 64 |
protected function assertPluginMissingFunction($module, $type, $id, $function = 'function') { |
36 | 65 |
$func = ctools_plugin_load_function($module, $type, $id, $function); |
37 | 66 |
$this->assertEqual($func, NULL, t('Plugin @plugin of plugin type @module:@type for @function with missing function successfully failed.', array( |
... | ... | |
42 | 71 |
))); |
43 | 72 |
} |
44 | 73 |
|
74 |
/** |
|
75 |
* Assert helper to check that a plugin can be loaded using a named class. |
|
76 |
* |
|
77 |
* @param $module |
|
78 |
* The module that owns the plugin. |
|
79 |
* @param $type |
|
80 |
* The type of plugin. |
|
81 |
* @param $id |
|
82 |
* The id of the specific plugin to load. |
|
83 |
* @param string $class |
|
84 |
* The name of the PHP class to load. |
|
85 |
*/ |
|
45 | 86 |
protected function assertPluginClass($module, $type, $id, $class = 'handler') { |
46 | 87 |
$class_name = ctools_plugin_load_class($module, $type, $id, $class); |
47 | 88 |
$this->assertTrue(class_exists($class_name), t('Plugin @plugin of plugin type @module:@type successfully retrieved @retrieved for @class.', array( |
... | ... | |
53 | 94 |
))); |
54 | 95 |
} |
55 | 96 |
|
97 |
/** |
|
98 |
* Assert helper to check that a plugin DOES NOT contain the named class. |
|
99 |
* |
|
100 |
* @param $module |
|
101 |
* The module that owns the plugin. |
|
102 |
* @param $type |
|
103 |
* The type of plugin. |
|
104 |
* @param $id |
|
105 |
* The id of the specific plugin to load. |
|
106 |
* @param string $class |
|
107 |
* The name of the PHP class to load. |
|
108 |
*/ |
|
56 | 109 |
protected function assertPluginMissingClass($module, $type, $id, $class = 'handler') { |
57 | 110 |
$class_name = ctools_plugin_load_class($module, $type, $id, $class); |
58 | 111 |
$this->assertEqual($class_name, NULL, t('Plugin @plugin of plugin type @module:@type for @class with missing class successfully failed.', array( |
... | ... | |
81 | 134 |
$this->assertPluginClass($module, $type, 'plugin_array', 'handler'); |
82 | 135 |
$this->assertPluginClass($module, $type, 'plugin_array2', 'handler'); |
83 | 136 |
$this->assertPluginMissingClass($module, $type, 'plugin_array_dne', 'handler'); |
84 |
// TODO Test big hook plugins.
|
|
137 |
// @todo Test big hook plugins.
|
|
85 | 138 |
|
86 | 139 |
$type = 'cached'; |
87 | 140 |
|
... | ... | |
95 | 148 |
$this->assertPluginClass($module, $type, 'plugin_array', 'handler'); |
96 | 149 |
$this->assertPluginClass($module, $type, 'plugin_array2', 'handler'); |
97 | 150 |
$this->assertPluginMissingClass($module, $type, 'plugin_array_dne', 'handler'); |
98 |
// TODO Test big hook plugins.
|
|
151 |
// @todo Test big hook plugins.
|
|
99 | 152 |
} |
153 |
|
|
100 | 154 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules