diff --git includes/bootstrap.inc includes/bootstrap.inc index be0a471..b47ac36 100644 --- includes/bootstrap.inc +++ includes/bootstrap.inc @@ -677,7 +677,7 @@ function drupal_get_filename($type, $name, $filename = NULL) { try { if (function_exists('db_query')) { $file = db_query("SELECT filename FROM {system} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))->fetchField(); - if (file_exists(DRUPAL_ROOT . '/' . $file)) { + if (!empty($file) && file_exists(DRUPAL_ROOT . '/' . $file)) { $files[$type][$name] = $file; } } diff --git modules/simpletest/tests/common.test modules/simpletest/tests/common.test index ca29e11..59d1def 100644 --- modules/simpletest/tests/common.test +++ modules/simpletest/tests/common.test @@ -2079,6 +2079,53 @@ class DrupalSystemListingTestCase extends DrupalWebTestCase { } } + +/** + * Tests for the drupal_get_path() function. + */ +class DrupalGetPathUnitTest extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Drupal get path', + 'description' => 'Perform unit tests on the drupal_get_path() function.', + 'group' => 'System', + ); + } + + /** + * Tests that drupal_get_path() function returns sensible results. + */ + function testDrupalGetPath() { + $paths = array( + array( + 'type' => 'theme', + 'name' => 'test_theme', + 'expected' => 'themes/tests/test_theme', + ), + array( + 'type' => 'theme_engine', + 'name' => 'phptemplate', + 'expected' => 'themes/engines/phptemplate', + ), + array( + 'type' => 'module', + 'name' => 'simpletest', + 'expected' => 'modules/simpletest', + ), + array( + 'type' => 'profile', + 'name' => 'standard', + 'expected' => 'profiles/standard', + ), + ); + + foreach ($paths as $path) { + $this->assertEqual(drupal_get_path($path['type'], $path['name']), $path['expected'], t('Component @name of type @type was found at @path', array('@name' => $path['name'], '@type' => $path['type'], '@path' => $path['expected']))); + } + + } +} + /** * Tests for the format_date() function. */