mirror of
https://github.com/pestphp/pest.git
synced 2026-12-03 22:45:06 +01:00
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:
@@ -13,6 +13,10 @@ use Tests\TestCase;
|
||||
|
|
||||
*/
|
||||
|
||||
if (! class_exists(TestCase::class)) {
|
||||
require_once __DIR__.'/TestCase.php';
|
||||
}
|
||||
|
||||
pest()->extend(TestCase::class)->in('Feature');
|
||||
|
||||
/*
|
||||
|
||||
@@ -1302,7 +1302,7 @@
|
||||
… a "describe" group of tests → it is incompleted
|
||||
|
||||
PASS Tests\Features\Init
|
||||
✓ init creates a suite when the tests directory is missing
|
||||
✓ init creates a runnable suite when the tests directory is missing
|
||||
✓ init creates a suite when --init is not the first argument
|
||||
✓ init creates a suite when --init is passed with a value
|
||||
✓ a missing tests directory does not crash while resolving tia state
|
||||
@@ -2523,4 +2523,4 @@
|
||||
✓ pass with dataset with ('my-datas-set-value')
|
||||
✓ within describe → pass with dataset with ('my-datas-set-value')
|
||||
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 38 skipped, 1831 passed (4150 assertions)
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 38 skipped, 1831 passed (4152 assertions)
|
||||
+11
-1
@@ -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
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ test('parallel', function () use ($run): void {
|
||||
$output = implode("\n", array_slice(explode("\n", (string) $output), -10));
|
||||
$profileOutput = $run('tests/Fixtures/Suites/SuccessOnly.php', '--profile');
|
||||
|
||||
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 30 skipped, 1734 passed (3750 assertions)';
|
||||
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 30 skipped, 1734 passed (3752 assertions)';
|
||||
|
||||
expect($output)
|
||||
->toContain("Tests: {$expected}")
|
||||
|
||||
Reference in New Issue
Block a user