Commit 55092dc7 authored by catch's avatar catch

Issue #2059313 by StephaneQ, giammi: Cache simpletest_phpunit_get_available_tests().

parent 375a7081
......@@ -589,6 +589,7 @@ function simpletest_clean_environment() {
// Detect test classes that have been added, renamed or deleted.
cache()->delete('simpletest');
cache()->delete('simpletest_phpunit');
}
/**
......@@ -718,6 +719,12 @@ function simpletest_library_info() {
* If TRUE, returns a flat array of class names only.
*/
function simpletest_phpunit_get_available_tests() {
// Try to load the class names array from cache.
if ($cache = \Drupal::cache()->get('simpletest_phpunit')) {
$test_classes = $cache->data;
}
else {
// If there was no cached data available we have to find the tests.
// Load the PHPUnit configuration file, which tells us where to find the
// tests.
$phpunit_config = simpletest_phpunit_configuration_filepath();
......@@ -725,7 +732,7 @@ function simpletest_phpunit_get_available_tests() {
// Find all the tests and get a list of unique class names.
$test_suite = $configuration->getTestSuiteConfiguration(NULL);
$test_classes = array();
foreach ($test_suite AS $test) {
foreach ($test_suite as $test) {
// PHPUnit returns a warning message if something is wrong with a test,
// throw an exception to avoid an error when trying to call getInfo() on
// this.
......@@ -739,6 +746,10 @@ function simpletest_phpunit_get_available_tests() {
}
}
// Since we have recalculated, we now need to store the new data into cache.
\Drupal::cache()->set('simpletest_phpunit', $test_classes);
}
return $test_classes;
}
......
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