From 65c0fbc528940aec5b4d88bf9c51c0791009c877 Mon Sep 17 00:00:00 2001 From: nuno maduro Date: Sat, 2 May 2026 19:07:41 +0100 Subject: [PATCH] wip --- src/Concerns/Testable.php | 24 +++++++++---------- .../Tia/{Replay.php => Enums/ReplayType.php} | 6 ++--- 2 files changed, 15 insertions(+), 15 deletions(-) rename src/Plugins/Tia/{Replay.php => Enums/ReplayType.php} (91%) diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index a6ba6512..8955c3a9 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -10,7 +10,7 @@ use Pest\Panic; use Pest\Plugins\Tia; use Pest\Plugins\Tia\Collectors; use Pest\Plugins\Tia\Recorder; -use Pest\Plugins\Tia\Replay; +use Pest\Plugins\Tia\ReplayType; use Pest\Preset; use Pest\Support\ChainableClosure; use Pest\Support\Container; @@ -85,7 +85,7 @@ trait Testable * The active replay mode for this test, set in `setUp()` and checked * in `__runTest()` / `tearDown()` to skip the body and after-each. */ - private Replay $__replay = Replay::No; + private ReplayType $__replay = ReplayType::None; /** * The cached assertion count to replay, captured when entering replay mode. @@ -279,16 +279,16 @@ trait Testable /** @var Tia $tia */ $tia = Container::getInstance()->get(Tia::class); $status = $tia->getStatus(self::$__filename, $this::class.'::'.$this->name()); - $replay = Replay::fromStatus($status); + $replay = ReplayType::fromStatus($status); - if ($replay !== Replay::No) { + if ($replay !== ReplayType::None) { assert($status !== null); match ($replay) { - Replay::Pass, Replay::Risky => $this->__beginReplay($replay, $tia), - Replay::Skipped => $this->markTestSkipped($status->message()), - Replay::Incomplete => $this->markTestIncomplete($status->message()), - Replay::Failure => throw new AssertionFailedError($status->message() ?: 'Cached failure'), + ReplayType::Pass, ReplayType::Risky => $this->__beginReplay($replay, $tia), + ReplayType::Skipped => $this->markTestSkipped($status->message()), + ReplayType::Incomplete => $this->markTestIncomplete($status->message()), + ReplayType::Failure => throw new AssertionFailedError($status->message() ?: 'Cached failure'), }; return; @@ -314,7 +314,7 @@ trait Testable $this->__callClosure($beforeEach, $arguments); } - private function __beginReplay(Replay $replay, Tia $tia): void + private function __beginReplay(ReplayType $replay, Tia $tia): void { $this->__replay = $replay; $this->__replayAssertions = $tia->getAssertionCount($this::class.'::'.$this->name()); @@ -353,7 +353,7 @@ trait Testable */ protected function tearDown(...$arguments): void { - if ($this->__replay !== Replay::No) { + if ($this->__replay !== ReplayType::None) { TestSuite::getInstance()->test = null; return; @@ -384,8 +384,8 @@ trait Testable */ private function __runTest(Closure $closure, ...$args): mixed { - if ($this->__replay === Replay::Pass || $this->__replay === Replay::Risky) { - if ($this->__replay === Replay::Pass && $this->__replayAssertions === 0) { + if ($this->__replay === ReplayType::Pass || $this->__replay === ReplayType::Risky) { + if ($this->__replay === ReplayType::Pass && $this->__replayAssertions === 0) { $this->expectNotToPerformAssertions(); } diff --git a/src/Plugins/Tia/Replay.php b/src/Plugins/Tia/Enums/ReplayType.php similarity index 91% rename from src/Plugins/Tia/Replay.php rename to src/Plugins/Tia/Enums/ReplayType.php index 75525b25..e083e6ac 100644 --- a/src/Plugins/Tia/Replay.php +++ b/src/Plugins/Tia/Enums/ReplayType.php @@ -9,9 +9,9 @@ use PHPUnit\Framework\TestStatus\TestStatus; /** * @internal */ -enum Replay +enum ReplayType { - case No; + case None; case Pass; case Risky; case Skipped; @@ -21,7 +21,7 @@ enum Replay public static function fromStatus(?TestStatus $status): self { if (! $status instanceof TestStatus) { - return self::No; + return self::None; } return match (true) {