Skip to content

Commit

Permalink
[11.x] Use PHPUnit's transformException() introduced in PHPUnit 10.1 (
Browse files Browse the repository at this point in the history
#48733)

* [11.x] Use PHPUnit's `transformException()` introduced in PHPUnit 10.1

This removed the need to override `runTest()` method which is marked as
`final` in the upcoming PHPUnit 11.

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone authored Oct 16, 2023
1 parent 02dadc0 commit 7132603
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"orchestra/testbench-core": "^9.0",
"pda/pheanstalk": "^4.0",
"phpstan/phpstan": "^1.4.7",
"phpunit/phpunit": "^10.0.7",
"phpunit/phpunit": "^10.1",
"predis/predis": "^2.0.2",
"symfony/cache": "^7.0",
"symfony/http-client": "^7.0"
Expand Down
16 changes: 5 additions & 11 deletions src/Illuminate/Foundation/Testing/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,15 @@ protected function setUpTraits()
/**
* {@inheritdoc}
*/
protected function runTest(): mixed
protected function transformException(Throwable $error): Throwable
{
$result = null;
$response = static::$latestResponse ?? null;

try {
$result = parent::runTest();
} catch (Throwable $e) {
if (! is_null(static::$latestResponse)) {
static::$latestResponse->transformNotSuccessfulException($e);
}

throw $e;
if (! is_null($response)) {
$response->transformNotSuccessfulException($error);
}

return $result;
return $error;
}

/**
Expand Down

0 comments on commit 7132603

Please sign in to comment.