function Loader::testSuite
1 call to Loader::testSuite()
- Loader::load in vendor/
phpunit/ phpunit/ src/ TextUI/ Configuration/ Xml/ Loader.php
File
-
vendor/
phpunit/ phpunit/ src/ TextUI/ Configuration/ Xml/ Loader.php, line 901
Class
- Loader
- @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Namespace
PHPUnit\TextUI\XmlConfigurationCode
private function testSuite(string $filename, DOMXPath $xpath) : TestSuiteCollection {
$testSuites = [];
foreach ($this->getTestSuiteElements($xpath) as $element) {
$exclude = [];
foreach ($element->getElementsByTagName('exclude') as $excludeNode) {
$excludeFile = $excludeNode->textContent;
if ($excludeFile) {
$exclude[] = new File($this->toAbsolutePath($filename, $excludeFile));
}
}
$directories = [];
foreach ($element->getElementsByTagName('directory') as $directoryNode) {
assert($directoryNode instanceof DOMElement);
$directory = $directoryNode->textContent;
if (empty($directory)) {
continue;
}
$prefix = '';
if ($directoryNode->hasAttribute('prefix')) {
$prefix = $directoryNode->getAttribute('prefix');
}
$suffix = 'Test.php';
if ($directoryNode->hasAttribute('suffix')) {
$suffix = $directoryNode->getAttribute('suffix');
}
$phpVersion = PHP_VERSION;
if ($directoryNode->hasAttribute('phpVersion')) {
$phpVersion = $directoryNode->getAttribute('phpVersion');
}
$phpVersionOperator = new VersionComparisonOperator('>=');
if ($directoryNode->hasAttribute('phpVersionOperator')) {
$phpVersionOperator = new VersionComparisonOperator($directoryNode->getAttribute('phpVersionOperator'));
}
$directories[] = new TestDirectory($this->toAbsolutePath($filename, $directory), $prefix, $suffix, $phpVersion, $phpVersionOperator);
}
$files = [];
foreach ($element->getElementsByTagName('file') as $fileNode) {
assert($fileNode instanceof DOMElement);
$file = $fileNode->textContent;
if (empty($file)) {
continue;
}
$phpVersion = PHP_VERSION;
if ($fileNode->hasAttribute('phpVersion')) {
$phpVersion = $fileNode->getAttribute('phpVersion');
}
$phpVersionOperator = new VersionComparisonOperator('>=');
if ($fileNode->hasAttribute('phpVersionOperator')) {
$phpVersionOperator = new VersionComparisonOperator($fileNode->getAttribute('phpVersionOperator'));
}
$files[] = new TestFile($this->toAbsolutePath($filename, $file), $phpVersion, $phpVersionOperator);
}
$name = $element->getAttribute('name');
assert(!empty($name));
$testSuites[] = new TestSuiteConfiguration($name, TestDirectoryCollection::fromArray($directories), TestFileCollection::fromArray($files), FileCollection::fromArray($exclude));
}
return TestSuiteCollection::fromArray($testSuites);
}