diff --git a/core/lib/Drupal/Core/Test/JUnitListener.php b/core/lib/Drupal/Core/Test/JUnitListener.php index 0f586337..08dbf352 100644 --- a/core/lib/Drupal/Core/Test/JUnitListener.php +++ b/core/lib/Drupal/Core/Test/JUnitListener.php @@ -81,11 +81,11 @@ public function __destruct() { * An error occurred. * * @param \PHPUnit\Framework\Test $test - * @param \Exception $e + * @param \Throwable $t * @param float $time */ - public function addError(Test $test, \Exception $e, $time) { - $this->doAddFault($test, $e, $time, 'error'); + public function addError(Test $test, \Throwable $t, float $time): void { + $this->doAddFault($test, $t, $time, 'error'); $this->testSuiteRuns[$this->testSuiteLevel]['errors']++; } @@ -96,7 +96,7 @@ public function addError(Test $test, \Exception $e, $time) { * @param \PHPUnit\Framework\Warning $e * @param float $time */ - public function addWarning(Test $test, Warning $e, $time) { + public function addWarning(Test $test, Warning $e, float $time): void { $this->doAddFault($test, $e, $time, 'warning'); $this->testSuiteRuns[$this->testSuiteLevel]['failures']++; } @@ -108,7 +108,7 @@ public function addWarning(Test $test, Warning $e, $time) { * @param \PHPUnit\Framework\AssertionFailedError $e * @param float $time */ - public function addFailure(Test $test, AssertionFailedError $e, $time) { + public function addFailure(Test $test, AssertionFailedError $e, float $time): void { $this->doAddFault($test, $e, $time, 'failure'); $this->testSuiteRuns[$this->testSuiteLevel]['failures']++; } @@ -117,10 +117,10 @@ public function addFailure(Test $test, AssertionFailedError $e, $time) { * Incomplete test. * * @param \PHPUnit\Framework\Test $test - * @param \Exception $e + * @param \Throwable $t * @param float $time */ - public function addIncompleteTest(Test $test, \Exception $e, $time) { + public function addIncompleteTest(Test $test, \Throwable $t, float $time): void { $this->doAddSkipped($test, 'incomplete'); } @@ -128,10 +128,10 @@ public function addIncompleteTest(Test $test, \Exception $e, $time) { * Risky test. * * @param \PHPUnit\Framework\Test $test - * @param \Exception $e + * @param \Throwable $t * @param float $time */ - public function addRiskyTest(Test $test, \Exception $e, $time) { + public function addRiskyTest(Test $test, \Throwable $t, float $time): void { $this->doAddSkipped($test, 'risky'); } @@ -139,10 +139,10 @@ public function addRiskyTest(Test $test, \Exception $e, $time) { * Skipped test. * * @param \PHPUnit\Framework\Test $test - * @param \Exception $e + * @param \Throwable $t * @param float $time */ - public function addSkippedTest(Test $test, \Exception $e, $time) { + public function addSkippedTest(Test $test, \Throwable $t, float $time): void { $this->doAddSkipped($test, 'skipped'); } @@ -151,7 +151,7 @@ public function addSkippedTest(Test $test, \Exception $e, $time) { * * @param \PHPUnit\Framework\TestSuite $suite */ - public function startTestSuite(TestSuite $suite) { + public function startTestSuite(TestSuite $suite): void { $testSuite = $this->document->createElement('testsuite'); $testSuite->setAttribute('name', $suite->getName()); if (class_exists($suite->getName(), FALSE)) { @@ -188,7 +188,7 @@ public function startTestSuite(TestSuite $suite) { * * @param \PHPUnit\Framework\TestSuite $suite */ - public function endTestSuite(TestSuite $suite) { + public function endTestSuite(TestSuite $suite): void { $properties = [ 'tests', 'assertions', @@ -220,7 +220,7 @@ public function endTestSuite(TestSuite $suite) { * * @param \PHPUnit\Framework\Test $test */ - public function startTest(Test $test) { + public function startTest(Test $test): void { $testCase = $this->document->createElement('testcase'); $testCase->setAttribute('name', $test->getName()); @@ -247,7 +247,7 @@ public function startTest(Test $test) { * @param \PHPUnit\Framework\Test $test * @param float $time */ - public function endTest(Test $test, $time) { + public function endTest(Test $test, float $time): void { if ($test instanceof TestCase) { $num_assertions = $test->getNumAssertions(); $this->testSuiteRuns[$this->testSuiteLevel]['assertions'] += $num_assertions; @@ -286,11 +286,11 @@ public function getXML() { * Method which generalizes addError() and addFailure() * * @param \PHPUnit\Framework\Test $test - * @param \Exception $e + * @param \Throwable $t * @param float $time * @param string $type */ - private function doAddFault(Test $test, \Exception $e, $time, $type) { + private function doAddFault(Test $test, \Throwable $t, float $time, string $type): void { if ($this->currentTestCase === NULL) { return; } @@ -302,15 +302,15 @@ private function doAddFault(Test $test, \Exception $e, $time, $type) { $buffer = ''; } - $buffer .= TestFailure::exceptionToString($e) . "\n" . Filter::getFilteredStacktrace($e); + $buffer .= TestFailure::exceptionToString($t) . "\n" . Filter::getFilteredStacktrace($t); $fault = $this->document->createElement($type, Xml::prepareString($buffer)); - if ($e instanceof ExceptionWrapper) { - $fault->setAttribute('type', $e->getClassName()); + if ($t instanceof ExceptionWrapper) { + $fault->setAttribute('type', $t->getClassName()); } else { - $fault->setAttribute('type', get_class($e)); + $fault->setAttribute('type', get_class($t)); } $this->currentTestCase->appendChild($fault); @@ -326,7 +326,7 @@ private function doAddFault(Test $test, \Exception $e, $time, $type) { * @param \PHPUnit\Framework\Test $test * @param string $message */ - private function doAddSkipped(Test $test, $message) { + private function doAddSkipped(Test $test, string $message): void { if ($this->currentTestCase === NULL) { return; } diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php index 6ef3a4fd..db6d0c5d 100644 --- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php @@ -119,6 +119,7 @@ public static function getSkippedDeprecations() { "The \"Drupal\Tests\Listeners\DrupalListener\" class implements \"PHPUnit\Framework\TestListener\" that is deprecated Use the `TestHook` interfaces instead.", "The \"Drupal\Tests\Listeners\DrupalListener\" class uses \"PHPUnit\Framework\TestListenerDefaultImplementation\" that is deprecated The `TestListener` interface is deprecated.", "The \"PHPUnit\Framework\TestSuite\" class is considered internal This class is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not use it from \"Drupal\Tests\TestSuites\TestSuiteBase\".", + "The \"Drupal\Core\Test\JUnitListener\" class implements \"PHPUnit\Framework\TestListener\" that is deprecated Use the `TestHook` interfaces instead.", // Simpletest's legacy assertion methods. 'UiHelperTrait::drupalPostForm() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use $this->submitForm() instead. See https://www.drupal.org/node/3168858', 'AssertLegacyTrait::assertEqual() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertEquals() instead. See https://www.drupal.org/node/3129738',