From f394bb33b2bb7a4120b531e8991409b7aa62fc43 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Fri, 14 Apr 2023 08:17:37 +0200 Subject: [PATCH] Update PHPUnit compatibility to 10.1 (#752) --- composer.json | 16 ++++++++-------- phpunit.xml | 6 ++++-- .../ApplicationForWrapperWorker.php | 18 +++++++++++++++--- src/WrapperRunner/WrapperRunner.php | 12 +++++++++--- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index b96c7e40..c5d53bcb 100644 --- a/composer.json +++ b/composer.json @@ -40,23 +40,23 @@ "ext-simplexml": "*", "fidry/cpu-core-counter": "^0.4.1 || ^0.5.1", "jean85/pretty-package-versions": "^2.0.5", - "phpunit/php-code-coverage": "^10.0.2", + "phpunit/php-code-coverage": "^10.1.0", "phpunit/php-file-iterator": "^4.0.1", "phpunit/php-timer": "^6.0", - "phpunit/phpunit": "^10.0.17", - "sebastian/environment": "^6.0", - "symfony/console": "^6.2.7", - "symfony/process": "^6.2.7" + "phpunit/phpunit": "^10.1.0", + "sebastian/environment": "^6.0.1", + "symfony/console": "^6.2.8", + "symfony/process": "^6.2.8" }, "require-dev": { "ext-pcov": "*", "ext-posix": "*", "doctrine/coding-standard": "^11.1.0", "infection/infection": "^0.26.19", - "phpstan/phpstan": "^1.10.7", + "phpstan/phpstan": "^1.10.13", "phpstan/phpstan-deprecation-rules": "^1.1.3", - "phpstan/phpstan-phpunit": "^1.3.10", - "phpstan/phpstan-strict-rules": "^1.5", + "phpstan/phpstan-phpunit": "^1.3.11", + "phpstan/phpstan-strict-rules": "^1.5.1", "squizlabs/php_codesniffer": "^3.7.2", "symfony/filesystem": "^6.2.7" }, diff --git a/phpunit.xml b/phpunit.xml index 79bf82a2..14995f9b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,10 +10,12 @@ beStrictAboutChangesToGlobalState="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache"> - + - src + src + + diff --git a/src/WrapperRunner/ApplicationForWrapperWorker.php b/src/WrapperRunner/ApplicationForWrapperWorker.php index a0a100db..5923ff84 100644 --- a/src/WrapperRunner/ApplicationForWrapperWorker.php +++ b/src/WrapperRunner/ApplicationForWrapperWorker.php @@ -95,6 +95,7 @@ private function bootstrap(): void EventFacade::emitter()->testRunnerBootstrapFinished($bootstrapFilename); } + $extensionRequiresCodeCoverageCollection = false; if (! $this->configuration->noExtensions()) { if ($this->configuration->hasPharExtensionDirectory()) { (new PharLoader())->loadPharExtensionsInDirectory( @@ -102,9 +103,10 @@ private function bootstrap(): void ); } + $extensionFacade = new ExtensionFacade(); $extensionBootstrapper = new ExtensionBootstrapper( $this->configuration, - new ExtensionFacade(), + $extensionFacade, ); foreach ($this->configuration->extensionBootstrappers() as $bootstrapper) { @@ -113,9 +115,15 @@ private function bootstrap(): void $bootstrapper['parameters'], ); } + + $extensionRequiresCodeCoverageCollection = $extensionFacade->requiresCodeCoverageCollection(); } - CodeCoverage::instance()->init($this->configuration, CodeCoverageFilterRegistry::instance()); + CodeCoverage::instance()->init( + $this->configuration, + CodeCoverageFilterRegistry::instance(), + $extensionRequiresCodeCoverageCollection, + ); if ($this->configuration->hasLogfileJunit()) { new JunitXmlLogger( @@ -126,9 +134,13 @@ private function bootstrap(): void new ProgressPrinter( DefaultPrinter::from($this->progressFile), + EventFacade::instance(), false, 120, - EventFacade::instance(), + $this->configuration->source(), + $this->configuration->restrictDeprecations(), + $this->configuration->restrictNotices(), + $this->configuration->restrictWarnings(), ); if (isset($this->teamcityFile)) { diff --git a/src/WrapperRunner/WrapperRunner.php b/src/WrapperRunner/WrapperRunner.php index a42ceaef..5492e668 100644 --- a/src/WrapperRunner/WrapperRunner.php +++ b/src/WrapperRunner/WrapperRunner.php @@ -288,11 +288,13 @@ private function complete(TestResult $testResultSum): int $this->generateLogs(); $exitcode = (new ShellExitCodeCalculator())->calculate( + $this->options->configuration->failOnDeprecation(), $this->options->configuration->failOnEmptyTestSuite(), - $this->options->configuration->failOnRisky(), - $this->options->configuration->failOnWarning(), $this->options->configuration->failOnIncomplete(), + $this->options->configuration->failOnNotice(), + $this->options->configuration->failOnRisky(), $this->options->configuration->failOnSkipped(), + $this->options->configuration->failOnWarning(), $testResultSum, ); @@ -314,7 +316,11 @@ protected function generateCodeCoverageReports(): void } $coverageManager = new CodeCoverage(); - $coverageManager->init($this->options->configuration, $this->codeCoverageFilterRegistry); + $coverageManager->init( + $this->options->configuration, + $this->codeCoverageFilterRegistry, + false, + ); $coverageMerger = new CoverageMerger($coverageManager->codeCoverage()); foreach ($this->coverageFiles as $coverageFile) { $coverageMerger->addCoverageFromFile($coverageFile);