Skip to content

Commit 7132603

Browse files
authored
[11.x] Use PHPUnit's transformException() introduced in PHPUnit 10.1 (#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]>
1 parent 02dadc0 commit 7132603

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"orchestra/testbench-core": "^9.0",
108108
"pda/pheanstalk": "^4.0",
109109
"phpstan/phpstan": "^1.4.7",
110-
"phpunit/phpunit": "^10.0.7",
110+
"phpunit/phpunit": "^10.1",
111111
"predis/predis": "^2.0.2",
112112
"symfony/cache": "^7.0",
113113
"symfony/http-client": "^7.0"

src/Illuminate/Foundation/Testing/TestCase.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,15 @@ protected function setUpTraits()
162162
/**
163163
* {@inheritdoc}
164164
*/
165-
protected function runTest(): mixed
165+
protected function transformException(Throwable $error): Throwable
166166
{
167-
$result = null;
167+
$response = static::$latestResponse ?? null;
168168

169-
try {
170-
$result = parent::runTest();
171-
} catch (Throwable $e) {
172-
if (! is_null(static::$latestResponse)) {
173-
static::$latestResponse->transformNotSuccessfulException($e);
174-
}
175-
176-
throw $e;
169+
if (! is_null($response)) {
170+
$response->transformNotSuccessfulException($error);
177171
}
178172

179-
return $result;
173+
return $error;
180174
}
181175

182176
/**

0 commit comments

Comments
 (0)