From 880b003bee2865ba18d43890e5b49c41ea7361b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20N=C3=BCrnberger?= Date: Wed, 24 Jan 2024 21:50:52 +0100 Subject: [PATCH] apply cs --- overrides/Logging/JUnit/JunitXmlLogger.php | 78 +++++++++++++--------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/overrides/Logging/JUnit/JunitXmlLogger.php b/overrides/Logging/JUnit/JunitXmlLogger.php index a2aaa42d..a1ca5ff5 100644 --- a/overrides/Logging/JUnit/JunitXmlLogger.php +++ b/overrides/Logging/JUnit/JunitXmlLogger.php @@ -1,4 +1,6 @@ - */ - private array $testSuiteTimes = [0]; - private int $testSuiteLevel = 0; + private array $testSuiteTimes = [0]; + + private int $testSuiteLevel = 0; + private ?DOMElement $currentTestCase = null; - private ?HRTime $time = null; - private bool $prepared = false; - private bool $preparationFailed = false; + + private ?HRTime $time = null; + + private bool $prepared = false; + + private bool $preparationFailed = false; /** * @throws EventFacadeIsSealedException @@ -122,13 +134,13 @@ final class JunitXmlLogger } $this->testSuiteLevel++; - $this->testSuites[$this->testSuiteLevel] = $testSuite; - $this->testSuiteTests[$this->testSuiteLevel] = 0; + $this->testSuites[$this->testSuiteLevel] = $testSuite; + $this->testSuiteTests[$this->testSuiteLevel] = 0; $this->testSuiteAssertions[$this->testSuiteLevel] = 0; - $this->testSuiteErrors[$this->testSuiteLevel] = 0; - $this->testSuiteFailures[$this->testSuiteLevel] = 0; - $this->testSuiteSkipped[$this->testSuiteLevel] = 0; - $this->testSuiteTimes[$this->testSuiteLevel] = 0; + $this->testSuiteErrors[$this->testSuiteLevel] = 0; + $this->testSuiteFailures[$this->testSuiteLevel] = 0; + $this->testSuiteSkipped[$this->testSuiteLevel] = 0; + $this->testSuiteTimes[$this->testSuiteLevel] = 0; } public function testSuiteFinished(): void @@ -164,12 +176,12 @@ final class JunitXmlLogger ); if ($this->testSuiteLevel > 1) { - $this->testSuiteTests[$this->testSuiteLevel - 1] += $this->testSuiteTests[$this->testSuiteLevel]; + $this->testSuiteTests[$this->testSuiteLevel - 1] += $this->testSuiteTests[$this->testSuiteLevel]; $this->testSuiteAssertions[$this->testSuiteLevel - 1] += $this->testSuiteAssertions[$this->testSuiteLevel]; - $this->testSuiteErrors[$this->testSuiteLevel - 1] += $this->testSuiteErrors[$this->testSuiteLevel]; - $this->testSuiteFailures[$this->testSuiteLevel - 1] += $this->testSuiteFailures[$this->testSuiteLevel]; - $this->testSuiteSkipped[$this->testSuiteLevel - 1] += $this->testSuiteSkipped[$this->testSuiteLevel]; - $this->testSuiteTimes[$this->testSuiteLevel - 1] += $this->testSuiteTimes[$this->testSuiteLevel]; + $this->testSuiteErrors[$this->testSuiteLevel - 1] += $this->testSuiteErrors[$this->testSuiteLevel]; + $this->testSuiteFailures[$this->testSuiteLevel - 1] += $this->testSuiteFailures[$this->testSuiteLevel]; + $this->testSuiteSkipped[$this->testSuiteLevel - 1] += $this->testSuiteSkipped[$this->testSuiteLevel]; + $this->testSuiteTimes[$this->testSuiteLevel - 1] += $this->testSuiteTimes[$this->testSuiteLevel]; } $this->testSuiteLevel--; @@ -277,8 +289,8 @@ final class JunitXmlLogger $this->testSuiteTimes[$this->testSuiteLevel] += $time; $this->currentTestCase = null; - $this->time = null; - $this->prepared = false; + $this->time = null; + $this->prepared = false; } /** @@ -304,7 +316,7 @@ final class JunitXmlLogger private function createDocument(): void { - $this->document = new DOMDocument('1.0', 'UTF-8'); + $this->document = new DOMDocument('1.0', 'UTF-8'); $this->document->formatOutput = true; $this->root = $this->document->createElement('testsuites'); @@ -316,7 +328,7 @@ final class JunitXmlLogger */ private function handleFault(Errored|Failed $event, string $type): void { - if (!$this->prepared) { + if (! $this->prepared) { $this->createTestCase($event); } @@ -326,7 +338,7 @@ final class JunitXmlLogger $throwable = $event->throwable(); $buffer .= trim( - $this->converter->getExceptionMessage($throwable) . PHP_EOL . // pest-changed + $this->converter->getExceptionMessage($throwable).PHP_EOL. // pest-changed $this->converter->getExceptionDetails($throwable), // pest-changed ); @@ -339,7 +351,7 @@ final class JunitXmlLogger $this->currentTestCase->appendChild($fault); - if (!$this->prepared) { + if (! $this->prepared) { $this->handleFinish($event->telemetryInfo(), 0); } } @@ -349,7 +361,7 @@ final class JunitXmlLogger */ private function handleIncompleteOrSkipped(MarkedIncomplete|Skipped $event): void { - if (!$this->prepared) { + if (! $this->prepared) { $this->createTestCase($event); } @@ -361,7 +373,7 @@ final class JunitXmlLogger $this->testSuiteSkipped[$this->testSuiteLevel]++; - if (!$this->prepared) { + if (! $this->prepared) { $this->handleFinish($event->telemetryInfo(), 0); } } @@ -396,7 +408,7 @@ final class JunitXmlLogger assert($test instanceof TestMethod); - if (!$test->testData()->hasDataFromDataProvider()) { + if (! $test->testData()->hasDataFromDataProvider()) { return $test->methodName(); } @@ -442,6 +454,6 @@ final class JunitXmlLogger } $this->currentTestCase = $testCase; - $this->time = $event->telemetryInfo()->time(); + $this->time = $event->telemetryInfo()->time(); } }