From 65475ddba23e76cd8fa521f6d6c2e056d4490e18 Mon Sep 17 00:00:00 2001 From: Michael Strelan Date: Mon, 19 Feb 2024 14:00:38 +1000 Subject: [PATCH 01/12] Remove use of deprecated ASSERT_ACTIVE constant --- tests/bootstrap.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 7ddf755..0bf42f5 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,9 +4,6 @@ * @file * Boostrap for PHPUnit. */ - -assert_options(ASSERT_ACTIVE, FALSE); - $autoloader = __DIR__ . '/../vendor/autoload.php'; $loader = require $autoloader; From ffc86828bca0e75d106c34d1e1b02fdba90e7f5c Mon Sep 17 00:00:00 2001 From: Michael Strelan Date: Mon, 19 Feb 2024 14:05:52 +1000 Subject: [PATCH 02/12] Migrate phpunit configuration --- phpunit.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index c07996d..86e75cb 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -4,16 +4,7 @@ or your current system user. See core/tests/README.md and https://www.drupal.org/node/2116263 for details. --> - - - - ./src - - - ./ - ./ - - + @@ -27,4 +18,13 @@ + + + ./src + + + ./ + ./ + + From 4ab480dc228f9d092901d60e9b1f8f0401ab100f Mon Sep 17 00:00:00 2001 From: Michael Strelan Date: Mon, 19 Feb 2024 14:06:11 +1000 Subject: [PATCH 03/12] Require phpunit ^10.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bf47d40..a8ad98e 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ ], "require": { "php": "^7.4||^8.0", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^10.5", "symfony/console": "^3.4||^4.4||^5||^6" }, "require-dev": { From 9aa50e6c32a49e108fcc0a5ca0de3a4f59b60a57 Mon Sep 17 00:00:00 2001 From: Michael Strelan Date: Mon, 19 Feb 2024 14:06:30 +1000 Subject: [PATCH 04/12] Update FinderCommand --- src/FinderCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FinderCommand.php b/src/FinderCommand.php index f444da5..308dc78 100644 --- a/src/FinderCommand.php +++ b/src/FinderCommand.php @@ -3,7 +3,7 @@ namespace PhpUnitFinder; use PHPUnit\Framework\TestCase; -use PHPUnit\TextUI\TestSuiteMapper; +use PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper; use PHPUnit\TextUI\XmlConfiguration\Loader; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -41,7 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { if ($testSuites && !in_array($suite->name(), $testSuites, TRUE)) { continue; } - $testSuite = (new TestSuiteMapper)->map($config->testSuite(), $suite->name()); + $testSuite = (new TestSuiteMapper)->map($config->filename(), $config->testSuite(), $suite->name(), ''); foreach (new \RecursiveIteratorIterator($testSuite) as $test) { if ($test instanceof TestCase) { $testFilenames[] = ((new \ReflectionClass($test))->getFileName()); From f75db91ebb8dd41a067fe5f756f2917899d8a48f Mon Sep 17 00:00:00 2001 From: Michael Strelan Date: Mon, 19 Feb 2024 14:12:27 +1000 Subject: [PATCH 05/12] Update deps, circle config --- .circleci/config.yml | 13 +++++-------- composer.json | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index eb3a036..c35a017 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,12 +1,9 @@ version: 2.1 executors: - php74: + php83: docker: - - image: skpr/php-cli:7.4-1.x - php80: - docker: - - image: skpr/php-cli:8.0-1.x + - image: skpr/php-cli:8.3-v2-latest workflows: build: @@ -14,7 +11,7 @@ workflows: - build: matrix: parameters: - php: ["php74", "php80"] + php: ["php83"] composer-opts: ["", "--prefer-lowest"] jobs: @@ -33,7 +30,7 @@ jobs: - deps-{{ arch }} - run: name: "Install Dependencies" - command: composer2 update --prefer-dist --no-progress --no-suggest --no-interaction << parameters.composer-opts >> + command: composer update --prefer-dist --no-progress --no-interaction << parameters.composer-opts >> - save_cache: key: deps-{{ arch }} paths: @@ -45,7 +42,7 @@ jobs: name: "Test" command: | mkdir -p ~/phpunit - ./bin/phpunit --testsuite unit --log-junit ~/phpunit/phpunit.xml + ./bin/phpunit --log-junit ~/phpunit/phpunit.xml - store_test_results: path: ~/phpunit - store_artifacts: diff --git a/composer.json b/composer.json index a8ad98e..ba5dd4d 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } ], "require": { - "php": "^7.4||^8.0", + "php": "^8.1", "phpunit/phpunit": "^10.5", "symfony/console": "^3.4||^4.4||^5||^6" }, From 253181bb20b0049b3a7c208420a9da2890321380 Mon Sep 17 00:00:00 2001 From: Michael Strelan Date: Mon, 19 Feb 2024 14:13:07 +1000 Subject: [PATCH 06/12] Lint --- src/FinderCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FinderCommand.php b/src/FinderCommand.php index 308dc78..9dddcc7 100644 --- a/src/FinderCommand.php +++ b/src/FinderCommand.php @@ -3,8 +3,8 @@ namespace PhpUnitFinder; use PHPUnit\Framework\TestCase; -use PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper; use PHPUnit\TextUI\XmlConfiguration\Loader; +use PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; From 3b33713398ba7ba8bfa1d01530db1fd95a31a6d6 Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Mon, 3 Feb 2025 21:44:41 +1100 Subject: [PATCH 07/12] Check phpunit version for bc --- composer.json | 4 +- src/FinderCommand.php | 88 ++++++++++++++++++++++++------------------- 2 files changed, 51 insertions(+), 41 deletions(-) diff --git a/composer.json b/composer.json index 7c9e584..8da8141 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,8 @@ ], "require": { "php": "^8.1", - "phpunit/phpunit": "^10.5", - "symfony/console": "^3.4||^4.4||^5||^6||^7" + "phpunit/phpunit": "^9.4||^10.5", + "symfony/console": "^6.4||^7" }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", diff --git a/src/FinderCommand.php b/src/FinderCommand.php index 9dddcc7..a90337e 100644 --- a/src/FinderCommand.php +++ b/src/FinderCommand.php @@ -3,6 +3,7 @@ namespace PhpUnitFinder; use PHPUnit\Framework\TestCase; +use PHPUnit\Runner\Version; use PHPUnit\TextUI\XmlConfiguration\Loader; use PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper; use Symfony\Component\Console\Command\Command; @@ -14,47 +15,56 @@ /** * A symfony command for finding PHPUnit files. */ -class FinderCommand extends Command { - - /** - * {@inheritdoc} - */ - protected function configure() { - $this->addOption('config-file', 'c', InputOption::VALUE_OPTIONAL, "The phpunit.xml config file to use.", getcwd() . '/phpunit.xml'); - $this->addOption('bootstrap-file', 'b', InputOption::VALUE_OPTIONAL, "The tests bootstrap file.", getcwd() . '/tests/bootstrap.php'); - $this->addArgument('test-suite', InputArgument::IS_ARRAY, "The test suites to scan."); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) { - $configFile = $input->getOption('config-file'); - $bootstrap = $input->getOption('bootstrap-file'); - include_once $bootstrap; - $testSuites = $input->getArgument('test-suite'); - $testFilenames = []; - - $config = (new Loader())->load($configFile); - - foreach ($config->testSuite() as $suite) { - if ($testSuites && !in_array($suite->name(), $testSuites, TRUE)) { - continue; - } - $testSuite = (new TestSuiteMapper)->map($config->filename(), $config->testSuite(), $suite->name(), ''); - foreach (new \RecursiveIteratorIterator($testSuite) as $test) { - if ($test instanceof TestCase) { - $testFilenames[] = ((new \ReflectionClass($test))->getFileName()); - } - } - } +class FinderCommand extends Command +{ - $testFilenames = array_unique($testFilenames); - foreach ($testFilenames as $testFilename) { - $output->writeln($testFilename); + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->addOption('config-file', 'c', InputOption::VALUE_OPTIONAL, "The phpunit.xml config file to use.", getcwd() . '/phpunit.xml'); + $this->addOption('bootstrap-file', 'b', InputOption::VALUE_OPTIONAL, "The tests bootstrap file.", getcwd() . '/tests/bootstrap.php'); + $this->addArgument('test-suite', InputArgument::IS_ARRAY, "The test suites to scan."); } - return 0; - } + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output): int + { + $configFile = $input->getOption('config-file'); + $bootstrap = $input->getOption('bootstrap-file'); + include_once $bootstrap; + $testSuites = $input->getArgument('test-suite'); + $testFilenames = []; + + $config = (new Loader())->load($configFile); + + foreach ($config->testSuite() as $suite) { + if ($testSuites && !in_array($suite->name(), $testSuites, TRUE)) { + continue; + } + // PHPUnit 9.4 and earlier. + if (str_starts_with(Version::id(), '9')) { + $testSuite = (new TestSuiteMapper())->map($config->testSuite(), $suite->name()); + } // PHPUnit 10.0 and later. + else { + $testSuite = (new TestSuiteMapper())->map($config->filename(), $config->testSuite(), $suite->name(), ''); + } + foreach (new \RecursiveIteratorIterator($testSuite) as $test) { + if ($test instanceof TestCase) { + $testFilenames[] = ((new \ReflectionClass($test))->getFileName()); + } + } + } + + $testFilenames = array_unique($testFilenames); + foreach ($testFilenames as $testFilename) { + $output->writeln($testFilename); + } + + return 0; + } } From c28899b019e80a5b32da4b5a255f96a59765c06d Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Mon, 3 Feb 2025 21:46:12 +1100 Subject: [PATCH 08/12] Fix coding standards --- src/FinderCommand.php | 86 +++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/src/FinderCommand.php b/src/FinderCommand.php index a90337e..72b5f42 100644 --- a/src/FinderCommand.php +++ b/src/FinderCommand.php @@ -15,56 +15,54 @@ /** * A symfony command for finding PHPUnit files. */ -class FinderCommand extends Command -{ +class FinderCommand extends Command { - /** - * {@inheritdoc} - */ - protected function configure() - { - $this->addOption('config-file', 'c', InputOption::VALUE_OPTIONAL, "The phpunit.xml config file to use.", getcwd() . '/phpunit.xml'); - $this->addOption('bootstrap-file', 'b', InputOption::VALUE_OPTIONAL, "The tests bootstrap file.", getcwd() . '/tests/bootstrap.php'); - $this->addArgument('test-suite', InputArgument::IS_ARRAY, "The test suites to scan."); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $configFile = $input->getOption('config-file'); - $bootstrap = $input->getOption('bootstrap-file'); - include_once $bootstrap; - $testSuites = $input->getArgument('test-suite'); - $testFilenames = []; + /** + * {@inheritdoc} + */ + protected function configure() { + $this->addOption('config-file', 'c', InputOption::VALUE_OPTIONAL, "The phpunit.xml config file to use.", getcwd() . '/phpunit.xml'); + $this->addOption('bootstrap-file', 'b', InputOption::VALUE_OPTIONAL, "The tests bootstrap file.", getcwd() . '/tests/bootstrap.php'); + $this->addArgument('test-suite', InputArgument::IS_ARRAY, "The test suites to scan."); + } - $config = (new Loader())->load($configFile); + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output): int { + $configFile = $input->getOption('config-file'); + $bootstrap = $input->getOption('bootstrap-file'); + include_once $bootstrap; + $testSuites = $input->getArgument('test-suite'); + $testFilenames = []; - foreach ($config->testSuite() as $suite) { - if ($testSuites && !in_array($suite->name(), $testSuites, TRUE)) { - continue; - } - // PHPUnit 9.4 and earlier. - if (str_starts_with(Version::id(), '9')) { - $testSuite = (new TestSuiteMapper())->map($config->testSuite(), $suite->name()); - } // PHPUnit 10.0 and later. - else { - $testSuite = (new TestSuiteMapper())->map($config->filename(), $config->testSuite(), $suite->name(), ''); - } - foreach (new \RecursiveIteratorIterator($testSuite) as $test) { - if ($test instanceof TestCase) { - $testFilenames[] = ((new \ReflectionClass($test))->getFileName()); - } - } - } + $config = (new Loader())->load($configFile); - $testFilenames = array_unique($testFilenames); - foreach ($testFilenames as $testFilename) { - $output->writeln($testFilename); + foreach ($config->testSuite() as $suite) { + if ($testSuites && !in_array($suite->name(), $testSuites, TRUE)) { + continue; + } + // PHPUnit 9.4 and earlier. + if (str_starts_with(Version::id(), '9')) { + $testSuite = (new TestSuiteMapper())->map($config->testSuite(), $suite->name()); + } + // PHPUnit 10.0 and later. + else { + $testSuite = (new TestSuiteMapper())->map($config->filename(), $config->testSuite(), $suite->name(), ''); + } + foreach (new \RecursiveIteratorIterator($testSuite) as $test) { + if ($test instanceof TestCase) { + $testFilenames[] = ((new \ReflectionClass($test))->getFileName()); } + } + } - return 0; + $testFilenames = array_unique($testFilenames); + foreach ($testFilenames as $testFilename) { + $output->writeln($testFilename); } + return 0; + } + } From 1ef26229b0b8255c13befcf34d948ae1057d62b7 Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Thu, 6 Feb 2025 15:16:18 +1100 Subject: [PATCH 09/12] Initialise Registry on PHPUnit10 --- src/FinderCommand.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/FinderCommand.php b/src/FinderCommand.php index 72b5f42..107d1b9 100644 --- a/src/FinderCommand.php +++ b/src/FinderCommand.php @@ -4,6 +4,8 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Runner\Version; +use PHPUnit\TextUI\CliArguments\Builder; +use PHPUnit\TextUI\Configuration\Registry; use PHPUnit\TextUI\XmlConfiguration\Loader; use PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper; use Symfony\Component\Console\Command\Command; @@ -38,6 +40,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $config = (new Loader())->load($configFile); + if (str_starts_with(Version::id(), '10')) { + Registry::init( + (new Builder)->fromParameters([]), + $config, + ); + } + foreach ($config->testSuite() as $suite) { if ($testSuites && !in_array($suite->name(), $testSuites, TRUE)) { continue; From 6db8508831cf817229c8580e922f6dcd7afb88fd Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Fri, 7 Feb 2025 13:41:59 +1100 Subject: [PATCH 10/12] Drop phpunit9 support --- src/FinderCommand.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/FinderCommand.php b/src/FinderCommand.php index 107d1b9..c46a585 100644 --- a/src/FinderCommand.php +++ b/src/FinderCommand.php @@ -40,25 +40,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int $config = (new Loader())->load($configFile); - if (str_starts_with(Version::id(), '10')) { - Registry::init( - (new Builder)->fromParameters([]), - $config, - ); - } + Registry::init( + (new Builder)->fromParameters([]), + $config, + ); foreach ($config->testSuite() as $suite) { if ($testSuites && !in_array($suite->name(), $testSuites, TRUE)) { continue; } - // PHPUnit 9.4 and earlier. - if (str_starts_with(Version::id(), '9')) { - $testSuite = (new TestSuiteMapper())->map($config->testSuite(), $suite->name()); - } - // PHPUnit 10.0 and later. - else { - $testSuite = (new TestSuiteMapper())->map($config->filename(), $config->testSuite(), $suite->name(), ''); - } + $testSuite = (new TestSuiteMapper())->map($config->filename(), $config->testSuite(), $suite->name(), ''); foreach (new \RecursiveIteratorIterator($testSuite) as $test) { if ($test instanceof TestCase) { $testFilenames[] = ((new \ReflectionClass($test))->getFileName()); From 79a7fc06057d422ef3ae4fc8bb9350a4ee22cf3a Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Tue, 25 Feb 2025 10:47:15 +1100 Subject: [PATCH 11/12] Drop phpunit 9 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8da8141..73ec539 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ ], "require": { "php": "^8.1", - "phpunit/phpunit": "^9.4||^10.5", + "phpunit/phpunit": "^10.5", "symfony/console": "^6.4||^7" }, "require-dev": { From 5d8a4e5664ce2b75580fbafd189cefb289296b89 Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Tue, 25 Feb 2025 10:49:05 +1100 Subject: [PATCH 12/12] Remove unused use --- src/FinderCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/FinderCommand.php b/src/FinderCommand.php index c46a585..1a8304c 100644 --- a/src/FinderCommand.php +++ b/src/FinderCommand.php @@ -3,7 +3,6 @@ namespace PhpUnitFinder; use PHPUnit\Framework\TestCase; -use PHPUnit\Runner\Version; use PHPUnit\TextUI\CliArguments\Builder; use PHPUnit\TextUI\Configuration\Registry; use PHPUnit\TextUI\XmlConfiguration\Loader;