feat(tia): adds poc

This commit is contained in:
nuno maduro
2026-04-15 17:31:53 -07:00
parent bff44562a9
commit c440031e28
11 changed files with 1630 additions and 0 deletions

View File

@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace Pest\Subscribers;
use Pest\Support\Tia\Recorder;
use PHPUnit\Event\Test\Finished;
use PHPUnit\Event\Test\FinishedSubscriber;
/**
* Stops PCOV collection after each test and merges the covered files into the
* TIA recorder's aggregate map. No-op unless the recorder is active.
*
* @internal
*/
final class EnsureTiaCoverageIsFlushed implements FinishedSubscriber
{
public function notify(Finished $event): void
{
Recorder::instance()->endTest();
}
}

View File

@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace Pest\Subscribers;
use Pest\Support\Tia\Recorder;
use PHPUnit\Event\Code\TestMethod;
use PHPUnit\Event\Test\Prepared;
use PHPUnit\Event\Test\PreparedSubscriber;
/**
* Starts PCOV collection before each test. No-op unless the TIA recorder was
* activated by the `--tia` plugin.
*
* @internal
*/
final class EnsureTiaCoverageIsRecorded implements PreparedSubscriber
{
public function notify(Prepared $event): void
{
$recorder = Recorder::instance();
if (! $recorder->isActive()) {
return;
}
$test = $event->test();
if (! $test instanceof TestMethod) {
return;
}
$recorder->beginTest($test->className(), $test->methodName(), $test->file());
}
}