4 * Tests for different parts of the ctools plugin system.
8 * Test menu links depending on user permissions.
10 class CtoolsPluginsGetInfoTestCase extends DrupalWebTestCase {
11 public static function getInfo() {
13 'name' => 'Get plugin info',
14 'description' => 'Verify that plugin type definitions can properly set and overide values.',
15 'group' => 'Chaos Tools Suite',
20 // Additionally enable contact module.
21 parent::setUp('ctools', 'ctools_plugin_test');
24 protected function assertPluginFunction($module, $type, $id, $function = 'function') {
25 $func = ctools_plugin_load_function($module, $type, $id, $function);
26 $this->assertTrue(function_exists($func), t('Plugin @plugin of plugin type @module:@type successfully retrieved @retrieved for @function.', array(
30 '@function' => $function,
31 '@retrieved' => $func,
35 protected function assertPluginMissingFunction($module, $type, $id, $function = 'function') {
36 $func = ctools_plugin_load_function($module, $type, $id, $function);
37 $this->assertEqual($func, NULL, t('Plugin @plugin of plugin type @module:@type for @function with missing function successfully failed.', array(
45 protected function assertPluginClass($module, $type, $id, $class = 'handler') {
46 $class_name = ctools_plugin_load_class($module, $type, $id, $class);
47 $this->assertTrue(class_exists($class_name), t('Plugin @plugin of plugin type @module:@type successfully retrieved @retrieved for @class.', array(
52 '@retrieved' => $class_name,
56 protected function assertPluginMissingClass($module, $type, $id, $class = 'handler') {
57 $class_name = ctools_plugin_load_class($module, $type, $id, $class);
58 $this->assertEqual($class_name, NULL, t('Plugin @plugin of plugin type @module:@type for @class with missing class successfully failed.', array(
67 * Test that plugins are loaded correctly.
69 function testPluginLoading() {
70 ctools_include('plugins');
71 $module = 'ctools_plugin_test';
74 // Test function retrieval for plugins using different definition methods.
75 $this->assertPluginFunction($module, $type, 'plugin_array', 'function');
76 $this->assertPluginFunction($module, $type, 'plugin_array2', 'function');
77 $this->assertPluginMissingFunction($module, $type, 'plugin_array_dne', 'function');
78 $this->assertPluginFunction($module, "big_hook_$type", 'test1', 'function');
80 // Test class retrieval for plugins using different definition methods.
81 $this->assertPluginClass($module, $type, 'plugin_array', 'handler');
82 $this->assertPluginClass($module, $type, 'plugin_array2', 'handler');
83 $this->assertPluginMissingClass($module, $type, 'plugin_array_dne', 'handler');
84 // TODO Test big hook plugins.
88 // Test function retrieval for plugins using different definition methods.
89 $this->assertPluginFunction($module, $type, 'plugin_array', 'function');
90 $this->assertPluginFunction($module, $type, 'plugin_array2', 'function');
91 $this->assertPluginMissingFunction($module, $type, 'plugin_array_dne', 'function');
92 $this->assertPluginFunction($module, "big_hook_$type", 'test1', 'function');
94 // Test class retrieval for plugins using different definition methods.
95 $this->assertPluginClass($module, $type, 'plugin_array', 'handler');
96 $this->assertPluginClass($module, $type, 'plugin_array2', 'handler');
97 $this->assertPluginMissingClass($module, $type, 'plugin_array_dne', 'handler');
98 // TODO Test big hook plugins.