Skip to content

Commit 3760f84

Browse files
Merge branch '10.5' into 11.0
2 parents 3a077af + 43cc09c commit 3760f84

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

.psalm/baseline.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@
446446
</PossiblyNullArgument>
447447
<RedundantCondition>
448448
<code><![CDATA[assert($test instanceof TestMethod)]]></code>
449+
<code><![CDATA[assert($test instanceof TestMethod)]]></code>
449450
</RedundantCondition>
450451
</file>
451452
<file src="src/Metadata/Api/CodeCoverage.php">

ChangeLog-11.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ All notable changes of the PHPUnit 11.0 release series are documented in this fi
1111
* [#5750](https://github.com/sebastianbergmann/phpunit/pull/5750): Micro-optimize `NamePrettifier::prettifyTestMethodName()` once again
1212
* [#5752](https://github.com/sebastianbergmann/phpunit/issues/5752): Improve message for deprecation of doubling methods named "method"
1313

14+
### Fixed
15+
16+
* [#5760](https://github.com/sebastianbergmann/phpunit/issues/5760): TestDox printer does not display details about exceptions raised in before-test methods
17+
1418
## [11.0.6] - 2024-03-12
1519

1620
### Changed

src/Logging/TestDox/TestResult/TestResultCollector.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ final class TestResultCollector
5454
private array $tests = [];
5555
private ?TestStatus $status = null;
5656
private ?Throwable $throwable = null;
57+
private bool $prepared = false;
5758

5859
/**
5960
* @throws EventFacadeIsSealedException
@@ -136,6 +137,7 @@ public function testPrepared(Prepared $event): void
136137

137138
$this->status = TestStatus::unknown();
138139
$this->throwable = null;
140+
$this->prepared = true;
139141
}
140142

141143
public function testErrored(Errored $event): void
@@ -146,6 +148,14 @@ public function testErrored(Errored $event): void
146148

147149
$this->status = TestStatus::error($event->throwable()->message());
148150
$this->throwable = $event->throwable();
151+
152+
if (!$this->prepared) {
153+
$test = $event->test();
154+
155+
assert($test instanceof TestMethod);
156+
157+
$this->process($test);
158+
}
149159
}
150160

151161
public function testFailed(Failed $event): void
@@ -290,18 +300,11 @@ public function testFinished(Finished $event): void
290300

291301
assert($test instanceof TestMethod);
292302

293-
if (!isset($this->tests[$test->testDox()->prettifiedClassName()])) {
294-
$this->tests[$test->testDox()->prettifiedClassName()] = [];
295-
}
296-
297-
$this->tests[$test->testDox()->prettifiedClassName()][] = new TestDoxTestMethod(
298-
$test,
299-
$this->status,
300-
$this->throwable,
301-
);
303+
$this->process($test);
302304

303305
$this->status = null;
304306
$this->throwable = null;
307+
$this->prepared = false;
305308
}
306309

307310
/**
@@ -340,4 +343,17 @@ private function updateTestStatus(TestStatus $status): void
340343

341344
$this->status = $status;
342345
}
346+
347+
private function process(TestMethod $test): void
348+
{
349+
if (!isset($this->tests[$test->testDox()->prettifiedClassName()])) {
350+
$this->tests[$test->testDox()->prettifiedClassName()] = [];
351+
}
352+
353+
$this->tests[$test->testDox()->prettifiedClassName()][] = new TestDoxTestMethod(
354+
$test,
355+
$this->status,
356+
$this->throwable,
357+
);
358+
}
343359
}

tests/end-to-end/regression/5760.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
https://github.com/sebastianbergmann/phpunit/issues/5760
3-
--XFAIL--
4-
https://github.com/sebastianbergmann/phpunit/issues/5760
53
--FILE--
64
<?php declare(strict_types=1);
75
$_SERVER['argv'][] = '--do-not-cache-result';

0 commit comments

Comments
 (0)