summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2015-10-12 23:32:29 -0400
committerDavid Rothstein <drothstein@gmail.com>2015-10-12 23:32:29 -0400
commit183a425c551969d4f56b04766fca82819a2a7b15 (patch)
tree08a4a9651b71c031133e2c7b508bc908793d62c9 /modules
parentf12effc70c835e77bfdea394214df9247533d319 (diff)
downloadbrdo-183a425c551969d4f56b04766fca82819a2a7b15.tar.gz
brdo-183a425c551969d4f56b04766fca82819a2a7b15.tar.bz2
Issue #2508055 by Dave Reid, David_Rothstein, hussainweb: Add support for autoloading Traits
Diffstat (limited to 'modules')
-rw-r--r--modules/simpletest/tests/bootstrap.test4
-rw-r--r--modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.module16
-rw-r--r--modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test_trait.sh16
3 files changed, 36 insertions, 0 deletions
diff --git a/modules/simpletest/tests/bootstrap.test b/modules/simpletest/tests/bootstrap.test
index ece1cd9e9..d46c6ec8f 100644
--- a/modules/simpletest/tests/bootstrap.test
+++ b/modules/simpletest/tests/bootstrap.test
@@ -313,6 +313,10 @@ class BootstrapAutoloadTestCase extends DrupalWebTestCase {
$this->assertTrue(drupal_autoload_interface('drupalautoloadtestinterface'), 'drupal_autoload_interface() recognizes <em>DrupalAutoloadTestInterface</em> in lower case.');
// Test class autoloader.
$this->assertTrue(drupal_autoload_class('drupalautoloadtestclass'), 'drupal_autoload_class() recognizes <em>DrupalAutoloadTestClass</em> in lower case.');
+ // Test trait autoloader.
+ if (version_compare(PHP_VERSION, '5.4') >= 0) {
+ $this->assertTrue(drupal_autoload_trait('drupalautoloadtesttrait'), 'drupal_autoload_trait() recognizes <em>DrupalAutoloadTestTrait</em> in lower case.');
+ }
}
}
diff --git a/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.module b/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.module
index 37aa94eb8..edd5d77cb 100644
--- a/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.module
+++ b/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.module
@@ -4,3 +4,19 @@
* @file
* Test module to check code registry.
*/
+
+/**
+ * Implements hook_registry_files_alter().
+ */
+function drupal_autoload_test_registry_files_alter(&$files, $modules) {
+ foreach ($modules as $module) {
+ // Add the drupal_autoload_test_trait.sh file to the registry when PHP 5.4+
+ // is being used.
+ if ($module->name == 'drupal_autoload_test' && version_compare(PHP_VERSION, '5.4') >= 0) {
+ $files["$module->dir/drupal_autoload_test_trait.sh"] = array(
+ 'module' => $module->name,
+ 'weight' => $module->weight,
+ );
+ }
+ }
+}
diff --git a/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test_trait.sh b/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test_trait.sh
new file mode 100644
index 000000000..69ce9ec08
--- /dev/null
+++ b/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test_trait.sh
@@ -0,0 +1,16 @@
+<?php
+
+/**
+ * @file
+ * Test traits for code registry testing.
+ *
+ * This file has a non-standard extension to prevent PHP < 5.4 testbots from
+ * trying to run a syntax check on it.
+ * @todo Use a standard extension once the testbots allow it. See
+ * https://www.drupal.org/node/2589649.
+ */
+
+/**
+ * This trait is empty because we only care if Drupal can find it.
+ */
+trait DrupalAutoloadTestTrait {}