Skip to content

Commit 4e13243

Browse files
Closes #6391
1 parent 6c79a47 commit 4e13243

File tree

3 files changed

+36
-18
lines changed

3 files changed

+36
-18
lines changed

ChangeLog-11.5.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes of the PHPUnit 11.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
44

5+
## [11.5.43] - 2025-MM-DD
6+
7+
### Fixed
8+
9+
* [#6391](https://github.com/sebastianbergmann/phpunit/issues/6391): Errors during backup of global variables and static properties are not reported
10+
511
## [11.5.42] - 2025-09-28
612

713
### Fixed
@@ -358,6 +364,7 @@ All notable changes of the PHPUnit 11.5 release series are documented in this fi
358364
* [#6055](https://github.com/sebastianbergmann/phpunit/issues/6055): `assertNotContainsOnly()` (use `assertContainsNotOnlyArray()`, `assertContainsNotOnlyBool()`, `assertContainsNotOnlyCallable()`, `assertContainsNotOnlyFloat()`, `assertContainsNotOnlyInt()`, `assertContainsNotOnlyIterable()`, `assertContainsNotOnlyNumeric()`, `assertContainsNotOnlyObject()`, `assertContainsNotOnlyResource()`, `assertContainsNotOnlyClosedResource()`, `assertContainsNotOnlyScalar()`, or `assertContainsNotOnlyString()` instead)
359365
* [#6059](https://github.com/sebastianbergmann/phpunit/issues/6059): `containsOnly()` (use `containsOnlyArray()`, `containsOnlyBool()`, `containsOnlyCallable()`, `containsOnlyFloat()`, `containsOnlyInt()`, `containsOnlyIterable()`, `containsOnlyNumeric()`, `containsOnlyObject()`, `containsOnlyResource()`, `containsOnlyClosedResource()`, `containsOnlyScalar()`, or `containsOnlyString()` instead)
360366

367+
[11.5.43]: https://github.com/sebastianbergmann/phpunit/compare/11.5.42...11.5
361368
[11.5.42]: https://github.com/sebastianbergmann/phpunit/compare/11.5.41...11.5.42
362369
[11.5.41]: https://github.com/sebastianbergmann/phpunit/compare/11.5.40...11.5.41
363370
[11.5.40]: https://github.com/sebastianbergmann/phpunit/compare/11.5.39...11.5.40

src/Framework/TestCase.php

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,18 +2106,31 @@ private function createGlobalStateSnapshot(bool $backupGlobals): Snapshot
21062106
}
21072107
}
21082108

2109-
return new Snapshot(
2110-
$excludeList,
2111-
$backupGlobals,
2112-
(bool) $this->backupStaticProperties,
2113-
false,
2114-
false,
2115-
false,
2116-
false,
2117-
false,
2118-
false,
2119-
false,
2120-
);
2109+
try {
2110+
return new Snapshot(
2111+
$excludeList,
2112+
$backupGlobals,
2113+
(bool) $this->backupStaticProperties,
2114+
false,
2115+
false,
2116+
false,
2117+
false,
2118+
false,
2119+
false,
2120+
false,
2121+
);
2122+
} catch (Throwable $t) {
2123+
Event\Facade::emitter()->testPreparationFailed(
2124+
$this->valueObjectForEvents(),
2125+
);
2126+
2127+
Event\Facade::emitter()->testErrored(
2128+
$this->valueObjectForEvents(),
2129+
Event\Code\ThrowableBuilder::from($t),
2130+
);
2131+
2132+
throw $t;
2133+
}
21212134
}
21222135

21232136
private function compareGlobalStateSnapshots(Snapshot $before, Snapshot $after): void

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
https://github.com/sebastianbergmann/phpunit/issues/6391
3-
--XFAIL--
4-
https://github.com/sebastianbergmann/phpunit/issues/6391
53
--FILE--
64
<?php declare(strict_types=1);
75
$_SERVER['argv'][] = '--no-configuration';
@@ -26,10 +24,10 @@ Before First Test Method Called (TestFixture\Issue6391\Issue6391Test::setUpBefor
2624
Before First Test Method Finished:
2725
- TestFixture\Issue6391\Issue6391Test::setUpBeforeClass
2826
Test Preparation Started (TestFixture\Issue6391\Issue6391Test::testOne)
29-
Test Prepared (TestFixture\Issue6391\Issue6391Test::testOne)
30-
Test Passed (TestFixture\Issue6391\Issue6391Test::testOne)
31-
Test Finished (TestFixture\Issue6391\Issue6391Test::testOne)
27+
Test Preparation Failed (TestFixture\Issue6391\Issue6391Test::testOne)
28+
Test Errored (TestFixture\Issue6391\Issue6391Test::testOne)
29+
Object of class TestFixture\Issue6391\Issue6391 could not be converted to string
3230
Test Suite Finished (TestFixture\Issue6391\Issue6391Test, 1 test)
3331
Test Runner Execution Finished
3432
Test Runner Finished
35-
PHPUnit Finished (Shell Exit Code: 0)
33+
PHPUnit Finished (Shell Exit Code: 2)

0 commit comments

Comments
 (0)