mirror of
https://github.com/pestphp/pest.git
synced 2026-12-05 15:22:17 +01:00
2b2a1dab31
* fix(tia): record test files the graph does not know during a replay * fix(tia): keep coverage-scoped edges off test files the graph does not know --------- Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
70 lines
2.5 KiB
PHP
70 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Pest\Support\Coverage;
|
|
use Tests\Fixtures\Tia\Project;
|
|
|
|
afterEach(function (): void {
|
|
Project::destroyAll();
|
|
});
|
|
|
|
function addTestFileTheGraphDoesNotKnow(Project $project): void
|
|
{
|
|
$project->write('tests/Integration/WelcomeTest.php', <<<'PHP'
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Fixture\App\Greeter;
|
|
|
|
test('welcomes a visitor', function (): void {
|
|
expect((new Greeter)->greet('visitor'))->toBe('Hello, visitor!');
|
|
});
|
|
PHP);
|
|
|
|
$project->git()->commit('add a test file the graph does not know');
|
|
}
|
|
|
|
test('a replay records a test file the graph does not know', function (array $arguments): void {
|
|
$project = Project::make('master');
|
|
addTestFileTheGraphDoesNotKnow($project);
|
|
$project->seed('master');
|
|
|
|
$first = $project->pest('--tia', ...$arguments);
|
|
|
|
expect($first->exitCode)->toBe(0, $first->describe())
|
|
->and($first->replayed())->toBe(Project::TOTAL_TESTS, $first->describe())
|
|
->and($first->uncached())->toBe(1, $first->describe())
|
|
->and($project->graph()['edges'] ?? [])->toHaveKey('tests/Integration/WelcomeTest.php');
|
|
|
|
$second = $project->pest('--tia', ...$arguments);
|
|
|
|
expect($second->exitCode)->toBe(0, $second->describe())
|
|
->and($second->replayed())->toBe(Project::TOTAL_TESTS + 1, $second->describe())
|
|
->and($second->uncached())->toBe(0, $second->describe());
|
|
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows()->skip(! Coverage::isAvailable(), 'Coverage is not available');
|
|
|
|
test('a replay that records a test file the graph does not know keeps the edges of the known test files', function (array $arguments): void {
|
|
$project = Project::make('master');
|
|
addTestFileTheGraphDoesNotKnow($project);
|
|
$project->seed('master', failing: ['greets a person']);
|
|
$project->mutateGraph(function (array $graph): array {
|
|
$graph['edges']['tests/Unit/GreeterTest.php'][] = array_search('app/Calculator.php', $graph['files'], true);
|
|
|
|
return $graph;
|
|
});
|
|
|
|
$known = $project->graph()['edges'] ?? [];
|
|
|
|
$result = $project->pest('--tia', ...$arguments);
|
|
$edges = $project->graph()['edges'] ?? [];
|
|
|
|
expect($result->exitCode)->toBe(0, $result->describe())
|
|
->and($edges)->toHaveKey('tests/Integration/WelcomeTest.php');
|
|
|
|
unset($edges['tests/Integration/WelcomeTest.php']);
|
|
|
|
expect($edges)->toBe($known);
|
|
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows()->skip(! Coverage::isAvailable(), 'Coverage is not available');
|