mirror of
https://github.com/pestphp/pest.git
synced 2026-06-05 19:02:13 +02:00
feat(tia): adds poc
This commit is contained in:
23
src/Subscribers/EnsureTiaCoverageIsFlushed.php
Normal file
23
src/Subscribers/EnsureTiaCoverageIsFlushed.php
Normal 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();
|
||||
}
|
||||
}
|
||||
36
src/Subscribers/EnsureTiaCoverageIsRecorded.php
Normal file
36
src/Subscribers/EnsureTiaCoverageIsRecorded.php
Normal 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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user