diff options
6 files changed, 72 insertions, 4 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 922fd094e..6a0ff7bc9 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -3167,10 +3167,13 @@ function _registry_check_code($type, $name = NULL) { // This function may get called when the default database is not active, but // there is no reason we'd ever want to not use the default database for // this query. - $file = Database::getConnection('default', 'default')->query("SELECT filename FROM {registry} WHERE name = :name AND type = :type", array( - ':name' => $name, - ':type' => $type, - )) + $file = Database::getConnection('default', 'default') + ->select('registry', 'r', array('target' => 'default')) + ->fields('r', array('filename')) + // Use LIKE here to make the query case-insensitive. + ->condition('r.name', db_like($name), 'LIKE') + ->condition('r.type', $type) + ->execute() ->fetchField(); // Flag that we've run a lookup query and need to update the cache. diff --git a/modules/simpletest/tests/bootstrap.test b/modules/simpletest/tests/bootstrap.test index 3489062f1..ece1cd9e9 100644 --- a/modules/simpletest/tests/bootstrap.test +++ b/modules/simpletest/tests/bootstrap.test @@ -289,6 +289,35 @@ class BootstrapVariableTestCase extends DrupalWebTestCase { } /** + * Tests the auto-loading behavior of the code registry. + */ +class BootstrapAutoloadTestCase extends DrupalWebTestCase { + + public static function getInfo() { + return array( + 'name' => 'Code registry', + 'description' => 'Test that the code registry functions correctly.', + 'group' => 'Bootstrap', + ); + } + + function setUp() { + parent::setUp('drupal_autoload_test'); + } + + /** + * Tests that autoloader name matching is not case sensitive. + */ + function testAutoloadCase() { + // Test interface autoloader. + $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 hook_boot() and hook_exit(). */ class HookBootExitTestCase extends DrupalWebTestCase { diff --git a/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.info b/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.info new file mode 100644 index 000000000..4660de367 --- /dev/null +++ b/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.info @@ -0,0 +1,8 @@ +name = "Drupal code registry test" +description = "Support module for testing the code registry." +files[] = drupal_autoload_test_interface.inc +files[] = drupal_autoload_test_class.inc +package = Testing +version = VERSION +core = 7.x +hidden = TRUE diff --git a/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.module b/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.module new file mode 100644 index 000000000..37aa94eb8 --- /dev/null +++ b/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.module @@ -0,0 +1,6 @@ +<?php + +/** + * @file + * Test module to check code registry. + */ diff --git a/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test_class.inc b/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test_class.inc new file mode 100644 index 000000000..afd72fe64 --- /dev/null +++ b/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test_class.inc @@ -0,0 +1,11 @@ +<?php + +/** + * @file + * Test classes for code registry testing. + */ + +/** + * This class is empty because we only care if Drupal can find it. + */ +class DrupalAutoloadTestClass implements DrupalAutoloadTestInterface {} diff --git a/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test_interface.inc b/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test_interface.inc new file mode 100644 index 000000000..d20ce5234 --- /dev/null +++ b/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test_interface.inc @@ -0,0 +1,11 @@ +<?php + +/** + * @file + * Test interfaces for code registry testing. + */ + +/** + * This interface is empty because we only care if Drupal can find it. + */ +interface DrupalAutoloadTestInterface {} |