mirror of
https://github.com/pestphp/pest.git
synced 2026-04-23 07:27:27 +02:00
wip
This commit is contained in:
63
tests-tia/AffectedSetTest.php
Normal file
63
tests-tia/AffectedSetTest.php
Normal 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/');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user