Commit cccc6206 authored by webchick's avatar webchick
Browse files

#304936 by drewish and boombatower: Fix SimpleTest copying/deletion.

parent 6da33f20
...@@ -28,12 +28,14 @@ function simpletest_install() { ...@@ -28,12 +28,14 @@ function simpletest_install() {
} }
// Copy other test files for consistency. // Copy other test files for consistency.
$files = file_scan_directory($path, '/(html|image|javascript|php|sql)-.*/'); $original = drupal_get_path('module', 'simpletest') . '/files';
if (count($files) == 0) { $files = file_scan_directory($original, '(html|image|javascript|php|sql)-.*');
$original = drupal_get_path('module', 'simpletest') . '/files';
// If there are more files in the original directory than the files directory, copy files.
if (count($files) > count(file_scan_directory($path, '(html|image|javascript|php|sql)-.*'))) {
$files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/'); $files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/');
foreach ($files as $file) { foreach ($files as $file) {
file_unmanaged_copy($file->filename, $path . '/' . $file->basename); file_copy($file->filename, $path, FILE_EXISTS_REPLACE);
} }
$generated = TRUE; $generated = TRUE;
} }
...@@ -92,11 +94,22 @@ function simpletest_get_file_count($directory, $filename) { ...@@ -92,11 +94,22 @@ function simpletest_get_file_count($directory, $filename) {
* Implementation of hook_uninstall(). * Implementation of hook_uninstall().
*/ */
function simpletest_uninstall() { function simpletest_uninstall() {
// Remove settings variables.
variable_del('simpletest_httpauth'); variable_del('simpletest_httpauth');
variable_del('simpletest_httpauth_username'); variable_del('simpletest_httpauth_username');
variable_del('simpletest_httpauth_pass'); variable_del('simpletest_httpauth_pass');
variable_del('simpletest_devel'); variable_del('simpletest_devel');
// Uninstall schema.
drupal_uninstall_schema('simpletest'); drupal_uninstall_schema('simpletest');
// Remove generated files.
$path = file_directory_path() . '/simpletest';
$files = file_scan_directory($path, '.*');
foreach ($files as $file) {
file_delete($file->filename);
}
rmdir($path);
} }
/** /**
......
Supports Markdown
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