diff --git a/includes/module.inc b/includes/module.inc index f5f66d7e9e5a5fca89c975a2b805fc397f1848f7..0450e6b5bbb6cc98eed71bf9145772425f1f1e5a 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -293,12 +293,11 @@ function module_load_all_includes($type, $name = NULL) { * If TRUE, dependencies will automatically be added and enabled in the * correct order. This incurs a significant performance cost, so use FALSE * if you know $module_list is already complete and in the correct order. - * @param $disable_modules_installed_hook - * Normally just testing wants to set this to TRUE. + * * @return * FALSE if one or more dependencies are missing, TRUE otherwise. */ -function module_enable($module_list, $enable_dependencies = TRUE, $disable_modules_installed_hook = FALSE) { +function module_enable($module_list, $enable_dependencies = TRUE) { if ($enable_dependencies) { // Get all module data so we can find dependencies and sort. $module_data = system_rebuild_module_data(); @@ -392,7 +391,7 @@ function module_enable($module_list, $enable_dependencies = TRUE, $disable_modul } // If any modules were newly installed, invoke hook_modules_installed(). - if (!$disable_modules_installed_hook && !empty($modules_installed)) { + if (!empty($modules_installed)) { module_invoke_all('modules_installed', $modules_installed); } diff --git a/includes/theme.inc b/includes/theme.inc index 87ab3c9ffa47e7cc95bd975b8affd1189a0b3ef2..ebee7255a6ea5406007e1aac0426d116c87d68b6 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -561,7 +561,7 @@ function _theme_build_registry($theme, $base_theme, $theme_engine) { * - 'base theme': The name of the base theme. */ function list_themes($refresh = FALSE) { - static $list = array(); + $list = &drupal_static(__FUNCTION__, array()); if ($refresh) { $list = array(); diff --git a/modules/rdf/rdf.module b/modules/rdf/rdf.module index edd4f1007def5cd7d64c2ac7efe6ae280185f792..01a3f8c7af724f11a486dc4bdc416ce5c5a5d4e5 100644 --- a/modules/rdf/rdf.module +++ b/modules/rdf/rdf.module @@ -267,10 +267,6 @@ function rdf_rdfa_attributes($mapping, $data = NULL) { * database so that they can be altered via the RDF CRUD mapping API. */ function rdf_modules_installed($modules) { - // We need to clear the caches of entity_info as this is not done right - // during the tests. see http://drupal.org/node/594234 - entity_info_cache_clear(); - foreach ($modules as $module) { $function = $module . '_rdf_mapping'; if (function_exists($function)) { diff --git a/modules/rdf/rdf.test b/modules/rdf/rdf.test index 908cfec4c0c0abd7f6daeb202001edd615984344..fa0c8c58ff260f312c286826fc5ade1e0610390d 100644 --- a/modules/rdf/rdf.test +++ b/modules/rdf/rdf.test @@ -17,9 +17,6 @@ class RdfMappingHookTestCase extends DrupalWebTestCase { function setUp() { parent::setUp('rdf', 'rdf_test', 'field_test'); - // We need to trigger rdf_modules_installed() because - // hook_modules_installed() is not automatically invoked during testing. - rdf_modules_installed(array('rdf_test')); } /** @@ -53,7 +50,6 @@ class RdfMarkupTestCase extends DrupalWebTestCase { function setUp() { parent::setUp('rdf', 'field_test', 'rdf_test'); - rdf_modules_installed(array('field_test', 'rdf_test')); } /** @@ -193,31 +189,54 @@ class RdfCrudTestCase extends DrupalWebTestCase { * Test inserting, loading, updating, and deleting RDF mappings. */ function testCRUD() { - $test_mapping = rdf_test_rdf_mapping(); - // Verify loading of a default mapping. - $this->assertFalse(count(_rdf_mapping_load('test_entity', 'test_bundle')), t('Default mapping was found.')); + $mapping = _rdf_mapping_load('test_entity', 'test_bundle'); + $this->assertTrue(count($mapping), t('Default mapping was found.')); // Verify saving a mapping. - $mapping = (array) $test_mapping; - rdf_mapping_save($mapping[0]); - $this->assertEqual($mapping[0]['mapping'], $test_mapping[0]['mapping'], t('Saved mapping equals default mapping.')); - $this->assertTrue(rdf_mapping_save($mapping[1]) === SAVED_NEW, t('Second mapping was inserted.')); - $this->assertEqual($mapping[1]['mapping'], _rdf_mapping_load($test_mapping[1]['type'], $test_mapping[1]['bundle']), t('Second mapping equals default mapping.')); + $mapping = array( + 'type' => 'crud_test_entity', + 'bundle' => 'crud_test_bundle', + 'mapping' => array( + 'rdftype' => array('sioc:Post'), + 'title' => array( + 'predicates' => array('dc:title'), + ), + 'uid' => array( + 'predicates' => array('sioc:has_creator', 'dc:creator'), + 'type' => 'rel', + ), + ), + ); + $this->assertTrue(rdf_mapping_save($mapping) === SAVED_NEW, t('Mapping was saved.')); + + // Read the raw record from the {rdf_mapping} table. + $result = db_query('SELECT * FROM {rdf_mapping} WHERE type = :type AND bundle = :bundle', array(':type' => $mapping['type'], ':bundle' => $mapping['bundle'])); + $stored_mapping = $result->fetchAssoc(); + $stored_mapping['mapping'] = unserialize($stored_mapping['mapping']); + $this->assertEqual($mapping, $stored_mapping, t('Mapping was stored properly in the {rdf_mapping} table.')); // Verify loading of saved mapping. - $this->assertEqual($mapping[0]['mapping'], _rdf_mapping_load($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Saved mapping equals loaded default mapping.')); + $this->assertEqual($mapping['mapping'], _rdf_mapping_load($mapping['type'], $mapping['bundle']), t('Saved mapping loaded successfully.')); // Verify updating of mapping. - $mapping[0]['mapping']['boofar'] = array( - 'predicates' => array('foo:bar'), + $mapping['mapping']['title'] = array( + 'predicates' => array('dc2:bar2'), ); - $this->assertTrue(rdf_mapping_save($mapping[0]) === SAVED_UPDATED, t('Mapping was updated.')); - $this->assertEqual($mapping[0]['mapping'], _rdf_mapping_load($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Updated and loaded mapping are equal.')); + $this->assertTrue(rdf_mapping_save($mapping) === SAVED_UPDATED, t('Mapping was updated.')); + + // Read the raw record from the {rdf_mapping} table. + $result = db_query('SELECT * FROM {rdf_mapping} WHERE type = :type AND bundle = :bundle', array(':type' => $mapping['type'], ':bundle' => $mapping['bundle'])); + $stored_mapping = $result->fetchAssoc(); + $stored_mapping['mapping'] = unserialize($stored_mapping['mapping']); + $this->assertEqual($mapping, $stored_mapping, t('Updated mapping was stored properly in the {rdf_mapping} table.')); + + // Verify loading of saved mapping. + $this->assertEqual($mapping['mapping'], _rdf_mapping_load($mapping['type'], $mapping['bundle']), t('Saved mapping loaded successfully.')); // Verify deleting of mapping. - $this->assertTrue(rdf_mapping_delete($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Mapping was deleted.')); - $this->assertFalse(_rdf_mapping_load($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Deleted mapping is no longer found.')); + $this->assertTrue(rdf_mapping_delete($mapping['type'], $mapping['bundle']), t('Mapping was deleted.')); + $this->assertFalse(_rdf_mapping_load($mapping['type'], $mapping['bundle']), t('Deleted mapping is no longer found in the database.')); } } @@ -232,12 +251,6 @@ class RdfMappingDefinitionTestCase extends DrupalWebTestCase { function setUp() { parent::setUp('rdf', 'rdf_test', 'blog'); - // We need to trigger rdf_modules_installed() because - // hook_modules_installed() is not automatically invoked during testing. - rdf_modules_installed(array('rdf_test', 'node')); - // entity_info caches must be cleared during testing. This is done - // automatically during the manual installation. - entity_info_cache_clear(); } /** @@ -327,13 +340,6 @@ class RdfTrackerAttributesTestCase extends DrupalWebTestCase { function setUp() { parent::setUp('rdf', 'rdf_test', 'tracker'); - // We need to trigger rdf_modules_installed() because - // hook_modules_installed() is not automatically invoked during testing. - rdf_modules_installed(array('rdf_test', 'node')); - // entity_info caches must be cleared during testing. This is done - // automatically during the manual installation. - cache_clear_all('entity_info', 'cache'); - drupal_static_reset('entity_get_info'); // Enable anonymous posting of content. user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array( 'create article content' => TRUE, diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 5a364f9b9aa600bff5e7723816c78dc83f468cb4..d07e0b2f1d7890e763af15752ea71f49660faa07 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -547,8 +547,7 @@ public static function randomName($length = 8) { * * These tests can not access the database nor files. Calling any Drupal * function that needs the database will throw exceptions. These include - * watchdog(), function_exists(), module_implements(), - * module_invoke_all() etc. + * watchdog(), module_implements(), module_invoke_all() etc. */ class DrupalUnitTestCase extends DrupalTestCase { @@ -1124,8 +1123,7 @@ protected function setUp() { ini_set('log_errors', 1); ini_set('error_log', $public_files_directory . '/error.log'); - // Reset all statics and variables so that test is performed with a clean - // environment. + // Reset all statics and variables to perform tests in a clean environment. $conf = array(); drupal_static_reset(); @@ -1139,32 +1137,30 @@ protected function setUp() { $profile_details = install_profile_info('standard', 'en'); // Install the modules specified by the default profile. - module_enable($profile_details['dependencies'], FALSE, TRUE); - - drupal_static_reset('_node_types_build'); + module_enable($profile_details['dependencies'], FALSE); + // Install modules needed for this test. if ($modules = func_get_args()) { - // Install modules needed for this test. - module_enable($modules, TRUE, TRUE); + module_enable($modules, TRUE); } - // Because the schema is static cached, we need to flush - // it between each run. If we don't, then it will contain - // stale data for the previous run's database prefix and all - // calls to it will fail. - drupal_get_schema(NULL, TRUE); - // Run default profile tasks. - $install_state = array(); - module_enable(array('standard'), FALSE, TRUE); + module_enable(array('standard'), FALSE); // Rebuild caches. - node_types_rebuild(); + drupal_static_reset(); + drupal_flush_all_caches(); + + // Register actions declared by any modules. actions_synchronize(); - _drupal_flush_css_js(); + + // Reload global $conf array and permissions. $this->refreshVariables(); $this->checkPermissions(array(), TRUE); + // Reset statically cached schema for new database prefix. + drupal_get_schema(NULL, TRUE); + // Run cron once in that environment, as install.php does at the end of // the installation process. drupal_cron_run();