Skip to content

Commit 9dbecce

Browse files
committed
Improved failure handling in FixturesTest.
1 parent dafb7ca commit 9dbecce

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

tests/cases/FixturesTest.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,22 @@ public function testAllFixtures()
3737
$this->validateFixture($fixtureFile, $parser, $failures);
3838
}
3939

40+
$previous = null;
4041
/** @var \Throwable $failure */
4142
foreach ($failures as $failure) {
42-
$exception = $failure instanceof \Exception ? $failure : null;
43-
throw new AssertionFailedError($failure->getMessage(), $failure->getCode(), $exception);
43+
if (!$failure instanceof \Throwable) {
44+
continue;
45+
}
46+
47+
$previous = new AssertionFailedError(
48+
$failure->getMessage(),
49+
$failure->getCode(),
50+
$previous
51+
);
52+
}
53+
54+
if ($previous) {
55+
throw $previous;
4456
}
4557
}
4658

@@ -120,9 +132,10 @@ private function validateCode(
120132
string $where,
121133
string $actualCode = null
122134
) {
135+
123136
$message = is_string($code)
124-
? sprintf("Expected %s code '%s' was not found", $type, $code)
125-
: sprintf("Expected %s code was not found", $type, $code);
137+
? sprintf('Expected %s code \'%s\' was not found', $type, $code)
138+
: sprintf('Expected %s was not found', $type);
126139

127140
$code === true
128141
? static::assertNotNull($actualCode, "{$message} {$where}.")

0 commit comments

Comments
 (0)