function TestFileParser::getTestListFromFile

Same name in other branches
  1. 9 core/lib/Drupal/Core/Test/RunTests/TestFileParser.php \Drupal\Core\Test\RunTests\TestFileParser::getTestListFromFile()
  2. 10 core/lib/Drupal/Core/Test/RunTests/TestFileParser.php \Drupal\Core\Test\RunTests\TestFileParser::getTestListFromFile()
  3. 11.x core/lib/Drupal/Core/Test/RunTests/TestFileParser.php \Drupal\Core\Test\RunTests\TestFileParser::getTestListFromFile()

Gets the classes from a PHP file.

Parameters

string $file: The path to the file to parse.

Return value

string[] Array of fully qualified class names within the PHP file.

File

core/lib/Drupal/Core/Test/RunTests/TestFileParser.php, line 24

Class

TestFileParser
Parses class names from PHP files without loading them.

Namespace

Drupal\Core\Test\RunTests

Code

public function getTestListFromFile($file) {
    $test_list = $this->parseContents(file_get_contents($file));
    return array_filter($test_list, function ($class) {
        return is_subclass_of($class, TestCase::class) || is_subclass_of($class, TestBase::class);
    });
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.