mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
42 lines
857 B
PHP
42 lines
857 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pest\Actions;
|
|
|
|
use Pest\Exceptions\FileOrFolderNotFound;
|
|
use Pest\TestSuite;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
final class ValidatesEnvironment
|
|
{
|
|
/**
|
|
* The need files on the root path.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
private const NEEDED_FILES = [
|
|
'composer.json',
|
|
];
|
|
|
|
/**
|
|
* Validates the environment.
|
|
*/
|
|
public static function in(TestSuite $testSuite): void
|
|
{
|
|
$rootPath = $testSuite->rootPath;
|
|
|
|
$exists = function ($neededFile) use ($rootPath): bool {
|
|
return file_exists(sprintf('%s%s%s', $rootPath, DIRECTORY_SEPARATOR, $neededFile));
|
|
};
|
|
|
|
foreach (self::NEEDED_FILES as $neededFile) {
|
|
if (!$exists($neededFile)) {
|
|
throw new FileOrFolderNotFound($neededFile);
|
|
}
|
|
}
|
|
}
|
|
}
|