danielebarchiesi@0: 'Get plugin info', danielebarchiesi@0: 'description' => 'Verify that plugin type definitions can properly set and overide values.', danielebarchiesi@0: 'group' => 'Chaos Tools Suite', danielebarchiesi@0: ); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: function setUp() { danielebarchiesi@0: // Additionally enable contact module. danielebarchiesi@0: parent::setUp('ctools', 'ctools_plugin_test'); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: protected function assertPluginFunction($module, $type, $id, $function = 'function') { danielebarchiesi@0: $func = ctools_plugin_load_function($module, $type, $id, $function); danielebarchiesi@0: $this->assertTrue(function_exists($func), t('Plugin @plugin of plugin type @module:@type successfully retrieved @retrieved for @function.', array( danielebarchiesi@0: '@plugin' => $id, danielebarchiesi@0: '@module' => $module, danielebarchiesi@0: '@type' => $type, danielebarchiesi@0: '@function' => $function, danielebarchiesi@0: '@retrieved' => $func, danielebarchiesi@0: ))); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: protected function assertPluginMissingFunction($module, $type, $id, $function = 'function') { danielebarchiesi@0: $func = ctools_plugin_load_function($module, $type, $id, $function); danielebarchiesi@0: $this->assertEqual($func, NULL, t('Plugin @plugin of plugin type @module:@type for @function with missing function successfully failed.', array( danielebarchiesi@0: '@plugin' => $id, danielebarchiesi@0: '@module' => $module, danielebarchiesi@0: '@type' => $type, danielebarchiesi@0: '@function' => $func, danielebarchiesi@0: ))); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: protected function assertPluginClass($module, $type, $id, $class = 'handler') { danielebarchiesi@0: $class_name = ctools_plugin_load_class($module, $type, $id, $class); danielebarchiesi@0: $this->assertTrue(class_exists($class_name), t('Plugin @plugin of plugin type @module:@type successfully retrieved @retrieved for @class.', array( danielebarchiesi@0: '@plugin' => $id, danielebarchiesi@0: '@module' => $module, danielebarchiesi@0: '@type' => $type, danielebarchiesi@0: '@class' => $class, danielebarchiesi@0: '@retrieved' => $class_name, danielebarchiesi@0: ))); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: protected function assertPluginMissingClass($module, $type, $id, $class = 'handler') { danielebarchiesi@0: $class_name = ctools_plugin_load_class($module, $type, $id, $class); danielebarchiesi@0: $this->assertEqual($class_name, NULL, t('Plugin @plugin of plugin type @module:@type for @class with missing class successfully failed.', array( danielebarchiesi@0: '@plugin' => $id, danielebarchiesi@0: '@module' => $module, danielebarchiesi@0: '@type' => $type, danielebarchiesi@0: '@class' => $class, danielebarchiesi@0: ))); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Test that plugins are loaded correctly. danielebarchiesi@0: */ danielebarchiesi@0: function testPluginLoading() { danielebarchiesi@0: ctools_include('plugins'); danielebarchiesi@0: $module = 'ctools_plugin_test'; danielebarchiesi@0: $type = 'not_cached'; danielebarchiesi@0: danielebarchiesi@0: // Test function retrieval for plugins using different definition methods. danielebarchiesi@0: $this->assertPluginFunction($module, $type, 'plugin_array', 'function'); danielebarchiesi@0: $this->assertPluginFunction($module, $type, 'plugin_array2', 'function'); danielebarchiesi@0: $this->assertPluginMissingFunction($module, $type, 'plugin_array_dne', 'function'); danielebarchiesi@0: $this->assertPluginFunction($module, "big_hook_$type", 'test1', 'function'); danielebarchiesi@0: danielebarchiesi@0: // Test class retrieval for plugins using different definition methods. danielebarchiesi@0: $this->assertPluginClass($module, $type, 'plugin_array', 'handler'); danielebarchiesi@0: $this->assertPluginClass($module, $type, 'plugin_array2', 'handler'); danielebarchiesi@0: $this->assertPluginMissingClass($module, $type, 'plugin_array_dne', 'handler'); danielebarchiesi@0: // TODO Test big hook plugins. danielebarchiesi@0: danielebarchiesi@0: $type = 'cached'; danielebarchiesi@0: danielebarchiesi@0: // Test function retrieval for plugins using different definition methods. danielebarchiesi@0: $this->assertPluginFunction($module, $type, 'plugin_array', 'function'); danielebarchiesi@0: $this->assertPluginFunction($module, $type, 'plugin_array2', 'function'); danielebarchiesi@0: $this->assertPluginMissingFunction($module, $type, 'plugin_array_dne', 'function'); danielebarchiesi@0: $this->assertPluginFunction($module, "big_hook_$type", 'test1', 'function'); danielebarchiesi@0: danielebarchiesi@0: // Test class retrieval for plugins using different definition methods. danielebarchiesi@0: $this->assertPluginClass($module, $type, 'plugin_array', 'handler'); danielebarchiesi@0: $this->assertPluginClass($module, $type, 'plugin_array2', 'handler'); danielebarchiesi@0: $this->assertPluginMissingClass($module, $type, 'plugin_array_dne', 'handler'); danielebarchiesi@0: // TODO Test big hook plugins. danielebarchiesi@0: } danielebarchiesi@0: }