This commit is contained in:
nuno maduro
2026-04-22 08:07:52 -07:00
parent 856a370032
commit c6a42a2b28
22 changed files with 1259 additions and 4 deletions

View File

@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
use Pest\TestsTia\Support\Sandbox;
/*
* Mutating a source file should narrow replay to the tests that depend
* on it. Untouched areas of the suite keep cache-hitting.
*/
test('editing a source file marks only its dependents as affected', function () {
tiaScenario(function (Sandbox $sandbox) {
$sandbox->pest(['--tia']);
$sandbox->write('src/Math.php', <<<'PHP'
<?php
declare(strict_types=1);
namespace App;
final class Math
{
public static function add(int $a, int $b): int
{
return $a + $b;
}
public static function sub(int $a, int $b): int
{
return $a - $b;
}
}
PHP);
$process = $sandbox->pest(['--tia']);
expect($process->isSuccessful())->toBeTrue(tiaOutput($process));
expect(tiaOutput($process))->toMatch('/2 affected,\s*1 replayed/');
});
});
test('adding a new test file runs the new test + replays the rest', function () {
tiaScenario(function (Sandbox $sandbox) {
$sandbox->pest(['--tia']);
$sandbox->write('tests/ExtraTest.php', <<<'PHP'
<?php
declare(strict_types=1);
test('extra smoke', function () {
expect(true)->toBeTrue();
});
PHP);
$process = $sandbox->pest(['--tia']);
expect($process->isSuccessful())->toBeTrue(tiaOutput($process));
expect(tiaOutput($process))->toMatch('/1 affected,\s*3 replayed/');
});
});