We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TestCase::transformException()
main
diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index b875580d5..00898d070 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -671,7 +671,7 @@ final public function runBare(): void null ); } else { - $e = $_e; + $e = $this->transformException($_e); $this->status = TestStatus::error($e->getMessage()); @@ -1465,6 +1465,11 @@ protected function getObjectForTrait(string $traitName, array $arguments = [], s ); } + protected function transformException(Throwable $t): Throwable + { + return $t; + }
Test.php
<?php declare(strict_types=1); use PHPUnit\Framework\TestCase; final class OriginalException extends RuntimeException { } final class ModifiedException extends RuntimeException { } final class Test extends TestCase { public function testOne(): void { throw new OriginalException('original message'); } protected function transformException(Throwable $t): Throwable { return new ModifiedException('modified message'); } }
PHPUnit 10.1-dev by Sebastian Bergmann and contributors. Runtime: PHP 8.2.4 E 1 / 1 (100%) Time: 00:00.019, Memory: 4.00 MB There was 1 error: 1) Test::testOne ModifiedException: modified message /home/sb/Test.php:21 ERRORS! Tests: 1, Assertions: 0, Errors: 1.
Originally posted by @sebastianbergmann in #5254 (comment)
The text was updated successfully, but these errors were encountered:
8b3f1d5
sebastianbergmann
No branches or pull requests
WIP: Implement
TestCase::transformException()
hook method (main
branch)Test.php
Originally posted by @sebastianbergmann in #5254 (comment)
The text was updated successfully, but these errors were encountered: