- Patch #260882 by boombatower: refresh variables after install and page requests. This actually fixes one failure.
parent
d952784de6
commit
ddea5c448d
|
|
@ -36,8 +36,6 @@ class ContactTestCase extends DrupalWebTestCase {
|
|||
$this->drupalPost('admin/build/contact/settings', $edit, t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'), t('Setting successfully saved.'));
|
||||
|
||||
$this->reloadVariables();
|
||||
|
||||
// Delete old categories to ensure that new categories are used.
|
||||
$this->deleteCategories();
|
||||
|
||||
|
|
@ -127,7 +125,6 @@ class ContactTestCase extends DrupalWebTestCase {
|
|||
|
||||
// Reload variables.
|
||||
$this->drupalLogout();
|
||||
$this->reloadVariables();
|
||||
|
||||
// Create web users and attempt to use personal contact forms with default set to true.
|
||||
$web_user1 = $this->drupalCreateUser(array());
|
||||
|
|
@ -156,7 +153,6 @@ class ContactTestCase extends DrupalWebTestCase {
|
|||
|
||||
// Reload variables.
|
||||
$this->drupalLogout();
|
||||
$this->reloadVariables();
|
||||
|
||||
// Create web users and attempt to use personal contact forms with default set to false.
|
||||
$web_user3 = $this->drupalCreateUser(array());
|
||||
|
|
@ -252,15 +248,4 @@ class ContactTestCase extends DrupalWebTestCase {
|
|||
$this->drupalPost('admin/user/permissions', $edit, t('Save permissions'));
|
||||
$this->assertText(t('The changes have been saved.'), t(' [permission] Saved changes.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload variables table.
|
||||
*/
|
||||
function reloadVariables() {
|
||||
global $conf;
|
||||
|
||||
cache_clear_all('variables', 'cache');
|
||||
$conf = variable_init();
|
||||
$this->assertTrue($conf, t('Variables reloaded.'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,8 +55,7 @@ class DBLogTestCase extends DrupalWebTestCase {
|
|||
$edit['dblog_row_limit'] = $row_limit;
|
||||
$this->drupalPost('admin/settings/logging/dblog', $edit, t('Save configuration'));
|
||||
$this->assertResponse(200);
|
||||
// Reload variable cache (since the global $conf array was changed in another "process" when the settings page above was posted).
|
||||
$this->reloadVariables();
|
||||
|
||||
// Check row limit variable.
|
||||
$current_limit = variable_get('dblog_row_limit', 1000);
|
||||
$this->assertTrue($current_limit == $row_limit, t('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit)));
|
||||
|
|
@ -356,15 +355,4 @@ class DBLogTestCase extends DrupalWebTestCase {
|
|||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload variables table.
|
||||
*/
|
||||
private function reloadVariables() {
|
||||
global $conf;
|
||||
|
||||
cache_clear_all('variables', 'cache');
|
||||
$conf = variable_init();
|
||||
$this->assertTrue($conf, t('Variables reloaded'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ class SearchBikeShed extends DrupalWebTestCase {
|
|||
// Create user.
|
||||
$this->searching_user = $this->drupalCreateUser(array('search content'));
|
||||
}
|
||||
|
||||
|
||||
function testFailedSearch() {
|
||||
$this->drupalLogin($this->searching_user);
|
||||
$this->drupalGet('search/node');
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ class DrupalWebTestCase extends UnitTestCase {
|
|||
protected $cookie_file = NULL;
|
||||
// Overwrite this any time to supply cURL options as necessary,
|
||||
// DrupalTestCase itself never sets this but always obeys whats set.
|
||||
protected $curl_options = array();
|
||||
protected $curl_options = array();
|
||||
protected $db_prefix_original;
|
||||
protected $original_file_directory;
|
||||
|
||||
/**
|
||||
|
|
@ -356,20 +357,35 @@ class DrupalWebTestCase extends UnitTestCase {
|
|||
*/
|
||||
function setUp() {
|
||||
global $db_prefix;
|
||||
|
||||
// Store necessary current values before switching to prefixed database.
|
||||
$this->db_prefix_original = $db_prefix;
|
||||
$clean_url_original = variable_get('clean_url', 0);
|
||||
|
||||
// Generate temporary prefixed database to ensure that tests have a clean starting point.
|
||||
$db_prefix = 'simpletest' . mt_rand(1000, 1000000);
|
||||
include_once './includes/install.inc';
|
||||
drupal_install_system();
|
||||
|
||||
// Add the specified modules to the list of modules in the default profile.
|
||||
$modules = array_unique(array_merge(func_get_args(), drupal_verify_profile('default', 'en')));
|
||||
drupal_install_modules($modules);
|
||||
|
||||
// Store the list of modules for use in subsequent drupalModuleEnable calls.
|
||||
$this->_modules = drupal_map_assoc($modules);
|
||||
$this->_modules['system'] = 'system';
|
||||
|
||||
// Run defualt profile tasks.
|
||||
$task = 'profile';
|
||||
default_profile_tasks($task, '');
|
||||
|
||||
// Rebuild caches.
|
||||
menu_rebuild();
|
||||
actions_synchronize();
|
||||
_drupal_flush_css_js();
|
||||
$this->refreshVariables();
|
||||
|
||||
// Restore necessary variables.
|
||||
variable_set('install_profile', 'default');
|
||||
variable_set('install_task', 'profile-finished');
|
||||
variable_set('clean_url', $clean_url_original);
|
||||
|
|
@ -378,9 +394,28 @@ class DrupalWebTestCase extends UnitTestCase {
|
|||
$this->original_file_directory = file_directory_path();
|
||||
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
|
||||
file_check_directory(file_directory_path(), TRUE); // Create the files directory.
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the in-memory set of variables. Useful after a page request is made
|
||||
* that changes a variable in a different thread.
|
||||
*
|
||||
* In other words calling a settings page with $this->drupalPost() with a changed
|
||||
* value would update a variable to reflect that change, but in the thread that
|
||||
* made the call (thread running the test) the changed variable would not be
|
||||
* picked up.
|
||||
*
|
||||
* This method clears the variables cache and loads a fresh copy from the database
|
||||
* to ensure that the most up-to-date set of variables is loaded.
|
||||
*/
|
||||
function refreshVariables() {
|
||||
global $conf;
|
||||
cache_clear_all('variables', 'cache');
|
||||
$conf = variable_init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete created files and temporary files directory, delete the tables created by setUp(),
|
||||
* and reset the database prefix.
|
||||
|
|
@ -392,13 +427,20 @@ class DrupalWebTestCase extends UnitTestCase {
|
|||
simpletest_clean_temporary_directory(file_directory_path());
|
||||
variable_set('file_directory_path', $this->original_file_directory);
|
||||
|
||||
// Remove all prefixed tables (all the tables in the schema).
|
||||
$schema = drupal_get_schema(NULL, TRUE);
|
||||
$ret = array();
|
||||
foreach ($schema as $name => $table) {
|
||||
db_drop_table($ret, $name);
|
||||
}
|
||||
|
||||
// Return the database prefix to the original.
|
||||
$db_prefix = $this->db_prefix_original;
|
||||
|
||||
// Ensure that the internal logged in variable is reset.
|
||||
$this->_logged_in = FALSE;
|
||||
|
||||
// Close the CURL handler.
|
||||
$this->curlClose();
|
||||
}
|
||||
parent::tearDown();
|
||||
|
|
@ -510,7 +552,9 @@ class DrupalWebTestCase extends UnitTestCase {
|
|||
// We re-using a CURL connection here. If that connection still has certain
|
||||
// options set, it might change the GET into a POST. Make sure we clear out
|
||||
// previous options.
|
||||
return $this->curlExec(array(CURLOPT_URL => url($path, $options), CURLOPT_POST => FALSE, CURLOPT_POSTFIELDS => array()));
|
||||
$out = $this->curlExec(array(CURLOPT_URL => url($path, $options), CURLOPT_POST => FALSE, CURLOPT_POSTFIELDS => array()));
|
||||
$this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up.
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -579,7 +623,9 @@ class DrupalWebTestCase extends UnitTestCase {
|
|||
}
|
||||
$post = implode('&', $post);
|
||||
}
|
||||
return $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POSTFIELDS => $post, CURLOPT_POST => TRUE));
|
||||
$out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POSTFIELDS => $post, CURLOPT_POST => TRUE));
|
||||
$this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up.
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
// We have not found a form which contained all fields of $edit.
|
||||
|
|
|
|||
Loading…
Reference in New Issue