Commit e14a2639 authored by webchick's avatar webchick
Browse files

#577398 by boombatower: Fix SimpleTest temporary file handling, post-stream wrappers.

parent 8e38d459
......@@ -1079,12 +1079,17 @@ protected function setUp() {
// Create test directory ahead of installation so fatal errors and debug
// information can be logged during installation process.
$directory = $this->originalFileDirectory . '/simpletest/' . substr($db_prefix, 10);
file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
// Use temporary files directory with the same prefix as the database.
$public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($db_prefix, 10);
$private_files_directory = $public_files_directory . '/private';
// Create the directories
file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY);
// Log fatal errors.
ini_set('log_errors', 1);
ini_set('error_log', $directory . '/error.log');
ini_set('error_log', $public_files_directory . '/error.log');
// Reset all statics so that test is performed with a clean environment.
drupal_static_reset();
......@@ -1142,21 +1147,12 @@ protected function setUp() {
unset($GLOBALS['conf']['language_default']);
$language = language_default();
// Use the test mail class instead of the default mail handler class.
variable_set('mail_system', array('default-system' => 'TestingMailSystem'));
// Use temporary files directory with the same prefix as the database.
$public_files_directory = $this->originalFileDirectory . '/' . $db_prefix;
$private_files_directory = $public_files_directory . '/private';
// Set path variables
variable_set('file_public_path', $public_files_directory);
variable_set('file_private_path', $private_files_directory);
// Create the directories
$directory = file_directory_path('public');
file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY);
// Use the test mail class instead of the default mail handler class.
variable_set('mail_system', array('default-system' => 'TestingMailSystem'));
drupal_set_time_limit($this->timeLimit);
}
......@@ -1211,7 +1207,7 @@ protected function tearDown() {
if (preg_match('/simpletest\d+/', $db_prefix)) {
// Delete temporary files directory.
file_unmanaged_delete_recursive($this->originalFileDirectory . '/' . $db_prefix);
file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($db_prefix, 10));
// Remove all prefixed tables (all the tables in the schema).
$schema = drupal_get_schema(NULL, TRUE);
......
......@@ -444,11 +444,11 @@ function simpletest_clean_database() {
* Find all leftover temporary directories and remove them.
*/
function simpletest_clean_temporary_directories() {
$files = scandir('public://');
$files = scandir('public://simpletest');
$count = 0;
foreach ($files as $file) {
$path = 'public://' . $file;
if (is_dir($path) && preg_match('/^simpletest\d+/', $file)) {
$path = 'public://simpletest/' . $file;
if (is_dir($path) && is_numeric($file)) {
file_unmanaged_delete_recursive($path);
$count++;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment