Skip to content

Commit 404c612

Browse files
mstrelanacbramleykimpepper
authored
Support PHPUnit 10 (#15)
* Remove use of deprecated ASSERT_ACTIVE constant * Migrate phpunit configuration * Require phpunit ^10.5 * Update FinderCommand * Update deps, circle config * Lint * Check phpunit version for bc * Fix coding standards * Initialise Registry on PHPUnit10 * Drop phpunit9 support * Drop phpunit 9 * Remove unused use --------- Co-authored-by: Adam Bramley <[email protected]> Co-authored-by: Kim Pepper <[email protected]> Co-authored-by: Michael Strelan <[email protected]>
1 parent a604c38 commit 404c612

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

.circleci/config.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
version: 2.1
22

33
executors:
4-
php74:
4+
php83:
55
docker:
6-
- image: skpr/php-cli:7.4-1.x
7-
php80:
8-
docker:
9-
- image: skpr/php-cli:8.0-1.x
6+
- image: skpr/php-cli:8.3-v2-latest
107

118
workflows:
129
build:
1310
jobs:
1411
- build:
1512
matrix:
1613
parameters:
17-
php: ["php74", "php80"]
14+
php: ["php83"]
1815
composer-opts: ["", "--prefer-lowest"]
1916

2017
jobs:
@@ -33,7 +30,7 @@ jobs:
3330
- deps-{{ arch }}
3431
- run:
3532
name: "Install Dependencies"
36-
command: composer2 update --prefer-dist --no-progress --no-suggest --no-interaction << parameters.composer-opts >>
33+
command: composer update --prefer-dist --no-progress --no-interaction << parameters.composer-opts >>
3734
- save_cache:
3835
key: deps-{{ arch }}
3936
paths:
@@ -45,7 +42,7 @@ jobs:
4542
name: "Test"
4643
command: |
4744
mkdir -p ~/phpunit
48-
./bin/phpunit --testsuite unit --log-junit ~/phpunit/phpunit.xml
45+
./bin/phpunit --log-junit ~/phpunit/phpunit.xml
4946
- store_test_results:
5047
path: ~/phpunit
5148
- store_artifacts:

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
}
1515
],
1616
"require": {
17-
"php": "^7.4||^8.0",
18-
"phpunit/phpunit": "^9.5",
19-
"symfony/console": "^3.4||^4.4||^5||^6||^7"
17+
"php": "^8.1",
18+
"phpunit/phpunit": "^10.5",
19+
"symfony/console": "^6.4||^7"
2020
},
2121
"require-dev": {
2222
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",

phpunit.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,7 @@
44
or your current system user. See core/tests/README.md and
55
https://www.drupal.org/node/2116263 for details.
66
-->
7-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" colors="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" beStrictAboutChangesToGlobalState="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
8-
<coverage>
9-
<include>
10-
<directory>./src</directory>
11-
</include>
12-
<exclude>
13-
<directory suffix="Test.php">./</directory>
14-
<directory suffix="TestBase.php">./</directory>
15-
</exclude>
16-
</coverage>
7+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" colors="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" beStrictAboutChangesToGlobalState="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
178
<php>
189
<!-- Set error reporting to E_ALL. -->
1910
<ini name="error_reporting" value="32767"/>
@@ -27,4 +18,13 @@
2718
</testsuite>
2819
</testsuites>
2920
<!-- Filter for coverage reports. -->
21+
<source>
22+
<include>
23+
<directory>./src</directory>
24+
</include>
25+
<exclude>
26+
<directory suffix="Test.php">./</directory>
27+
<directory suffix="TestBase.php">./</directory>
28+
</exclude>
29+
</source>
3030
</phpunit>

src/FinderCommand.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
namespace PhpUnitFinder;
44

55
use PHPUnit\Framework\TestCase;
6-
use PHPUnit\TextUI\TestSuiteMapper;
6+
use PHPUnit\TextUI\CliArguments\Builder;
7+
use PHPUnit\TextUI\Configuration\Registry;
78
use PHPUnit\TextUI\XmlConfiguration\Loader;
9+
use PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper;
810
use Symfony\Component\Console\Command\Command;
911
use Symfony\Component\Console\Input\InputArgument;
1012
use Symfony\Component\Console\Input\InputInterface;
@@ -28,7 +30,7 @@ protected function configure() {
2830
/**
2931
* {@inheritdoc}
3032
*/
31-
protected function execute(InputInterface $input, OutputInterface $output) {
33+
protected function execute(InputInterface $input, OutputInterface $output): int {
3234
$configFile = $input->getOption('config-file');
3335
$bootstrap = $input->getOption('bootstrap-file');
3436
include_once $bootstrap;
@@ -37,11 +39,16 @@ protected function execute(InputInterface $input, OutputInterface $output) {
3739

3840
$config = (new Loader())->load($configFile);
3941

42+
Registry::init(
43+
(new Builder)->fromParameters([]),
44+
$config,
45+
);
46+
4047
foreach ($config->testSuite() as $suite) {
4148
if ($testSuites && !in_array($suite->name(), $testSuites, TRUE)) {
4249
continue;
4350
}
44-
$testSuite = (new TestSuiteMapper)->map($config->testSuite(), $suite->name());
51+
$testSuite = (new TestSuiteMapper())->map($config->filename(), $config->testSuite(), $suite->name(), '');
4552
foreach (new \RecursiveIteratorIterator($testSuite) as $test) {
4653
if ($test instanceof TestCase) {
4754
$testFilenames[] = ((new \ReflectionClass($test))->getFileName());

tests/bootstrap.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
* @file
55
* Boostrap for PHPUnit.
66
*/
7-
8-
assert_options(ASSERT_ACTIVE, FALSE);
9-
107
$autoloader = __DIR__ . '/../vendor/autoload.php';
118
$loader = require $autoloader;
129

0 commit comments

Comments
 (0)