mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 08:17:22 +01:00
start ConfigLoader tests
This commit is contained in:
@ -13,14 +13,17 @@ use Throwable;
|
||||
*/
|
||||
final class ConfigLoader
|
||||
{
|
||||
private ?SimpleXMLElement $config = null;
|
||||
|
||||
/**
|
||||
* Default path if config loading went wrong.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private const DEFAULT_TESTS_PATH = 'tests';
|
||||
public const DEFAULT_TESTS_PATH = 'tests';
|
||||
|
||||
/**
|
||||
* XML tree of the PHPUnit configuration file.
|
||||
*/
|
||||
private ?SimpleXMLElement $config = null;
|
||||
|
||||
/**
|
||||
* Creates a new instance of the config loader.
|
||||
@ -62,6 +65,26 @@ final class ConfigLoader
|
||||
return is_dir($basePath) ? $basePath : self::DEFAULT_TESTS_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration file path.
|
||||
*/
|
||||
public function getConfigurationFilePath(): string|false
|
||||
{
|
||||
$candidates = [
|
||||
$this->rootPath . '/phpunit.xml',
|
||||
$this->rootPath . '/phpunit.dist.xml',
|
||||
$this->rootPath . '/phpunit.xml.dist',
|
||||
];
|
||||
|
||||
foreach ($candidates as $candidate) {
|
||||
if (is_file($candidate)) {
|
||||
return realpath($candidate);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the configuration file.
|
||||
*/
|
||||
@ -87,24 +110,4 @@ final class ConfigLoader
|
||||
// Restore the correct error reporting
|
||||
error_reporting($oldReportingLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration file path.
|
||||
*/
|
||||
private function getConfigurationFilePath(): string|false
|
||||
{
|
||||
$candidates = [
|
||||
$this->rootPath . '/phpunit.xml',
|
||||
$this->rootPath . '/phpunit.dist.xml',
|
||||
$this->rootPath . '/phpunit.xml.dist',
|
||||
];
|
||||
|
||||
foreach ($candidates as $candidate) {
|
||||
if (is_file($candidate)) {
|
||||
return realpath($candidate);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user