Run the generated Pest suite without a Tests autoload mapping (#2054)

Co-authored-by: haranishi <223786623+haranishi@users.noreply.github.com>
This commit is contained in:
Ikki Nishihara
2026-11-20 04:43:13 +09:00
committed by GitHub
parent fcd408b895
commit bb91916d0d
4 changed files with 18 additions and 4 deletions
+11 -1
View File
@@ -4,7 +4,7 @@ declare(strict_types=1);
use Symfony\Component\Process\Process;
test('init creates a suite when the tests directory is missing', function (): void {
test('init creates a runnable suite when the tests directory is missing', function (): void {
$root = makeInitProject();
try {
@@ -17,6 +17,11 @@ test('init creates a suite when the tests directory is missing', function (): vo
->and($root.DIRECTORY_SEPARATOR.'tests'.DIRECTORY_SEPARATOR.'Pest.php')->toBeFile()
->and($root.DIRECTORY_SEPARATOR.'tests'.DIRECTORY_SEPARATOR.'TestCase.php')->toBeFile()
->and($root.DIRECTORY_SEPARATOR.'tests'.DIRECTORY_SEPARATOR.'Unit'.DIRECTORY_SEPARATOR.'ExampleTest.php')->toBeFile();
$suite = runInitProject($root, '--colors=never');
expect($suite->getExitCode())->toBe(0)
->and($suite->getOutput())->toContain('2 passed (2 assertions)');
} finally {
removeInitProject($root);
}
@@ -85,6 +90,11 @@ function makeInitProject(): string
true,
);
file_put_contents(
$root.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php',
"<?php\n\nreturn require_once {$autoload};\n",
);
file_put_contents($root.DIRECTORY_SEPARATOR.'run.php', <<<PHP
<?php