Skip to content

Commit

Permalink
Merge pull request #7 from previousnext/allow-phpunit-9
Browse files Browse the repository at this point in the history
Allow phpunit 9
  • Loading branch information
larowlan authored Jun 21, 2021
2 parents 9269877 + 1f6b4b3 commit 10b1fc9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 44 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
}
],
"require": {
"php": "^7.2||^8.0",
"phpunit/phpunit": "^6.4||^7.0||^8.0",
"php": "^7.4||^8.0",
"phpunit/phpunit": "^9.5",
"symfony/console": "^3.4||^4.4"
},
"require-dev": {
Expand Down
28 changes: 10 additions & 18 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
<!-- PHPUnit expects functional tests to be run with either a privileged user
or your current system user. See core/tests/README.md and
https://www.drupal.org/node/2116263 for details.
-->
<phpunit bootstrap="tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true">
<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">
<coverage>
<include>
<directory>./src</directory>
</include>
<exclude>
<directory suffix="Test.php">./</directory>
<directory suffix="TestBase.php">./</directory>
</exclude>
</coverage>
<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
Expand All @@ -20,19 +25,6 @@
<testsuite name="unit">
<directory>./tests/Unit</directory>
</testsuite>
<testsuite name="functional">
<directory>./tests/Functional</directory>
</testsuite>
</testsuites>
<!-- Filter for coverage reports. -->
<filter>
<whitelist>
<directory>./src</directory>
<!-- By definition test classes have no tests. -->
<exclude>
<directory suffix="Test.php">./</directory>
<directory suffix="TestBase.php">./</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
20 changes: 11 additions & 9 deletions src/FinderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
namespace PhpUnitFinder;

use PHPUnit\Framework\TestCase;
use PHPUnit\Util\Configuration;
use PHPUnit\TextUI\TestSuiteMapper;
use PHPUnit\TextUI\XmlConfiguration\Loader;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -33,19 +34,20 @@ protected function execute(InputInterface $input, OutputInterface $output) {
include_once $bootstrap;
$testSuites = $input->getArgument('test-suite');

$config = Configuration::getInstance($configFile);
if (empty($testSuites)) {
$testSuites = $config->getTestSuiteNames();
}
$testFilenames = [];
foreach ($testSuites as $suiteName) {
$suite = $config->getTestSuiteConfiguration($suiteName);
foreach (new \RecursiveIteratorIterator($suite->getIterator()) as $test) {
$config = (new Loader())->load($configFile);

foreach ($config->testSuite() as $suite) {
if ($testSuites && !in_array($suite->name(), $testSuites, TRUE)) {
continue;
}
$testSuite = (new TestSuiteMapper)->map($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);
Expand Down
25 changes: 10 additions & 15 deletions tests/fixtures/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
<!-- PHPUnit expects functional tests to be run with either a privileged user
or your current system user. See core/tests/README.md and
https://www.drupal.org/node/2116263 for details.
-->
<phpunit bootstrap="tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true">
<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">
<coverage>
<include>
<directory>./src</directory>
</include>
<exclude>
<directory suffix="Test.php">./</directory>
<directory suffix="TestBase.php">./</directory>
</exclude>
</coverage>
<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
Expand All @@ -25,14 +30,4 @@
</testsuite>
</testsuites>
<!-- Filter for coverage reports. -->
<filter>
<whitelist>
<directory>./src</directory>
<!-- By definition test classes have no tests. -->
<exclude>
<directory suffix="Test.php">./</directory>
<directory suffix="TestBase.php">./</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

0 comments on commit 10b1fc9

Please sign in to comment.