Skip to content

Commit 10b1fc9

Browse files
authored
Merge pull request #7 from previousnext/allow-phpunit-9
Allow phpunit 9
2 parents 9269877 + 1f6b4b3 commit 10b1fc9

File tree

4 files changed

+33
-44
lines changed

4 files changed

+33
-44
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
}
1414
],
1515
"require": {
16-
"php": "^7.2||^8.0",
17-
"phpunit/phpunit": "^6.4||^7.0||^8.0",
16+
"php": "^7.4||^8.0",
17+
"phpunit/phpunit": "^9.5",
1818
"symfony/console": "^3.4||^4.4"
1919
},
2020
"require-dev": {

phpunit.xml

+10-18
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
32
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
43
<!-- PHPUnit expects functional tests to be run with either a privileged user
54
or your current system user. See core/tests/README.md and
65
https://www.drupal.org/node/2116263 for details.
76
-->
8-
<phpunit bootstrap="tests/bootstrap.php" colors="true"
9-
beStrictAboutTestsThatDoNotTestAnything="true"
10-
beStrictAboutOutputDuringTests="true"
11-
beStrictAboutChangesToGlobalState="true">
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>
1217
<php>
1318
<!-- Set error reporting to E_ALL. -->
1419
<ini name="error_reporting" value="32767"/>
@@ -20,19 +25,6 @@
2025
<testsuite name="unit">
2126
<directory>./tests/Unit</directory>
2227
</testsuite>
23-
<testsuite name="functional">
24-
<directory>./tests/Functional</directory>
25-
</testsuite>
2628
</testsuites>
2729
<!-- Filter for coverage reports. -->
28-
<filter>
29-
<whitelist>
30-
<directory>./src</directory>
31-
<!-- By definition test classes have no tests. -->
32-
<exclude>
33-
<directory suffix="Test.php">./</directory>
34-
<directory suffix="TestBase.php">./</directory>
35-
</exclude>
36-
</whitelist>
37-
</filter>
3830
</phpunit>

src/FinderCommand.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
namespace PhpUnitFinder;
44

55
use PHPUnit\Framework\TestCase;
6-
use PHPUnit\Util\Configuration;
6+
use PHPUnit\TextUI\TestSuiteMapper;
7+
use PHPUnit\TextUI\XmlConfiguration\Loader;
78
use Symfony\Component\Console\Command\Command;
89
use Symfony\Component\Console\Input\InputArgument;
910
use Symfony\Component\Console\Input\InputInterface;
@@ -33,19 +34,20 @@ protected function execute(InputInterface $input, OutputInterface $output) {
3334
include_once $bootstrap;
3435
$testSuites = $input->getArgument('test-suite');
3536

36-
$config = Configuration::getInstance($configFile);
37-
if (empty($testSuites)) {
38-
$testSuites = $config->getTestSuiteNames();
39-
}
40-
$testFilenames = [];
41-
foreach ($testSuites as $suiteName) {
42-
$suite = $config->getTestSuiteConfiguration($suiteName);
43-
foreach (new \RecursiveIteratorIterator($suite->getIterator()) as $test) {
37+
$config = (new Loader())->load($configFile);
38+
39+
foreach ($config->testSuite() as $suite) {
40+
if ($testSuites && !in_array($suite->name(), $testSuites, TRUE)) {
41+
continue;
42+
}
43+
$testSuite = (new TestSuiteMapper)->map($config->testSuite(), $suite->name());
44+
foreach (new \RecursiveIteratorIterator($testSuite) as $test) {
4445
if ($test instanceof TestCase) {
4546
$testFilenames[] = ((new \ReflectionClass($test))->getFileName());
4647
}
4748
}
4849
}
50+
4951
$testFilenames = array_unique($testFilenames);
5052
foreach ($testFilenames as $testFilename) {
5153
$output->writeln($testFilename);

tests/fixtures/phpunit.xml

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
32
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
43
<!-- PHPUnit expects functional tests to be run with either a privileged user
54
or your current system user. See core/tests/README.md and
65
https://www.drupal.org/node/2116263 for details.
76
-->
8-
<phpunit bootstrap="tests/bootstrap.php" colors="true"
9-
beStrictAboutTestsThatDoNotTestAnything="true"
10-
beStrictAboutOutputDuringTests="true"
11-
beStrictAboutChangesToGlobalState="true">
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>
1217
<php>
1318
<!-- Set error reporting to E_ALL. -->
1419
<ini name="error_reporting" value="32767"/>
@@ -25,14 +30,4 @@
2530
</testsuite>
2631
</testsuites>
2732
<!-- Filter for coverage reports. -->
28-
<filter>
29-
<whitelist>
30-
<directory>./src</directory>
31-
<!-- By definition test classes have no tests. -->
32-
<exclude>
33-
<directory suffix="Test.php">./</directory>
34-
<directory suffix="TestBase.php">./</directory>
35-
</exclude>
36-
</whitelist>
37-
</filter>
3833
</phpunit>

0 commit comments

Comments
 (0)