diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index 8a78058..1d291c7 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -645,6 +645,10 @@ function simpletest_generate_file($filename, $width, $lines, $type = 'binary-tex * Removes all temporary database tables and directories. */ function simpletest_clean_environment() { + // We have to register the test namespaces so that core's test classes are + // accessible to these functions. + // @todo: Remove/refactor in https://www.drupal.org/node/2800267 + \Drupal::service('test_discovery')->registerTestNamespaces(); simpletest_clean_database(); simpletest_clean_temporary_directories(); if (\Drupal::config('simpletest.settings')->get('clear_results')) { @@ -694,7 +698,7 @@ function simpletest_clean_temporary_directories() { foreach ($files as $file) { if ($file[0] != '.') { $path = DRUPAL_ROOT . '/sites/simpletest/' . $file; - file_unmanaged_delete_recursive($path, 'simpletest_temp_directory_pre_delete_callback'); + file_unmanaged_delete_recursive($path, array('Drupal\simpletest\TestBase', 'filePreDeleteCallback')); $count++; } } @@ -860,17 +864,3 @@ function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcas ); return $record; } - -/** - * Ensures test files are deletable within file_unmanaged_delete_recursive(). - * - * Some tests chmod generated files to be read only. During - * simpletest_clean_environment() and other cleanup operations, these files - * need to get deleted too. - * - * @param string $path - * The path to be deleted. - */ -function simpletest_temp_directory_pre_delete_callback($path) { - chmod($path, 0700); -} diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php index b3f8ee0..039ddfc 100644 --- a/core/modules/simpletest/src/TestBase.php +++ b/core/modules/simpletest/src/TestBase.php @@ -1509,9 +1509,14 @@ public static function generatePermutations($parameters) { * Some tests chmod generated files to be read only. During * TestBase::restoreEnvironment() and other cleanup operations, these files * need to get deleted too. + * + * @param string $path + * The path about to be deleted. + * + * @todo Remove/refactor in https://www.drupal.org/node/2800267 */ public static function filePreDeleteCallback($path) { - simpletest_temp_directory_pre_delete_callback($path); + chmod($path, 0700); } /**