Skip to content

Commit 57c4368

Browse files
Idrinthsebastianbergmann
authored andcommitted
removing seperate handling of caught exceptions where all are treated identical
1 parent 6c666c7 commit 57c4368

File tree

2 files changed

+37
-48
lines changed

2 files changed

+37
-48
lines changed

src/Framework/TestCase.php

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,52 +1144,47 @@ protected function runTest()
11441144

11451145
try {
11461146
$testResult = $this->{$this->name}(...\array_values($testArguments));
1147-
} catch (Throwable $t) {
1148-
$exception = $t;
1149-
}
1150-
1151-
if (isset($exception)) {
1152-
if ($this->checkExceptionExpectations($exception)) {
1153-
if ($this->expectedException !== null) {
1154-
$this->assertThat(
1155-
$exception,
1156-
new ExceptionConstraint(
1157-
$this->expectedException
1158-
)
1159-
);
1160-
}
1161-
1162-
if ($this->expectedExceptionMessage !== null) {
1163-
$this->assertThat(
1164-
$exception,
1165-
new ExceptionMessage(
1166-
$this->expectedExceptionMessage
1167-
)
1168-
);
1169-
}
1147+
} catch (Throwable $exception) {
1148+
if (!$this->checkExceptionExpectations($exception)) {
1149+
throw $exception;
1150+
}
1151+
if ($this->expectedException !== null) {
1152+
$this->assertThat(
1153+
$exception,
1154+
new ExceptionConstraint(
1155+
$this->expectedException
1156+
)
1157+
);
1158+
}
11701159

1171-
if ($this->expectedExceptionMessageRegExp !== null) {
1172-
$this->assertThat(
1173-
$exception,
1174-
new ExceptionMessageRegularExpression(
1175-
$this->expectedExceptionMessageRegExp
1176-
)
1177-
);
1178-
}
1160+
if ($this->expectedExceptionMessage !== null) {
1161+
$this->assertThat(
1162+
$exception,
1163+
new ExceptionMessage(
1164+
$this->expectedExceptionMessage
1165+
)
1166+
);
1167+
}
11791168

1180-
if ($this->expectedExceptionCode !== null) {
1181-
$this->assertThat(
1182-
$exception,
1183-
new ExceptionCode(
1184-
$this->expectedExceptionCode
1185-
)
1186-
);
1187-
}
1169+
if ($this->expectedExceptionMessageRegExp !== null) {
1170+
$this->assertThat(
1171+
$exception,
1172+
new ExceptionMessageRegularExpression(
1173+
$this->expectedExceptionMessageRegExp
1174+
)
1175+
);
1176+
}
11881177

1189-
return;
1178+
if ($this->expectedExceptionCode !== null) {
1179+
$this->assertThat(
1180+
$exception,
1181+
new ExceptionCode(
1182+
$this->expectedExceptionCode
1183+
)
1184+
);
11901185
}
11911186

1192-
throw $exception;
1187+
return;
11931188
}
11941189

11951190
if ($this->expectedException !== null) {

src/Framework/TestSuite.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,7 @@ public static function createTest(ReflectionClass $theClass, $name): Test
182182
}
183183

184184
$data = self::skipTest($className, $name, $message);
185-
} catch (Throwable $_t) {
186-
$t = $_t;
187-
} catch (Exception $_t) {
188-
$t = $_t;
189-
}
190-
191-
if (isset($t)) {
185+
} catch (Throwable $t) {
192186
$message = \sprintf(
193187
'The data provider specified for %s::%s is invalid.',
194188
$className,

0 commit comments

Comments
 (0)