- Patch #347959 by sun, Damien Tournoud, justinrandell, scor, chx: modules_installed() was broken during testing.
parent
0d9eedc8fb
commit
a5d180b9c0
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -547,8 +547,7 @@ abstract class DrupalTestCase {
|
|||
*
|
||||
* 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 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
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 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
$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();
|
||||
|
|
Loading…
Reference in New Issue