annotate sites/all/modules/ctools/tests/ctools.plugins.test @ 9:830c812b520f

added smtp module
author root <root@paio.local>
date Mon, 28 Oct 2013 15:34:27 +0000
parents ff03f76ab3fe
children
rev   line source
danielebarchiesi@0 1 <?php
danielebarchiesi@0 2 /**
danielebarchiesi@0 3 * @file
danielebarchiesi@0 4 * Tests for different parts of the ctools plugin system.
danielebarchiesi@0 5 */
danielebarchiesi@0 6
danielebarchiesi@0 7 /**
danielebarchiesi@0 8 * Test menu links depending on user permissions.
danielebarchiesi@0 9 */
danielebarchiesi@0 10 class CtoolsPluginsGetInfoTestCase extends DrupalWebTestCase {
danielebarchiesi@0 11 public static function getInfo() {
danielebarchiesi@0 12 return array(
danielebarchiesi@0 13 'name' => 'Get plugin info',
danielebarchiesi@0 14 'description' => 'Verify that plugin type definitions can properly set and overide values.',
danielebarchiesi@0 15 'group' => 'Chaos Tools Suite',
danielebarchiesi@0 16 );
danielebarchiesi@0 17 }
danielebarchiesi@0 18
danielebarchiesi@0 19 function setUp() {
danielebarchiesi@0 20 // Additionally enable contact module.
danielebarchiesi@0 21 parent::setUp('ctools', 'ctools_plugin_test');
danielebarchiesi@0 22 }
danielebarchiesi@0 23
danielebarchiesi@0 24 protected function assertPluginFunction($module, $type, $id, $function = 'function') {
danielebarchiesi@0 25 $func = ctools_plugin_load_function($module, $type, $id, $function);
danielebarchiesi@0 26 $this->assertTrue(function_exists($func), t('Plugin @plugin of plugin type @module:@type successfully retrieved @retrieved for @function.', array(
danielebarchiesi@0 27 '@plugin' => $id,
danielebarchiesi@0 28 '@module' => $module,
danielebarchiesi@0 29 '@type' => $type,
danielebarchiesi@0 30 '@function' => $function,
danielebarchiesi@0 31 '@retrieved' => $func,
danielebarchiesi@0 32 )));
danielebarchiesi@0 33 }
danielebarchiesi@0 34
danielebarchiesi@0 35 protected function assertPluginMissingFunction($module, $type, $id, $function = 'function') {
danielebarchiesi@0 36 $func = ctools_plugin_load_function($module, $type, $id, $function);
danielebarchiesi@0 37 $this->assertEqual($func, NULL, t('Plugin @plugin of plugin type @module:@type for @function with missing function successfully failed.', array(
danielebarchiesi@0 38 '@plugin' => $id,
danielebarchiesi@0 39 '@module' => $module,
danielebarchiesi@0 40 '@type' => $type,
danielebarchiesi@0 41 '@function' => $func,
danielebarchiesi@0 42 )));
danielebarchiesi@0 43 }
danielebarchiesi@0 44
danielebarchiesi@0 45 protected function assertPluginClass($module, $type, $id, $class = 'handler') {
danielebarchiesi@0 46 $class_name = ctools_plugin_load_class($module, $type, $id, $class);
danielebarchiesi@0 47 $this->assertTrue(class_exists($class_name), t('Plugin @plugin of plugin type @module:@type successfully retrieved @retrieved for @class.', array(
danielebarchiesi@0 48 '@plugin' => $id,
danielebarchiesi@0 49 '@module' => $module,
danielebarchiesi@0 50 '@type' => $type,
danielebarchiesi@0 51 '@class' => $class,
danielebarchiesi@0 52 '@retrieved' => $class_name,
danielebarchiesi@0 53 )));
danielebarchiesi@0 54 }
danielebarchiesi@0 55
danielebarchiesi@0 56 protected function assertPluginMissingClass($module, $type, $id, $class = 'handler') {
danielebarchiesi@0 57 $class_name = ctools_plugin_load_class($module, $type, $id, $class);
danielebarchiesi@0 58 $this->assertEqual($class_name, NULL, t('Plugin @plugin of plugin type @module:@type for @class with missing class successfully failed.', array(
danielebarchiesi@0 59 '@plugin' => $id,
danielebarchiesi@0 60 '@module' => $module,
danielebarchiesi@0 61 '@type' => $type,
danielebarchiesi@0 62 '@class' => $class,
danielebarchiesi@0 63 )));
danielebarchiesi@0 64 }
danielebarchiesi@0 65
danielebarchiesi@0 66 /**
danielebarchiesi@0 67 * Test that plugins are loaded correctly.
danielebarchiesi@0 68 */
danielebarchiesi@0 69 function testPluginLoading() {
danielebarchiesi@0 70 ctools_include('plugins');
danielebarchiesi@0 71 $module = 'ctools_plugin_test';
danielebarchiesi@0 72 $type = 'not_cached';
danielebarchiesi@0 73
danielebarchiesi@0 74 // Test function retrieval for plugins using different definition methods.
danielebarchiesi@0 75 $this->assertPluginFunction($module, $type, 'plugin_array', 'function');
danielebarchiesi@0 76 $this->assertPluginFunction($module, $type, 'plugin_array2', 'function');
danielebarchiesi@0 77 $this->assertPluginMissingFunction($module, $type, 'plugin_array_dne', 'function');
danielebarchiesi@0 78 $this->assertPluginFunction($module, "big_hook_$type", 'test1', 'function');
danielebarchiesi@0 79
danielebarchiesi@0 80 // Test class retrieval for plugins using different definition methods.
danielebarchiesi@0 81 $this->assertPluginClass($module, $type, 'plugin_array', 'handler');
danielebarchiesi@0 82 $this->assertPluginClass($module, $type, 'plugin_array2', 'handler');
danielebarchiesi@0 83 $this->assertPluginMissingClass($module, $type, 'plugin_array_dne', 'handler');
danielebarchiesi@0 84 // TODO Test big hook plugins.
danielebarchiesi@0 85
danielebarchiesi@0 86 $type = 'cached';
danielebarchiesi@0 87
danielebarchiesi@0 88 // Test function retrieval for plugins using different definition methods.
danielebarchiesi@0 89 $this->assertPluginFunction($module, $type, 'plugin_array', 'function');
danielebarchiesi@0 90 $this->assertPluginFunction($module, $type, 'plugin_array2', 'function');
danielebarchiesi@0 91 $this->assertPluginMissingFunction($module, $type, 'plugin_array_dne', 'function');
danielebarchiesi@0 92 $this->assertPluginFunction($module, "big_hook_$type", 'test1', 'function');
danielebarchiesi@0 93
danielebarchiesi@0 94 // Test class retrieval for plugins using different definition methods.
danielebarchiesi@0 95 $this->assertPluginClass($module, $type, 'plugin_array', 'handler');
danielebarchiesi@0 96 $this->assertPluginClass($module, $type, 'plugin_array2', 'handler');
danielebarchiesi@0 97 $this->assertPluginMissingClass($module, $type, 'plugin_array_dne', 'handler');
danielebarchiesi@0 98 // TODO Test big hook plugins.
danielebarchiesi@0 99 }
danielebarchiesi@0 100 }