summaryrefslogtreecommitdiff
path: root/sites/all/modules/ctools/tests
diff options
context:
space:
mode:
Diffstat (limited to 'sites/all/modules/ctools/tests')
-rw-r--r--sites/all/modules/ctools/tests/context.test62
-rw-r--r--sites/all/modules/ctools/tests/css.test81
-rw-r--r--sites/all/modules/ctools/tests/css_cache.test48
-rwxr-xr-xsites/all/modules/ctools/tests/ctools.drush.sh119
-rw-r--r--sites/all/modules/ctools/tests/ctools.plugins.test100
-rw-r--r--sites/all/modules/ctools/tests/ctools_export_test/ctools_export.test215
-rw-r--r--sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.default_ctools_export_tests.inc31
-rw-r--r--sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.info16
-rw-r--r--sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.install86
-rw-r--r--sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.module10
-rw-r--r--sites/all/modules/ctools/tests/ctools_plugin_test.info20
-rw-r--r--sites/all/modules/ctools/tests/ctools_plugin_test.module72
-rw-r--r--sites/all/modules/ctools/tests/math_expression.test129
-rw-r--r--sites/all/modules/ctools/tests/math_expression_stack.test63
-rw-r--r--sites/all/modules/ctools/tests/object_cache.test46
-rw-r--r--sites/all/modules/ctools/tests/plugins/cached/ctoolsCachedPluginArray.class.php7
-rw-r--r--sites/all/modules/ctools/tests/plugins/cached/ctoolsCachedPluginArray2.class.php7
-rw-r--r--sites/all/modules/ctools/tests/plugins/cached/plugin_array.inc20
-rw-r--r--sites/all/modules/ctools/tests/plugins/cached/plugin_array2.inc20
-rw-r--r--sites/all/modules/ctools/tests/plugins/cached/plugin_array_dne.inc15
-rw-r--r--sites/all/modules/ctools/tests/plugins/not_cached/ctoolsNotCachedPluginArray.class.php7
-rw-r--r--sites/all/modules/ctools/tests/plugins/not_cached/ctoolsNotCachedPluginArray2.class.php7
-rw-r--r--sites/all/modules/ctools/tests/plugins/not_cached/plugin_array.inc20
-rw-r--r--sites/all/modules/ctools/tests/plugins/not_cached/plugin_array2.inc20
-rw-r--r--sites/all/modules/ctools/tests/plugins/not_cached/plugin_array_dne.inc15
25 files changed, 1236 insertions, 0 deletions
diff --git a/sites/all/modules/ctools/tests/context.test b/sites/all/modules/ctools/tests/context.test
new file mode 100644
index 000000000..bdf14e3f4
--- /dev/null
+++ b/sites/all/modules/ctools/tests/context.test
@@ -0,0 +1,62 @@
+<?php
+
+class CtoolsContextKeywordsSubstitutionTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Keywords substitution',
+ 'description' => 'Verify that keywords are properly replaced with data.',
+ 'group' => 'Chaos Tools Suite',
+ );
+ }
+
+ public function setUp() {
+ parent::setUp('ctools');
+
+ ctools_include('context');
+ }
+
+ public function testKeywordsSubstitution() {
+ // Create node context for substitution.
+ $node = $this->drupalCreateNode();
+ $context = ctools_context_create('node', $node);
+ $contexts = array('argument_1' => $context);
+
+ // Run tests on some edge cases.
+ $checks = array(
+ '%node:changed:raw:' => array(
+ "{$node->changed}:",
+ t('Multi-level token has been replaced. Colon left untouched.'),
+ ),
+ '%node:title' => array(
+ "{$node->title}",
+ t('Keyword and converter have been replaced.'),
+ ),
+ '%%node:title' => array(
+ "%node:title",
+ t('Keyword after escaped percent sign left untouched.'),
+ ),
+ '%node:title%node:nid' => array(
+ "{$node->title}{$node->nid}",
+ t('Multiple substitutions have been replaced.'),
+ ),
+ '%node:title:' => array(
+ "{$node->title}:",
+ t('Colon after keyword and converter left untouched.'),
+ ),
+ '%node:title%%' => array(
+ "{$node->title}%",
+ t('Escaped percent sign after keyword and converter left untouched.'),
+ ),
+ '%%%node:title' => array(
+ "%{$node->title}",
+ t('Keyword after escaped and unescaped percent sign has been replaced.'),
+ ),
+ );
+ foreach ($checks as $string => $expectations) {
+ list($expected_result, $message) = $expectations;
+ $actual_result = ctools_context_keyword_substitute($string, array(), $contexts);
+ $this->assertEqual($actual_result, $expected_result, $message);
+ }
+ }
+
+}
diff --git a/sites/all/modules/ctools/tests/css.test b/sites/all/modules/ctools/tests/css.test
new file mode 100644
index 000000000..4a5200caa
--- /dev/null
+++ b/sites/all/modules/ctools/tests/css.test
@@ -0,0 +1,81 @@
+<?php
+/**
+ * @file
+ * Tests for different parts of the ctools plugin system.
+ */
+
+/**
+ * Test menu links depending on user permissions.
+ */
+class CtoolsCssTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'CSS Tools tests',
+ 'description' => '...',
+ 'group' => 'Chaos Tools Suite',
+ );
+ }
+
+ function setUp() {
+ // Additionally enable contact module.
+ parent::setUp('ctools');
+ }
+
+ /**
+ * Test that cached plugins are loaded correctly.
+ */
+ function testCssStuff() {
+ $css = "#some-id .some-class {\n color: black;\n illegal-key: foo;\n}";
+ $filtered_css = '#some-id .some-class{color:black;}';
+
+ ctools_include('css');
+ $filename1 = ctools_css_store('unfiltered-css-test', $css, FALSE);
+ $filename2 = ctools_css_store('filtered-css-test', $css, TRUE);
+
+ $this->assertEqual($filename1, ctools_css_retrieve('unfiltered-css-test'), 'Unfiltered css file successfully fetched');
+ $file_contents = file_get_contents($filename1);
+ $this->assertEqual($css, $file_contents, 'Unfiltered css file contents are correct');
+// $match = $filename1 == ctools_css_retrieve('unfiltered-css-test') ? 'Match' : 'No match';
+// $output .= '<pre>Unfiltered: ' . $filename1 . ' ' . $match . '</pre>';
+// $output .= '<pre>' . file_get_contents($filename1) . '</pre>';
+
+ $this->assertEqual($filename2, ctools_css_retrieve('filtered-css-test'), 'Filtered css file succcesfully fetched');
+ $file_contents = file_get_contents($filename2);
+ $this->assertEqual($filtered_css, $file_contents, 'Filtered css file contents are correct');
+ // $match = $filename2 == ctools_css_retrieve('filtered-css-test') ? 'Match' : 'No match';
+// $output .= '<pre>Filtered: ' . $filename2 . ' ' . $match . '</pre>';
+// $output .= '<pre>' . file_get_contents($filename2) . '</pre>';
+//
+// drupal_add_css($filename2, array('type' => 'file'));
+// return array('#markup' => $output);
+
+
+ // Test that in case that url can be used, the value surives when a colon is in it.
+ $css = "#some-id {\n background-image: url(http://example.com/example.gif);\n}";
+ $css_data = ctools_css_disassemble($css);
+ $empty_array = array();
+ $disallowed_values_regex = '/(expression)/';
+ $filtered = ctools_css_assemble(ctools_css_filter_css_data($css_data, $empty_array, $empty_array, '', $disallowed_values_regex));
+ $url = (strpos($filtered, 'http://example.com/example.gif') !== FALSE);
+ $this->assertTrue($url, 'CSS with multiple colons can survive.');
+
+ // Test that in case the CSS has two properties defined are merged.
+ $css = "#some-id {\n font-size: 12px;\n}\n#some-id {\n color: blue;\n}";
+ $filtered = ctools_css_filter($css);
+ $font_size = (strpos($filtered, 'font-size:12px;') !== FALSE);
+ $color = (strpos($filtered, 'color:blue') !== FALSE);
+ $this->assertTrue($font_size && $color, 'Multiple properties are merged.');
+
+ $css = '@import url("other.css");p {color: red;}';
+ $filtered = ctools_css_filter($css);
+ $other_css = (strpos($filtered, 'other.css') === FALSE);
+ $color = (strpos($filtered, 'color:red') !== FALSE);
+ $this->assertTrue($other_css && $color, 'CSS is properly sanitized.');
+
+ $css = ';p {color: red; font-size: 12px;}';
+ $filtered = ctools_css_filter($css);
+ $font_size = (strpos($filtered, 'font-size:12px;') !== FALSE);
+ $color = (strpos($filtered, 'color:red') !== FALSE);
+ $this->assertTrue($font_size && $color, 'Multiple properties are retained.');
+ }
+}
diff --git a/sites/all/modules/ctools/tests/css_cache.test b/sites/all/modules/ctools/tests/css_cache.test
new file mode 100644
index 000000000..e289b42c9
--- /dev/null
+++ b/sites/all/modules/ctools/tests/css_cache.test
@@ -0,0 +1,48 @@
+<?php
+/**
+ * @file
+ * Tests the custom CSS cache handler.
+ */
+
+/**
+ * Tests the custom CSS cache handler.
+ */
+class CtoolsObjectCache extends DrupalWebTestCase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getInfo() {
+ return array(
+ 'name' => 'Ctools CSS cache',
+ 'description' => 'Tests the custom CSS cache handler.',
+ 'group' => 'Chaos Tools Suite',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ parent::setUp('ctools');
+ }
+
+ /**
+ * Tests the custom CSS cache handler.
+ *
+ * @see https://drupal.org/node/1313368
+ */
+ public function testCssCache() {
+ // Create a CSS cache entry.
+ $filename = ctools_css_cache('body { color: red; }');
+
+ // Perform a cron run. The CSS cache entry should not be removed.
+ $this->cronRun();
+ $this->assertTrue(file_exists($filename), 'The CSS cache is not cleared after performing a cron run.');
+
+ // Manually clear the caches. The CSS cache entry should be removed.
+ drupal_flush_all_caches();
+ $this->assertFalse(file_exists($filename), 'The CSS cache is cleared after clearing all caches.');
+ }
+
+}
diff --git a/sites/all/modules/ctools/tests/ctools.drush.sh b/sites/all/modules/ctools/tests/ctools.drush.sh
new file mode 100755
index 000000000..31bdee359
--- /dev/null
+++ b/sites/all/modules/ctools/tests/ctools.drush.sh
@@ -0,0 +1,119 @@
+#!/bin/bash
+
+# Run this from the terminal inside a drupal root folder
+# i.e. DRUPAL_ROOT_DIR/sites/all/modules/contrib/ctools/tests/ctools.drush.sh
+
+function stamp {
+ echo ==============
+ echo timestamp : `date`
+ echo ==============
+}
+
+DRUPAL_ROOT=`drush dd`
+MODULE_DIR="$DRUPAL_ROOT/sites/all/modules"
+MODULE_NAME="ctools_drush_test"
+
+stamp
+
+echo 'Enabling ctools, views, and bulk_export modules.'
+drush en ctools views bulk_export --yes
+
+stamp
+echo 'Reading all export info'
+drush ctools-export-info
+
+stamp
+echo 'Reading all export info with format'
+drush ctools-export-info --format=json
+
+stamp
+echo 'Reading tables only from export info'
+drush ctools-export-info --tables-only
+
+stamp
+echo 'Reading tables only from export info with format'
+drush ctools-export-info --tables-only --format=json
+
+stamp
+echo 'Reading all disabled exportables'
+drush ctools-export-info --filter=disabled
+
+stamp
+echo 'Enabling all default views'
+drush ctools-export-enable views_view --yes
+
+stamp
+echo 'Reading all enabled exportables'
+drush ctools-export-info --filter=enabled
+
+stamp
+echo 'Reading all overridden exportables'
+drush ctools-export-info --filter=overridden
+
+stamp
+echo 'Reading all database only exportables'
+drush ctools-export-info --filter=database
+
+stamp
+echo 'View all default views export data'
+drush ctools-export-view views_view --yes
+
+stamp
+echo 'View default "archive" view export data'
+drush ctools-export-view views_view archive
+
+stamp
+echo 'Disable default "archive" view'
+drush ctools-export-disable views_view archive
+
+stamp
+echo 'Enable default "archive" view'
+drush ctools-export-enable views_view archive
+
+stamp
+echo 'Reading all enabled exportables (archive disabled)'
+drush ctools-export-info
+
+stamp
+echo 'Disabling all default views'
+drush ctools-export-disable views_view --yes
+
+stamp
+echo 'Revert all default views'
+drush ctools-export-revert views_view --yes
+
+stamp
+echo 'Enable all node views'
+drush ctools-export-enable views_view --module=node --yes
+
+stamp
+echo 'Disable all node views'
+drush ctools-export-disable views_view --module=node --yes
+
+stamp
+echo 'Revert all node views'
+drush ctools-export-revert views_view --module=node --yes
+
+stamp
+echo 'Revert all exportables'
+drush ctools-export-revert --all --yes
+
+stamp
+echo 'Enable all exportables'
+drush ctools-export-enable --all --yes
+
+stamp
+echo 'Disable all exportables'
+drush ctools-export-disable --all --yes
+
+stamp
+echo 'Bulk export all objects'
+drush ctools-export $MODULE_NAME --subdir='tests' --choice=1
+
+stamp
+echo 'Show all files in created folder'
+ls -lAR "$MODULE_DIR/tests/$MODULE_NAME"
+
+stamp
+echo 'Removing exported object files'
+rm -Rf $MODULE_DIR/tests
diff --git a/sites/all/modules/ctools/tests/ctools.plugins.test b/sites/all/modules/ctools/tests/ctools.plugins.test
new file mode 100644
index 000000000..fe1829cfb
--- /dev/null
+++ b/sites/all/modules/ctools/tests/ctools.plugins.test
@@ -0,0 +1,100 @@
+<?php
+/**
+ * @file
+ * Tests for different parts of the ctools plugin system.
+ */
+
+/**
+ * Test menu links depending on user permissions.
+ */
+class CtoolsPluginsGetInfoTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Get plugin info',
+ 'description' => 'Verify that plugin type definitions can properly set and overide values.',
+ 'group' => 'Chaos Tools Suite',
+ );
+ }
+
+ function setUp() {
+ // Additionally enable contact module.
+ parent::setUp('ctools', 'ctools_plugin_test');
+ }
+
+ protected function assertPluginFunction($module, $type, $id, $function = 'function') {
+ $func = ctools_plugin_load_function($module, $type, $id, $function);
+ $this->assertTrue(function_exists($func), t('Plugin @plugin of plugin type @module:@type successfully retrieved @retrieved for @function.', array(
+ '@plugin' => $id,
+ '@module' => $module,
+ '@type' => $type,
+ '@function' => $function,
+ '@retrieved' => $func,
+ )));
+ }
+
+ protected function assertPluginMissingFunction($module, $type, $id, $function = 'function') {
+ $func = ctools_plugin_load_function($module, $type, $id, $function);
+ $this->assertEqual($func, NULL, t('Plugin @plugin of plugin type @module:@type for @function with missing function successfully failed.', array(
+ '@plugin' => $id,
+ '@module' => $module,
+ '@type' => $type,
+ '@function' => $func,
+ )));
+ }
+
+ protected function assertPluginClass($module, $type, $id, $class = 'handler') {
+ $class_name = ctools_plugin_load_class($module, $type, $id, $class);
+ $this->assertTrue(class_exists($class_name), t('Plugin @plugin of plugin type @module:@type successfully retrieved @retrieved for @class.', array(
+ '@plugin' => $id,
+ '@module' => $module,
+ '@type' => $type,
+ '@class' => $class,
+ '@retrieved' => $class_name,
+ )));
+ }
+
+ protected function assertPluginMissingClass($module, $type, $id, $class = 'handler') {
+ $class_name = ctools_plugin_load_class($module, $type, $id, $class);
+ $this->assertEqual($class_name, NULL, t('Plugin @plugin of plugin type @module:@type for @class with missing class successfully failed.', array(
+ '@plugin' => $id,
+ '@module' => $module,
+ '@type' => $type,
+ '@class' => $class,
+ )));
+ }
+
+ /**
+ * Test that plugins are loaded correctly.
+ */
+ function testPluginLoading() {
+ ctools_include('plugins');
+ $module = 'ctools_plugin_test';
+ $type = 'not_cached';
+
+ // Test function retrieval for plugins using different definition methods.
+ $this->assertPluginFunction($module, $type, 'plugin_array', 'function');
+ $this->assertPluginFunction($module, $type, 'plugin_array2', 'function');
+ $this->assertPluginMissingFunction($module, $type, 'plugin_array_dne', 'function');
+ $this->assertPluginFunction($module, "big_hook_$type", 'test1', 'function');
+
+ // Test class retrieval for plugins using different definition methods.
+ $this->assertPluginClass($module, $type, 'plugin_array', 'handler');
+ $this->assertPluginClass($module, $type, 'plugin_array2', 'handler');
+ $this->assertPluginMissingClass($module, $type, 'plugin_array_dne', 'handler');
+ // TODO Test big hook plugins.
+
+ $type = 'cached';
+
+ // Test function retrieval for plugins using different definition methods.
+ $this->assertPluginFunction($module, $type, 'plugin_array', 'function');
+ $this->assertPluginFunction($module, $type, 'plugin_array2', 'function');
+ $this->assertPluginMissingFunction($module, $type, 'plugin_array_dne', 'function');
+ $this->assertPluginFunction($module, "big_hook_$type", 'test1', 'function');
+
+ // Test class retrieval for plugins using different definition methods.
+ $this->assertPluginClass($module, $type, 'plugin_array', 'handler');
+ $this->assertPluginClass($module, $type, 'plugin_array2', 'handler');
+ $this->assertPluginMissingClass($module, $type, 'plugin_array_dne', 'handler');
+ // TODO Test big hook plugins.
+ }
+}
diff --git a/sites/all/modules/ctools/tests/ctools_export_test/ctools_export.test b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export.test
new file mode 100644
index 000000000..1accfd740
--- /dev/null
+++ b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export.test
@@ -0,0 +1,215 @@
+<?php
+
+/**
+ * @file
+ * Tests for the CTools export system.
+ */
+
+/**
+ * Tests export CRUD.
+ */
+class CtoolsExportCrudTestCase extends DrupalWebTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'CTools export CRUD tests',
+ 'description' => 'Test the CRUD functionality for the ctools export system.',
+ 'group' => 'Chaos Tools Suite',
+ );
+ }
+
+ protected function setUp() {
+ parent::setUp('ctools_export_test');
+ $this->resetAll();
+ }
+
+ /**
+ * Tests CRUD operation: Load.
+ */
+ function testCrudExportLoad() {
+ $loaded_export = ctools_export_crud_load('ctools_export_test', 'database_test');
+
+ $expected_export = new stdClass();
+ $expected_export->machine = 'database_test';
+ $expected_export->title = 'Database test';
+ $expected_export->number = 0;
+ $expected_export->data = array(
+ 'test_1' => 'Test 1',
+ 'test_2' => 'Test 2',
+ );
+ $expected_export->table = 'ctools_export_test';
+ $expected_export->export_type = EXPORT_IN_DATABASE;
+ $expected_export->type = 'Normal';
+
+ $this->assertEqual($expected_export, $loaded_export, 'An exportable object has been loaded correctly from the database.');
+ }
+
+ /**
+ * Tests CRUD operation: Load multiple.
+ */
+ function testCrudExportLoadMultiple() {
+ $exportable_names = array('database_test', 'overridden_test', 'default_test');
+ $loaded_exports = ctools_export_crud_load_multiple('ctools_export_test', $exportable_names);
+
+ $this->assertEqual(count($loaded_exports), 3, 'All exportables have been loaded.');
+ }
+
+ /**
+ * Tests CRUD operation: Load all.
+ */
+ function testCrudExportLoadAll() {
+ $loaded_exports = ctools_export_crud_load_all('ctools_export_test');
+
+ $this->assertEqual(count($loaded_exports), 3, 'All exportables have been loaded.');
+ }
+
+ /**
+ * Tests CRUD operation: Save.
+ */
+ function testCrudExportSave() {
+ $default_export = ctools_export_crud_load('ctools_export_test', 'default_test');
+
+ $this->assertTrue($default_export->in_code_only,'The loaded exportable is in code only.');
+
+ ctools_export_crud_save('ctools_export_test', $default_export);
+
+ // Clear the static cache.
+ ctools_export_load_object_reset('ctools_export_test');
+
+ $overridden_export = ctools_export_crud_load('ctools_export_test', 'default_test');
+
+ $this->assertTrue($overridden_export->export_type === 3, 'The loaded exportable is overridden in the database.');
+ }
+
+ /**
+ * Tests CRUD operation: New.
+ */
+ function testCrudExportNew() {
+ // Default exportable with defualt values.
+ $new_export = ctools_export_crud_new('ctools_export_test');
+
+ $expected_export = new stdClass();
+ $expected_export->machine = '';
+ $expected_export->title = '';
+ $expected_export->number = 0;
+ $expected_export->data = NULL;
+ $expected_export->export_type = NULL;
+ $expected_export->type = 'Local';
+
+ $this->assertEqual($expected_export, $new_export, 'An exportable with default values is created.');
+
+ // Default exportable without default values.
+ $new_export = ctools_export_crud_new('ctools_export_test', FALSE);
+
+ $expected_export = new stdClass();
+ $expected_export->machine = '';
+ $expected_export->title = '';
+ $expected_export->number = NULL;
+ $expected_export->data = NULL;
+
+ $this->assertEqual($expected_export, $new_export, 'An exportable without default values has been created.');
+ }
+
+ /**
+ * Tests CRUD operation: Revert.
+ */
+ function testCrudExportRevert() {
+ // Load exportable, will come from database.
+ $original_export = ctools_export_crud_load('ctools_export_test', 'overridden_test');
+
+ $this->assertTrue($original_export->export_type === 3, 'Loaded export is overridden.');
+
+ $machine = $original_export->machine;
+ ctools_export_crud_delete('ctools_export_test', $original_export);
+
+ $result = db_query("SELECT machine FROM {ctools_export_test} WHERE machine = :machine", array(':machine' => $machine))->fetchField();
+
+ $this->assertFalse($result, 'The exportable object has been removed from the database.');
+
+ // Clear the static cache.
+ ctools_export_load_object_reset('ctools_export_test');
+
+ // Reload the same object.
+ $default_export = ctools_export_crud_load('ctools_export_test', 'overridden_test');
+
+ // Check the exportable is now in_code_only.
+ $this->assertTrue($default_export->in_code_only, 'The loaded exportable is in the database only.');
+
+ // Make sure the default object loaded matches the same overridden one in the database.
+ $this->assertEqual($original_export->machine, $default_export->machine, 'The default exportable has been loaded and matches the overridden exportable.');
+ }
+
+ /**
+ * Tests CRUD operation: Delete.
+ */
+ function testCrudExportDelete() {
+ // Create a stub entry save it and delete it from the database.
+ $new_export = ctools_export_crud_new('ctools_export_test');
+ ctools_export_crud_save('ctools_export_test', $new_export);
+
+ $machine = $new_export->machine;
+ ctools_export_crud_delete('ctools_export_test', $new_export);
+ $result = ctools_export_crud_load('ctools_export_test', $machine);
+
+ $this->assertFalse($result, 'The new exportable has been removed from the database.');
+
+ // Load the database only exportable.
+ $database_export = ctools_export_crud_load('ctools_export_test', 'database_test');
+
+ $machine = $database_export->machine;
+ ctools_export_crud_delete('ctools_export_test', $database_export);
+ // Clear the exportable caches as it's been loaded above.
+ ctools_export_load_object_reset('ctools_export_test');
+ $result = ctools_export_crud_load('ctools_export_test', $machine);
+
+ $this->assertFalse($result, 'The database exportable has been removed from the database.');
+ }
+
+ /**
+ * Tests CRUD operation: Set status.
+ */
+ function testCrudExportSetStatus() {
+ // Database only object.
+ $database_export = ctools_export_crud_load('ctools_export_test', 'database_test');
+ ctools_export_crud_disable('ctools_export_test', $database_export);
+ ctools_export_load_object_reset('ctools_export_test');
+ $disabled_export = ctools_export_crud_load('ctools_export_test', 'database_test');
+
+ $this->assertTrue($disabled_export->disabled, 'The database only exportable has been disabled.');
+
+ ctools_export_crud_enable('ctools_export_test', $disabled_export);
+ ctools_export_load_object_reset('ctools_export_test');
+ $enabled_export = ctools_export_crud_load('ctools_export_test', 'database_test');
+
+ $this->assertTrue(empty($enabled_export->disabled), 'The database only exportable has been enabled.');
+
+ // Overridden object.
+ $overridden_export = ctools_export_crud_load('ctools_export_test', 'overridden_test');
+ ctools_export_crud_disable('ctools_export_test', $overridden_export);
+ ctools_export_load_object_reset('ctools_export_test');
+ $disabled_export = ctools_export_crud_load('ctools_export_test', 'overridden_test');
+
+ $this->assertTrue($disabled_export->disabled, 'The overridden exportable has been disabled.');
+
+ ctools_export_crud_enable('ctools_export_test', $disabled_export);
+ ctools_export_load_object_reset('ctools_export_test');
+ $enabled_export = ctools_export_crud_load('ctools_export_test', 'overridden_test');
+
+ $this->assertTrue(empty($enabled_export->disabled), 'The overridden exportable has been enabled.');
+
+ // Default object.
+ $default_export = ctools_export_crud_load('ctools_export_test', 'default_test');
+ ctools_export_crud_disable('ctools_export_test', $default_export);
+ ctools_export_load_object_reset('ctools_export_test');
+ $disabled_export = ctools_export_crud_load('ctools_export_test', 'default_test');
+
+ $this->assertTrue($disabled_export->disabled, 'The default exportable has been disabled.');
+
+ ctools_export_crud_enable('ctools_export_test', $disabled_export);
+ ctools_export_load_object_reset('ctools_export_test');
+ $enabled_export = ctools_export_crud_load('ctools_export_test', 'default_test');
+
+ $this->assertTrue(empty($enabled_export->disabled), 'The default exportable has been enabled.');
+ }
+
+}
diff --git a/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.default_ctools_export_tests.inc b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.default_ctools_export_tests.inc
new file mode 100644
index 000000000..9f2dd6c6b
--- /dev/null
+++ b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.default_ctools_export_tests.inc
@@ -0,0 +1,31 @@
+<?php
+
+/**
+ * Implements hook_default_export_tests().
+ */
+function ctools_export_test_default_ctools_export_tests() {
+ $ctools_export_tests = array();
+
+ $ctools_export_test = new stdClass();
+ $ctools_export_test->disabled = FALSE; /* Edit this to true to make a default export_test disabled initially */
+ $ctools_export_test->api_version = 1;
+ $ctools_export_test->machine = 'overridden_test';
+ $ctools_export_test->title = 'Overridden test';
+ $ctools_export_test->number = 1;
+ $ctools_export_test->data = array(
+ 'test_1' => 'Test 1',
+ 'test_2' => 'Test 2',
+ );
+ $ctools_export_tests['overridden_test'] = $ctools_export_test;
+
+ $ctools_export_test = new stdClass();
+ $ctools_export_test->disabled = FALSE; /* Edit this to true to make a default export_test disabled initially */
+ $ctools_export_test->api_version = 1;
+ $ctools_export_test->machine = 'default_test';
+ $ctools_export_test->title = 'Default test';
+ $ctools_export_test->number = 2;
+ $ctools_export_test->data = '';
+ $ctools_export_tests['default_test'] = $ctools_export_test;
+
+ return $ctools_export_tests;
+}
diff --git a/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.info b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.info
new file mode 100644
index 000000000..e016aeb5d
--- /dev/null
+++ b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.info
@@ -0,0 +1,16 @@
+name = CTools export test
+description = CTools export test module
+core = 7.x
+package = Chaos tool suite
+version = CTOOLS_MODULE_VERSION
+dependencies[] = ctools
+hidden = TRUE
+
+files[] = ctools_export.test
+
+; Information added by Drupal.org packaging script on 2015-08-19
+version = "7.x-1.9"
+core = "7.x"
+project = "ctools"
+datestamp = "1440020680"
+
diff --git a/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.install b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.install
new file mode 100644
index 000000000..2eb54ca39
--- /dev/null
+++ b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.install
@@ -0,0 +1,86 @@
+<?php
+
+/**
+ * Implements hook_schema();
+ */
+function ctools_export_test_schema() {
+ $schema['ctools_export_test'] = array(
+ 'description' => 'CTools export test data table',
+ 'export' => array(
+ 'key' => 'machine',
+ 'identifier' => 'ctools_export_test',
+ 'default hook' => 'default_ctools_export_tests',
+ 'bulk export' => TRUE,
+ 'api' => array(
+ 'owner' => 'ctools_export_test',
+ 'api' => 'default_ctools_export_tests',
+ 'minimum_version' => 1,
+ 'current_version' => 1,
+ ),
+ ),
+ 'fields' => array(
+ 'machine' => array(
+ 'description' => "The unique machine name (required by ctools).",
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'title' => array(
+ 'description' => "The human readable title.",
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'number' => array(
+ 'description' => "A number.",
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'data' => array(
+ 'type' => 'blob',
+ 'description' => "A serialized array of data.",
+ 'serialize' => TRUE,
+ 'serialized default' => 'a:0:{}',
+ ),
+ ),
+ 'primary key' => array('machine'),
+ );
+
+ return $schema;
+}
+
+/**
+ * Implments hook_install();
+ */
+function ctools_export_test_install() {
+ $ctools_export_tests = array();
+ // Put this default in the database only (no default).
+ $ctools_export_test = new stdClass();
+ $ctools_export_test->machine = 'database_test';
+ $ctools_export_test->title = 'Database test';
+ $ctools_export_test->number = 0;
+ $ctools_export_test->data = array(
+ 'test_1' => 'Test 1',
+ 'test_2' => 'Test 2',
+ );
+ $ctools_export_tests['database_test'] = $ctools_export_test;
+
+ // Put this default in the database, so we have this in code and in the database.
+ $ctools_export_test = new stdClass();
+ $ctools_export_test->machine = 'overridden_test';
+ $ctools_export_test->title = 'Overridden test';
+ $ctools_export_test->number = 1;
+ $ctools_export_test->data = array(
+ 'test_1' => 'Test 1',
+ 'test_2' => 'Test 2',
+ );
+ $ctools_export_tests['overridden_test'] = $ctools_export_test;
+
+ foreach ($ctools_export_tests as $ctools_export_test) {
+ // Save the record to the database.
+ drupal_write_record('ctools_export_test', $ctools_export_test);
+ }
+}
diff --git a/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.module b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.module
new file mode 100644
index 000000000..80f1adbb3
--- /dev/null
+++ b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.module
@@ -0,0 +1,10 @@
+<?php
+
+/**
+ * Implements hook_ctools_plugin_api().
+ */
+function ctools_export_test_ctools_plugin_api($module, $api) {
+ if ($module == 'ctools_export_test' && $api == 'default_ctools_export_tests') {
+ return array('version' => 1);
+ }
+}
diff --git a/sites/all/modules/ctools/tests/ctools_plugin_test.info b/sites/all/modules/ctools/tests/ctools_plugin_test.info
new file mode 100644
index 000000000..15a510b62
--- /dev/null
+++ b/sites/all/modules/ctools/tests/ctools_plugin_test.info
@@ -0,0 +1,20 @@
+name = Chaos tools plugins test
+description = Provides hooks for testing ctools plugins.
+package = Chaos tool suite
+version = CTOOLS_MODULE_VERSION
+core = 7.x
+dependencies[] = ctools
+files[] = ctools.plugins.test
+files[] = object_cache.test
+files[] = css.test
+files[] = context.test
+files[] = math_expression.test
+files[] = math_expression_stack.test
+hidden = TRUE
+
+; Information added by Drupal.org packaging script on 2015-08-19
+version = "7.x-1.9"
+core = "7.x"
+project = "ctools"
+datestamp = "1440020680"
+
diff --git a/sites/all/modules/ctools/tests/ctools_plugin_test.module b/sites/all/modules/ctools/tests/ctools_plugin_test.module
new file mode 100644
index 000000000..567f6e73d
--- /dev/null
+++ b/sites/all/modules/ctools/tests/ctools_plugin_test.module
@@ -0,0 +1,72 @@
+<?php
+/**
+ * Define some plugin systems to test ctools plugin includes.
+ */
+
+/**
+ * Implementation of hook_ctools_plugin_dierctory()
+ */
+function ctools_plugin_test_ctools_plugin_directory($module, $plugin) {
+ if ($module == 'ctools_plugin_test') {
+ return 'plugins/' . $plugin;
+ }
+}
+
+function ctools_plugin_test_ctools_plugin_type() {
+ return array(
+ 'extra_defaults' => array(
+ 'defaults' => array(
+ 'bool' => true,
+ 'string' => 'string',
+ 'array' => array('some value'),
+ ),
+ ),
+ 'cached' => array(
+ 'cache' => TRUE,
+ 'classes' => array(
+ 'handler',
+ ),
+ ),
+ 'not_cached' => array(
+ 'cache' => FALSE,
+ 'classes' => array(
+ 'handler',
+ ),
+ ),
+ 'big_hook_cached' => array(
+ 'cache' => TRUE,
+ 'use hooks' => TRUE,
+ 'classes' => array(
+ 'handler',
+ ),
+ ),
+ 'big_hook_not_cached' => array(
+ 'cache' => FALSE,
+ 'use hooks' => TRUE,
+ 'classes' => array(
+ 'handler',
+ ),
+ ),
+ );
+}
+
+function ctools_plugin_test_ctools_plugin_test_big_hook_cached() {
+ return array(
+ 'test1' => array(
+ 'function' => 'ctools_plugin_test_hook_cached_test',
+ 'handler' => 'class1',
+ ),
+ );
+}
+
+function ctools_plugin_test_ctools_plugin_test_big_hook_not_cached() {
+ return array(
+ 'test1' => array(
+ 'function' => 'ctools_plugin_test_hook_not_cached_test',
+ 'class' => 'class1',
+ ),
+ );
+}
+
+function ctools_plugin_test_hook_cached_test() {}
+function ctools_plugin_test_hook_not_cached_test() {}
diff --git a/sites/all/modules/ctools/tests/math_expression.test b/sites/all/modules/ctools/tests/math_expression.test
new file mode 100644
index 000000000..730e079a5
--- /dev/null
+++ b/sites/all/modules/ctools/tests/math_expression.test
@@ -0,0 +1,129 @@
+<?php
+
+/**
+ * @file
+ * Contains \CtoolsMathExpressionTestCase.
+ */
+
+/**
+ * Tests the MathExpression library of ctools.
+ */
+class CtoolsMathExpressionTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'CTools math expression tests',
+ 'description' => 'Test the math expression library of ctools.',
+ 'group' => 'Chaos Tools Suite',
+ );
+ }
+
+ public function setUp() {
+ parent::setUp('ctools', 'ctools_plugin_test');
+ }
+
+ /**
+ * Returns a random double between 0 and 1.
+ */
+ protected function rand01() {
+ return rand(0, PHP_INT_MAX) / PHP_INT_MAX;
+ }
+
+ /**
+ * A custom assertion with checks the values in a certain range.
+ */
+ protected function assertFloat($first, $second, $delta = 0.0000001, $message = '', $group = 'Other') {
+ return $this->assert(abs($first - $second) <= $delta, $message ? $message : t('Value @first is equal to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
+ }
+
+ public function testArithmetic() {
+ $math_expression = new ctools_math_expr();
+
+ // Test constant expressions.
+ $this->assertEqual($math_expression->e('2'), 2);
+ $random_number = rand(0, 10);
+ $this->assertEqual($random_number, $math_expression->e((string) $random_number));
+
+ // Test simple arithmetic.
+ $random_number_a = rand(5, 10);
+ $random_number_b = rand(5, 10);
+ $this->assertEqual($random_number_a + $random_number_b, $math_expression->e("$random_number_a + $random_number_b"));
+ $this->assertEqual($random_number_a - $random_number_b, $math_expression->e("$random_number_a - $random_number_b"));
+ $this->assertEqual($random_number_a * $random_number_b, $math_expression->e("$random_number_a * $random_number_b"));
+ $this->assertEqual($random_number_a / $random_number_b, $math_expression->e("$random_number_a / $random_number_b"));
+
+ // Test Associative property.
+ $random_number_c = rand(5, 10);
+ $this->assertEqual($math_expression->e("$random_number_a + ($random_number_b + $random_number_c)"), $math_expression->e("($random_number_a + $random_number_b) + $random_number_c"));
+ $this->assertEqual($math_expression->e("$random_number_a * ($random_number_b * $random_number_c)"), $math_expression->e("($random_number_a * $random_number_b) * $random_number_c"));
+
+ // Test Commutative property.
+ $this->assertEqual($math_expression->e("$random_number_a + $random_number_b"), $math_expression->e("$random_number_b + $random_number_a"));
+ $this->assertEqual($math_expression->e("$random_number_a * $random_number_b"), $math_expression->e("$random_number_b * $random_number_a"));
+
+ // Test Distributive property.
+ $this->assertEqual($math_expression->e("($random_number_a + $random_number_b) * $random_number_c"), $math_expression->e("($random_number_a * $random_number_c + $random_number_b * $random_number_c)"));
+
+ $this->assertEqual(pow($random_number_a, $random_number_b), $math_expression->e("$random_number_a ^ $random_number_b"));
+ }
+
+ public function testBuildInFunctions() {
+ $math_expression = new ctools_math_expr();
+
+ // @todo: maybe run this code multiple times to test different values.
+ $random_double = $this->rand01();
+ $random_int = rand(5, 10);
+ $this->assertFloat(sin($random_double), $math_expression->e("sin($random_double)"));
+ $this->assertFloat(cos($random_double), $math_expression->e("cos($random_double)"));
+ $this->assertFloat(tan($random_double), $math_expression->e("tan($random_double)"));
+ $this->assertFloat(exp($random_double), $math_expression->e("exp($random_double)"));
+ $this->assertFloat(sqrt($random_double), $math_expression->e("sqrt($random_double)"));
+ $this->assertFloat(log($random_double), $math_expression->e("ln($random_double)"));
+ $this->assertFloat(round($random_double), $math_expression->e("round($random_double)"));
+ $this->assertFloat(abs($random_double + $random_int), $math_expression->e('abs(' . ($random_double + $random_int) . ')'));
+ $this->assertEqual(round($random_double + $random_int), $math_expression->e('round(' . ($random_double + $random_int) . ')'));
+ $this->assertEqual(ceil($random_double + $random_int), $math_expression->e('ceil(' . ($random_double + $random_int) . ')'));
+ $this->assertEqual(floor($random_double + $random_int), $math_expression->e('floor(' . ($random_double + $random_int) . ')'));
+
+ // @fixme: you can't run time without an argument.
+ $this->assertFloat(time(), $math_expression->e('time(1)'));
+
+ $random_double_a = $this->rand01();
+ $random_double_b = $this->rand01();
+ // @fixme: max/min don't work at the moment.
+// $this->assertFloat(max($random_double_a, $random_double_b), $math_expression->e("max($random_double_a, $random_double_b)"));
+// $this->assertFloat(min($random_double_a, $random_double_b), $math_expression->e("min($random_double_a, $random_double_b)"));
+ }
+
+ public function testVariables() {
+ $math_expression = new ctools_math_expr();
+
+ $random_number_a = rand(5, 10);
+ $random_number_b = rand(5, 10);
+
+ // Store the first random number and use it on calculations.
+ $math_expression->e("var = $random_number_a");
+ $this->assertEqual($random_number_a + $random_number_b, $math_expression->e("var + $random_number_b"));
+ $this->assertEqual($random_number_a * $random_number_b, $math_expression->e("var * $random_number_b"));
+ $this->assertEqual($random_number_a - $random_number_b, $math_expression->e("var - $random_number_b"));
+ $this->assertEqual($random_number_a / $random_number_b, $math_expression->e("var / $random_number_b"));
+ }
+
+ public function testCustomFunctions() {
+ $math_expression = new ctools_math_expr();
+
+ $random_number_a = rand(5, 10);
+ $random_number_b = rand(5, 10);
+
+ // Create a one-argument function.
+ $math_expression->e("f(x) = 2 * x");
+ $this->assertEqual($random_number_a * 2, $math_expression->e("f($random_number_a)"));
+ $this->assertEqual($random_number_b * 2, $math_expression->e("f($random_number_b)"));
+
+ // Create a two-argument function.
+ $math_expression->e("g(x, y) = 2 * x + y");
+ $this->assertEqual($random_number_a * 2 + $random_number_b, $math_expression->e("g($random_number_a, $random_number_b)"));
+
+ // Use a custom function in another function.
+ $this->assertEqual(($random_number_a * 2 + $random_number_b) * 2, $math_expression->e("f(g($random_number_a, $random_number_b))"));
+ }
+}
diff --git a/sites/all/modules/ctools/tests/math_expression_stack.test b/sites/all/modules/ctools/tests/math_expression_stack.test
new file mode 100644
index 000000000..8143a55b8
--- /dev/null
+++ b/sites/all/modules/ctools/tests/math_expression_stack.test
@@ -0,0 +1,63 @@
+<?php
+
+/**
+ * @file
+ * Contains \CtoolsMathExpressionStackTestCase
+ */
+
+/**
+ * Tests the simple MathExpressionStack class.
+ */
+class CtoolsMathExpressionStackTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'CTools math expression stack tests',
+ 'description' => 'Test the stack class of the math expression library.',
+ 'group' => 'Chaos Tools Suite',
+ );
+ }
+
+ public function setUp() {
+ parent::setUp('ctools', 'ctools_plugin_test');
+ }
+
+ public function testStack() {
+ $stack = new ctools_math_expr_stack();
+
+ // Test the empty stack.
+ $this->assertNull($stack->last());
+ $this->assertNull($stack->pop());
+
+ // Add an element and see whether it's the right element.
+ $value = $this->randomName();
+ $stack->push($value);
+ $this->assertIdentical($value, $stack->last());
+ $this->assertIdentical($value, $stack->pop());
+ $this->assertNull($stack->pop());
+
+ // Add multiple elements and see whether they are returned in the right order.
+ $values = array($this->randomName(), $this->randomName(), $this->randomName());
+ foreach ($values as $value) {
+ $stack->push($value);
+ }
+
+ // Test the different elements at different positions with the last() method.
+ $count = count($values);
+ foreach ($values as $key => $value) {
+ $this->assertEqual($value, $stack->last($count - $key));
+ }
+
+ // Pass in a non-valid number to last.
+ $non_valid_number = rand(10, 20);
+ $this->assertNull($stack->last($non_valid_number));
+
+ // Test the order of the poping.
+ $values = array_reverse($values);
+ foreach ($values as $key => $value) {
+ $this->assertEqual($stack->last(), $value);
+ $this->assertEqual($stack->pop(), $value);
+ }
+ $this->assertNull($stack->pop());
+
+ }
+}
diff --git a/sites/all/modules/ctools/tests/object_cache.test b/sites/all/modules/ctools/tests/object_cache.test
new file mode 100644
index 000000000..8791d7e70
--- /dev/null
+++ b/sites/all/modules/ctools/tests/object_cache.test
@@ -0,0 +1,46 @@
+<?php
+/**
+ * @file
+ * Tests for different parts of the ctools object caching system.
+ */
+
+/**
+ * Test object cache storage.
+ */
+class CtoolsObjectCache extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Ctools object cache storage',
+ 'description' => 'Verify that objects are written, readable and lockable.',
+ 'group' => 'Chaos Tools Suite',
+ );
+ }
+
+ public function setUp() {
+ // Additionally enable ctools module.
+ parent::setUp('ctools');
+ }
+
+ public function testObjectStorage() {
+ $account1 = $this->drupalCreateUser(array());
+ $this->drupalLogin($account1);
+
+ $data = array(
+ 'test1' => 'foobar',
+ );
+
+ ctools_include('object-cache');
+ ctools_object_cache_set('testdata', 'one', $data);
+ $this->assertEqual($data, ctools_object_cache_get('testdata', 'one'), 'Object cache data successfully stored');
+
+ // TODO Test object locking somehow.
+ // Object locking/testing works on session_id but simpletest uses
+ // $this->session_id so can't be tested ATM.
+
+ ctools_object_cache_clear('testdata', 'one');
+ $this->assertFalse(ctools_object_cache_get('testdata', 'one'), 'Object cache data successfully cleared');
+
+ // TODO Test ctools_object_cache_clear_all somehow...
+ // ctools_object_cache_clear_all requires session_id funtionality as well.
+ }
+}
diff --git a/sites/all/modules/ctools/tests/plugins/cached/ctoolsCachedPluginArray.class.php b/sites/all/modules/ctools/tests/plugins/cached/ctoolsCachedPluginArray.class.php
new file mode 100644
index 000000000..ea087fa63
--- /dev/null
+++ b/sites/all/modules/ctools/tests/plugins/cached/ctoolsCachedPluginArray.class.php
@@ -0,0 +1,7 @@
+<?php
+/**
+ * @file
+ * A cached plugin object that tests inheritance including.
+ */
+
+class ctoolsCachedPluginArray {}
diff --git a/sites/all/modules/ctools/tests/plugins/cached/ctoolsCachedPluginArray2.class.php b/sites/all/modules/ctools/tests/plugins/cached/ctoolsCachedPluginArray2.class.php
new file mode 100644
index 000000000..f774541ca
--- /dev/null
+++ b/sites/all/modules/ctools/tests/plugins/cached/ctoolsCachedPluginArray2.class.php
@@ -0,0 +1,7 @@
+<?php
+/**
+ * @file
+ * A cached plugin object that tests inheritance including.
+ */
+
+class ctoolsCachedPluginArray2 extends ctoolsCachedPluginArray {}
diff --git a/sites/all/modules/ctools/tests/plugins/cached/plugin_array.inc b/sites/all/modules/ctools/tests/plugins/cached/plugin_array.inc
new file mode 100644
index 000000000..40a4bf736
--- /dev/null
+++ b/sites/all/modules/ctools/tests/plugins/cached/plugin_array.inc
@@ -0,0 +1,20 @@
+<?php
+/**
+ * @file
+ * Chaos Tools plugin include using a plugin array to declare a plugin.
+ */
+
+/**
+ * Plugin array plugin definition.
+ */
+$plugin = array(
+ 'function' => 'ctools_plugin_test_plugin_array_cached_test',
+ 'handler' => array(
+ 'class' => 'ctoolsCachedPluginArray',
+ ),
+);
+
+/**
+ * Plugin array function plugin.
+ */
+function ctools_plugin_test_plugin_array_cached_test() {}
diff --git a/sites/all/modules/ctools/tests/plugins/cached/plugin_array2.inc b/sites/all/modules/ctools/tests/plugins/cached/plugin_array2.inc
new file mode 100644
index 000000000..e6676154d
--- /dev/null
+++ b/sites/all/modules/ctools/tests/plugins/cached/plugin_array2.inc
@@ -0,0 +1,20 @@
+<?php
+/**
+ * @file
+ * Chaos Tools plugin include using a plugin array to declare a plugin.
+ */
+
+/**
+ * Plugin array plugin definition.
+ */
+$plugin = array(
+ 'function' => 'ctools_plugin_test_plugin_array2_cached_test',
+ 'handler' => array(
+ 'class' => 'ctoolsCachedPluginArray2',
+ ),
+);
+
+/**
+ * Plugin array function plugin.
+ */
+function ctools_plugin_test_plugin_array2_cached_test() {}
diff --git a/sites/all/modules/ctools/tests/plugins/cached/plugin_array_dne.inc b/sites/all/modules/ctools/tests/plugins/cached/plugin_array_dne.inc
new file mode 100644
index 000000000..e3d3bfb90
--- /dev/null
+++ b/sites/all/modules/ctools/tests/plugins/cached/plugin_array_dne.inc
@@ -0,0 +1,15 @@
+<?php
+/**
+ * @file
+ * Chaos Tools plugin include using a plugin array to declare a plugin.
+ */
+
+/**
+ * Plugin array plugin definition.
+ */
+$plugin = array(
+ 'function' => 'ctools_plugin_test_plugin_array_dne_cached_test',
+ 'handler' => array(
+ 'class' => 'ctoolsCachedPluginArrayDNE',
+ ),
+);
diff --git a/sites/all/modules/ctools/tests/plugins/not_cached/ctoolsNotCachedPluginArray.class.php b/sites/all/modules/ctools/tests/plugins/not_cached/ctoolsNotCachedPluginArray.class.php
new file mode 100644
index 000000000..422a7b34c
--- /dev/null
+++ b/sites/all/modules/ctools/tests/plugins/not_cached/ctoolsNotCachedPluginArray.class.php
@@ -0,0 +1,7 @@
+<?php
+/**
+ * @file
+ * A cached plugin object that tests inheritance including.
+ */
+
+class ctoolsNotCachedPluginArray extends ctoolsNotCachedPluginArray2 {}
diff --git a/sites/all/modules/ctools/tests/plugins/not_cached/ctoolsNotCachedPluginArray2.class.php b/sites/all/modules/ctools/tests/plugins/not_cached/ctoolsNotCachedPluginArray2.class.php
new file mode 100644
index 000000000..d7687dd02
--- /dev/null
+++ b/sites/all/modules/ctools/tests/plugins/not_cached/ctoolsNotCachedPluginArray2.class.php
@@ -0,0 +1,7 @@
+<?php
+/**
+ * @file
+ * A cached plugin object that tests including.
+ */
+
+class ctoolsNotCachedPluginArray2 {}
diff --git a/sites/all/modules/ctools/tests/plugins/not_cached/plugin_array.inc b/sites/all/modules/ctools/tests/plugins/not_cached/plugin_array.inc
new file mode 100644
index 000000000..3f4539359
--- /dev/null
+++ b/sites/all/modules/ctools/tests/plugins/not_cached/plugin_array.inc
@@ -0,0 +1,20 @@
+<?php
+/**
+ * @file
+ * Chaos Tools plugin include using a plugin array to declare a plugin.
+ */
+
+/**
+ * Plugin array plugin definition.
+ */
+$plugin = array(
+ 'function' => 'ctools_plugin_test_plugin_array_not_cached_test',
+ 'handler' => array(
+ 'class' => 'ctoolsNotCachedPluginArray',
+ ),
+);
+
+/**
+ * Plugin array function plugin.
+ */
+function ctools_plugin_test_plugin_array_not_cached_test() {}
diff --git a/sites/all/modules/ctools/tests/plugins/not_cached/plugin_array2.inc b/sites/all/modules/ctools/tests/plugins/not_cached/plugin_array2.inc
new file mode 100644
index 000000000..06b817571
--- /dev/null
+++ b/sites/all/modules/ctools/tests/plugins/not_cached/plugin_array2.inc
@@ -0,0 +1,20 @@
+<?php
+/**
+ * @file
+ * Chaos Tools plugin include using a plugin array to declare a plugin.
+ */
+
+/**
+ * Plugin array plugin definition.
+ */
+$plugin = array(
+ 'function' => 'ctools_plugin_test_plugin_array2_not_cached_test',
+ 'handler' => array(
+ 'class' => 'ctoolsNotCachedPluginArray2',
+ ),
+);
+
+/**
+ * Plugin array function plugin.
+ */
+function ctools_plugin_test_plugin_array2_not_cached_test() {}
diff --git a/sites/all/modules/ctools/tests/plugins/not_cached/plugin_array_dne.inc b/sites/all/modules/ctools/tests/plugins/not_cached/plugin_array_dne.inc
new file mode 100644
index 000000000..1f19d2a44
--- /dev/null
+++ b/sites/all/modules/ctools/tests/plugins/not_cached/plugin_array_dne.inc
@@ -0,0 +1,15 @@
+<?php
+/**
+ * @file
+ * Chaos Tools plugin include using a plugin array to declare a plugin.
+ */
+
+/**
+ * Plugin array plugin definition.
+ */
+$plugin = array(
+ 'function' => 'ctools_plugin_test_plugin_array_dne_not_cached_test',
+ 'handler' => array(
+ 'class' => 'ctoolsNotCachedPluginArrayDNE',
+ ),
+);