From 7760d945bb0732dc366314816e328b21ff742e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20N=C3=BCrnberger?= Date: Mon, 20 Jan 2025 09:06:03 +0100 Subject: [PATCH 1/7] sync latest changes --- .../Runner/ResultCache/DefaultResultCache.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/overrides/Runner/ResultCache/DefaultResultCache.php b/overrides/Runner/ResultCache/DefaultResultCache.php index 581a4c7f..fde6bad9 100644 --- a/overrides/Runner/ResultCache/DefaultResultCache.php +++ b/overrides/Runner/ResultCache/DefaultResultCache.php @@ -46,6 +46,7 @@ declare(strict_types=1); namespace PHPUnit\Runner\ResultCache; use const DIRECTORY_SEPARATOR; +use const LOCK_EX; use PHPUnit\Framework\TestStatus\TestStatus; use PHPUnit\Runner\DirectoryCannotBeCreatedException; @@ -65,6 +66,8 @@ use function json_encode; use function Pest\version; /** + * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit + * * @internal This class is not covered by the backward compatibility promise for PHPUnit */ final class DefaultResultCache implements ResultCache @@ -77,12 +80,12 @@ final class DefaultResultCache implements ResultCache private readonly string $cacheFilename; /** - * @psalm-var array + * @var array */ private array $defects = []; /** - * @psalm-var array + * @var array */ private array $times = []; @@ -119,6 +122,17 @@ final class DefaultResultCache implements ResultCache return $this->times[$id] ?? 0.0; } + public function mergeWith(self $other): void + { + foreach ($other->defects as $id => $defect) { + $this->defects[$id] = $defect; + } + + foreach ($other->times as $id => $time) { + $this->times[$id] = $time; + } + } + public function load(): void { if (! is_file($this->cacheFilename)) { From 8ee9d66d802887129a175939d0ba7e82741b60e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20N=C3=BCrnberger?= Date: Mon, 20 Jan 2025 09:34:55 +0100 Subject: [PATCH 2/7] sync cs --- overrides/Logging/JUnit/JunitXmlLogger.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/overrides/Logging/JUnit/JunitXmlLogger.php b/overrides/Logging/JUnit/JunitXmlLogger.php index ca5c02c4..3a335f84 100644 --- a/overrides/Logging/JUnit/JunitXmlLogger.php +++ b/overrides/Logging/JUnit/JunitXmlLogger.php @@ -41,6 +41,8 @@ use function str_replace; use function trim; /** + * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit + * * @internal This class is not covered by the backward compatibility promise for PHPUnit */ final class JunitXmlLogger @@ -59,32 +61,32 @@ final class JunitXmlLogger private array $testSuites = []; /** - * @psalm-var array + * @var array */ private array $testSuiteTests = [0]; /** - * @psalm-var array + * @var array */ private array $testSuiteAssertions = [0]; /** - * @psalm-var array + * @var array */ private array $testSuiteErrors = [0]; /** - * @psalm-var array + * @var array */ private array $testSuiteFailures = [0]; /** - * @psalm-var array + * @var array */ private array $testSuiteSkipped = [0]; /** - * @psalm-var array + * @var array */ private array $testSuiteTimes = [0]; @@ -195,17 +197,11 @@ final class JunitXmlLogger $this->createTestCase($event); } - /** - * @throws InvalidArgumentException - */ public function testPreparationFailed(): void { $this->preparationFailed = true; } - /** - * @throws InvalidArgumentException - */ public function testPrepared(): void { $this->prepared = true; @@ -431,7 +427,7 @@ final class JunitXmlLogger /** * @throws InvalidArgumentException * - * @psalm-assert !null $this->currentTestCase + * @phpstan-assert !null $this->currentTestCase */ private function createTestCase(Errored|Failed|MarkedIncomplete|PreparationStarted|Prepared|Skipped $event): void { From fe4b5e5e1fa5e65c345b71328d1bc44502b11d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20N=C3=BCrnberger?= Date: Mon, 20 Jan 2025 09:35:44 +0100 Subject: [PATCH 3/7] sync change --- overrides/Logging/JUnit/JunitXmlLogger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overrides/Logging/JUnit/JunitXmlLogger.php b/overrides/Logging/JUnit/JunitXmlLogger.php index 3a335f84..7f59b4a7 100644 --- a/overrides/Logging/JUnit/JunitXmlLogger.php +++ b/overrides/Logging/JUnit/JunitXmlLogger.php @@ -115,7 +115,7 @@ final class JunitXmlLogger public function flush(): void { - $this->printer->print($this->document->saveXML()); + $this->printer->print($this->document->saveXML() ?: ''); $this->printer->flush(); } From 0cb8c42497a7d34c1239d73cdaeb1330667ecf38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20N=C3=BCrnberger?= Date: Mon, 20 Jan 2025 09:36:48 +0100 Subject: [PATCH 4/7] sync missing listener --- overrides/Logging/JUnit/JunitXmlLogger.php | 1 + 1 file changed, 1 insertion(+) diff --git a/overrides/Logging/JUnit/JunitXmlLogger.php b/overrides/Logging/JUnit/JunitXmlLogger.php index 7f59b4a7..21b73c62 100644 --- a/overrides/Logging/JUnit/JunitXmlLogger.php +++ b/overrides/Logging/JUnit/JunitXmlLogger.php @@ -304,6 +304,7 @@ final class JunitXmlLogger new TestFinishedSubscriber($this), new TestErroredSubscriber($this), new TestFailedSubscriber($this), + new TestMarkedIncompleteSubscriber($this), new TestSkippedSubscriber($this), new TestRunnerExecutionFinishedSubscriber($this), ); From 23f130b0f900469df7e693459b97e828f8eae3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20N=C3=BCrnberger?= Date: Mon, 20 Jan 2025 09:38:24 +0100 Subject: [PATCH 5/7] Update JunitXmlLogger.php from https://github.com/sebastianbergmann/phpunit/issues/5771 https://github.com/sebastianbergmann/phpunit/commit/c722fb259972a6c55fbb295169fd1a000b3d4c88 --- overrides/Logging/JUnit/JunitXmlLogger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overrides/Logging/JUnit/JunitXmlLogger.php b/overrides/Logging/JUnit/JunitXmlLogger.php index 21b73c62..d90ab723 100644 --- a/overrides/Logging/JUnit/JunitXmlLogger.php +++ b/overrides/Logging/JUnit/JunitXmlLogger.php @@ -212,7 +212,7 @@ final class JunitXmlLogger */ public function testFinished(Finished $event): void { - if ($this->preparationFailed) { + if (!$this->prepared || $this->preparationFailed) { return; } From e834527db2aa2dac5596faa8dd832874b3b4baeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20N=C3=BCrnberger?= Date: Mon, 20 Jan 2025 09:39:10 +0100 Subject: [PATCH 6/7] Update JunitXmlLogger.php https://github.com/sebastianbergmann/phpunit/issues/6098 --- overrides/Logging/JUnit/JunitXmlLogger.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/overrides/Logging/JUnit/JunitXmlLogger.php b/overrides/Logging/JUnit/JunitXmlLogger.php index d90ab723..433bc05b 100644 --- a/overrides/Logging/JUnit/JunitXmlLogger.php +++ b/overrides/Logging/JUnit/JunitXmlLogger.php @@ -27,6 +27,7 @@ use PHPUnit\Event\Test\Finished; use PHPUnit\Event\Test\MarkedIncomplete; use PHPUnit\Event\Test\PreparationStarted; use PHPUnit\Event\Test\Prepared; +use PHPUnit\Event\Test\PrintedUnexpectedOutput; use PHPUnit\Event\Test\Skipped; use PHPUnit\Event\TestSuite\Started; use PHPUnit\Event\UnknownSubscriberTypeException; @@ -207,6 +208,18 @@ final class JunitXmlLogger $this->prepared = true; } + public function testPrintedUnexpectedOutput(PrintedUnexpectedOutput $event): void + { + assert($this->currentTestCase !== null); + + $systemOut = $this->document->createElement( + 'system-out', + Xml::prepareString($event->output()), + ); + + $this->currentTestCase->appendChild($systemOut); + } + /** * @throws InvalidArgumentException */ @@ -301,6 +314,7 @@ final class JunitXmlLogger new TestPreparationStartedSubscriber($this), new TestPreparationFailedSubscriber($this), new TestPreparedSubscriber($this), + new TestPrintedUnexpectedOutputSubscriber($this), new TestFinishedSubscriber($this), new TestErroredSubscriber($this), new TestFailedSubscriber($this), From c4c9e915f46c934cc68071fb0e6c9811f20d60e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20N=C3=BCrnberger?= Date: Mon, 20 Jan 2025 09:50:36 +0100 Subject: [PATCH 7/7] cs --- overrides/Logging/JUnit/JunitXmlLogger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overrides/Logging/JUnit/JunitXmlLogger.php b/overrides/Logging/JUnit/JunitXmlLogger.php index 433bc05b..b7362b1f 100644 --- a/overrides/Logging/JUnit/JunitXmlLogger.php +++ b/overrides/Logging/JUnit/JunitXmlLogger.php @@ -225,7 +225,7 @@ final class JunitXmlLogger */ public function testFinished(Finished $event): void { - if (!$this->prepared || $this->preparationFailed) { + if (! $this->prepared || $this->preparationFailed) { return; }