From 8083a421cee7dad847ee7c464529043ba30de380 Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Tue, 31 Oct 2023 05:13:57 -0400 Subject: [PATCH] [6.x] Add Symfony 7 support (#822) Co-authored-by: Filippo Tessarotto --- composer.json | 12 ++++++------ src/Console/Commands/ParaTestCommand.php | 1 + src/Logging/JUnit/Reader.php | 3 +++ src/Logging/JUnit/TestCase.php | 8 ++++---- src/Runners/PHPUnit/Suite.php | 1 + src/Runners/PHPUnit/TestMethod.php | 1 + test/Unit/Runners/PHPUnit/OptionsTest.php | 2 +- test/Unit/Runners/PHPUnit/WrapperRunnerTest.php | 4 +++- 8 files changed, 20 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 795e272b..2c9df136 100644 --- a/composer.json +++ b/composer.json @@ -38,23 +38,23 @@ "ext-pcre": "*", "ext-reflection": "*", "ext-simplexml": "*", - "fidry/cpu-core-counter": "^0.4.1 || ^0.5.1", + "fidry/cpu-core-counter": "^0.4.1 || ^0.5.1 || ^1.0.0", "jean85/pretty-package-versions": "^2.0.5", "phpunit/php-code-coverage": "^9.2.25", "phpunit/php-file-iterator": "^3.0.6", "phpunit/php-timer": "^5.0.3", "phpunit/phpunit": "^9.6.4", "sebastian/environment": "^5.1.5", - "symfony/console": "^5.4.21 || ^6.2.7", - "symfony/process": "^5.4.21 || ^6.2.7" + "symfony/console": "^5.4.28 || ^6.3.4 || ^7.0.0", + "symfony/process": "^5.4.28 || ^6.3.4 || ^7.0.0" }, "require-dev": { "ext-pcov": "*", "ext-posix": "*", - "doctrine/coding-standard": "^10.0.0", - "infection/infection": "^0.26.19", + "doctrine/coding-standard": "^12.0.0", + "infection/infection": "^0.27.6", "squizlabs/php_codesniffer": "^3.7.2", - "symfony/filesystem": "^5.4.21 || ^6.2.7", + "symfony/filesystem": "^5.4.25 || ^6.3.1 || ^7.0.0", "vimeo/psalm": "^5.7.7" }, "autoload": { diff --git a/src/Console/Commands/ParaTestCommand.php b/src/Console/Commands/ParaTestCommand.php index 1c3c6ebc..9506d8fa 100644 --- a/src/Console/Commands/ParaTestCommand.php +++ b/src/Console/Commands/ParaTestCommand.php @@ -40,6 +40,7 @@ final class ParaTestCommand extends Command public function __construct(string $cwd, ?string $name = null) { $this->cwd = $cwd; + parent::__construct($name); } diff --git a/src/Logging/JUnit/Reader.php b/src/Logging/JUnit/Reader.php index 60b277e1..4ef891ad 100644 --- a/src/Logging/JUnit/Reader.php +++ b/src/Logging/JUnit/Reader.php @@ -51,6 +51,8 @@ public function __construct(string $logFile) private function parseTestSuite(SimpleXMLElement $node, bool $isRootSuite): TestSuite { + assert($node->testsuite !== null); + if ($isRootSuite) { foreach ($node->testsuite as $singleTestSuiteXml) { return $this->parseTestSuite($singleTestSuiteXml, false); @@ -63,6 +65,7 @@ private function parseTestSuite(SimpleXMLElement $node, bool $isRootSuite): Test $suites[$testSuite->name] = $testSuite; } + assert($node->testcase !== null); $cases = []; foreach ($node->testcase as $singleTestCase) { $cases[] = TestCase::caseFromNode($singleTestCase); diff --git a/src/Logging/JUnit/TestCase.php b/src/Logging/JUnit/TestCase.php index f55b642d..1149de6b 100644 --- a/src/Logging/JUnit/TestCase.php +++ b/src/Logging/JUnit/TestCase.php @@ -167,10 +167,10 @@ class_exists($type) if ((string) $node['class'] !== '') { $text = sprintf( "%s::%s\n\n%s:%s", - $node['class'], - $node['name'], - $node['file'], - $node['line'], + (string) $node['class'], + (string) $node['name'], + (string) $node['file'], + (int) $node['line'], ); } diff --git a/src/Runners/PHPUnit/Suite.php b/src/Runners/PHPUnit/Suite.php index d82db6b4..1790f111 100644 --- a/src/Runners/PHPUnit/Suite.php +++ b/src/Runners/PHPUnit/Suite.php @@ -27,6 +27,7 @@ final class Suite extends ExecutableTest public function __construct(string $path, array $functions, bool $needsCoverage, bool $needsTeamcity, string $tmpDir) { parent::__construct($path, $needsCoverage, $needsTeamcity, $tmpDir); + $this->functions = $functions; } diff --git a/src/Runners/PHPUnit/TestMethod.php b/src/Runners/PHPUnit/TestMethod.php index 328e901b..c674d3fb 100644 --- a/src/Runners/PHPUnit/TestMethod.php +++ b/src/Runners/PHPUnit/TestMethod.php @@ -38,6 +38,7 @@ final class TestMethod extends ExecutableTest public function __construct(string $testPath, array $filters, bool $needsCoverage, bool $needsTeamcity, string $tmpDir) { parent::__construct($testPath, $needsCoverage, $needsTeamcity, $tmpDir); + // for compatibility with other code (tests), which can pass string (one filter) // instead of array of filters $this->filters = $filters; diff --git a/test/Unit/Runners/PHPUnit/OptionsTest.php b/test/Unit/Runners/PHPUnit/OptionsTest.php index 82c86c95..9edd0b87 100644 --- a/test/Unit/Runners/PHPUnit/OptionsTest.php +++ b/test/Unit/Runners/PHPUnit/OptionsTest.php @@ -491,7 +491,7 @@ public function testColors(bool $expected, ?string $phpunitConfig, array $option self::assertSame($expected, $this->createOptionsFromArgv($options, __DIR__, $hasColorSupport)->colors()); } - /** @return array|null)>> */ + /** @return array|null)>> */ public function provideColorsCases(): array { return [ diff --git a/test/Unit/Runners/PHPUnit/WrapperRunnerTest.php b/test/Unit/Runners/PHPUnit/WrapperRunnerTest.php index 8c2316e5..715164a5 100644 --- a/test/Unit/Runners/PHPUnit/WrapperRunnerTest.php +++ b/test/Unit/Runners/PHPUnit/WrapperRunnerTest.php @@ -5,6 +5,7 @@ namespace ParaTest\Tests\Unit\Runners\PHPUnit; use InvalidArgumentException; +use ParaTest\Runners\PHPUnit\RunnerInterface; use ParaTest\Runners\PHPUnit\WrapperRunner; use function array_diff; @@ -28,7 +29,8 @@ final class WrapperRunnerTest extends RunnerTestCase { protected const NUMBER_OF_CLASS_TESTS_FOR_BATCH_SIZE = 4; protected const UNPROCESSABLE_FILENAMES = ['..', '.', '.gitignore']; - /** {@inheritdoc } */ + + /** @var class-string */ protected $runnerClass = WrapperRunner::class; public function testWrapperRunnerNotAvailableInFunctionalMode(): void