Skip to content

Commit

Permalink
Merge branch '10.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Aug 25, 2023
2 parents d0103c0 + 959ea41 commit 8847f0c
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 22 deletions.
42 changes: 22 additions & 20 deletions src/TextUI/Configuration/Xml/TestSuiteMapper.php
Expand Up @@ -10,6 +10,8 @@
namespace PHPUnit\TextUI\XmlConfiguration;

use const PHP_VERSION;
use function array_merge;
use function array_unique;
use function explode;
use function in_array;
use function is_dir;
Expand Down Expand Up @@ -52,34 +54,32 @@ public function map(string $xmlConfigurationFile, TestSuiteCollection $configura
continue;
}

$testSuite = TestSuiteObject::empty($testSuiteConfiguration->name());
$testSuiteEmpty = true;

$exclude = [];

foreach ($testSuiteConfiguration->exclude()->asArray() as $file) {
$exclude[] = $file->path();
}

$files = [];

foreach ($testSuiteConfiguration->directories() as $directory) {
if (!str_contains($directory->path(), '*') && !is_dir($directory->path())) {
throw new TestDirectoryNotFoundException($directory->path());
}

if (!version_compare(PHP_VERSION, $directory->phpVersion(), $directory->phpVersionOperator()->asString())) {
continue;
}

$files = (new Facade)->getFilesAsArray(
$directory->path(),
$directory->suffix(),
$directory->prefix(),
$exclude,
$files = array_merge(
$files,
(new Facade)->getFilesAsArray(
$directory->path(),
$directory->suffix(),
$directory->prefix(),
$exclude,
),
);

if (!empty($files)) {
$testSuite->addTestFiles($files);

$testSuiteEmpty = false;
} elseif (!str_contains($directory->path(), '*') && !is_dir($directory->path())) {
throw new TestDirectoryNotFoundException($directory->path());
}
}

foreach ($testSuiteConfiguration->files() as $file) {
Expand All @@ -91,12 +91,14 @@ public function map(string $xmlConfigurationFile, TestSuiteCollection $configura
continue;
}

$testSuite->addTestFile($file->path());

$testSuiteEmpty = false;
$files[] = $file->path();
}

if (!$testSuiteEmpty) {
if (!empty($files)) {
$testSuite = TestSuiteObject::empty($testSuiteConfiguration->name());

$testSuite->addTestFiles(array_unique($files));

$result->addTest($testSuite);
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/end-to-end/generic/dataprovider-issue-2859.phpt
Expand Up @@ -14,8 +14,8 @@ PHPUnit %s by Sebastian Bergmann and contributors.
Runtime: %s
Configuration: %s

.. 2 / 2 (100%)
. 1 / 1 (100%)

Time: %s, Memory: %s

OK (2 tests, 2 assertions)
OK (1 test, 1 assertion)
21 changes: 21 additions & 0 deletions tests/end-to-end/regression/5487.phpt
@@ -0,0 +1,21 @@
--TEST--
https://github.com/sebastianbergmann/phpunit/issues/5487
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = __DIR__ . '/5487';

require_once __DIR__ . '/../../bootstrap.php';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s
Configuration: %s

.. 2 / 2 (100%)

Time: %s, Memory: %s

OK (2 tests, 2 assertions)
11 changes: 11 additions & 0 deletions tests/end-to-end/regression/5487/phpunit.xml
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../phpunit.xsd">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
<directory>tests/foo</directory>
<directory>tests/bar</directory>
</testsuite>
</testsuites>
</phpunit>
20 changes: 20 additions & 0 deletions tests/end-to-end/regression/5487/tests/bar/BarTest.php
@@ -0,0 +1,20 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture\Issue5487;

use PHPUnit\Framework\TestCase;

final class BarTest extends TestCase
{
public function testOne(): void
{
$this->assertTrue(true);
}
}
20 changes: 20 additions & 0 deletions tests/end-to-end/regression/5487/tests/foo/FooTest.php
@@ -0,0 +1,20 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture\Issue5487;

use PHPUnit\Framework\TestCase;

final class FooTest extends TestCase
{
public function testOne(): void
{
$this->assertTrue(true);
}
}

0 comments on commit 8847f0c

Please sign in to comment.