Skip to content

Commit b9a0560

Browse files
Merge branch '11.5' into 12.1
2 parents 4f667f9 + 206e599 commit b9a0560

12 files changed

+212
-11
lines changed

src/TextUI/Command/Commands/ListTestSuitesCommand.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace PHPUnit\TextUI\Command;
1111

1212
use const PHP_EOL;
13+
use function assert;
1314
use function count;
1415
use function ksort;
1516
use function sprintf;
@@ -36,9 +37,7 @@ public function execute(): Result
3637
$suites = [];
3738

3839
foreach ($this->testSuite->tests() as $test) {
39-
if (!$test instanceof TestSuite) {
40-
continue;
41-
}
40+
assert($test instanceof TestSuite);
4241

4342
$suites[$test->name()] = count($test->collect());
4443
}
@@ -70,20 +69,24 @@ private function warnAboutConflictingOptions(): string
7069

7170
$configuration = Registry::get();
7271

72+
if ($configuration->hasDefaultTestSuite()) {
73+
$buffer .= 'The defaultTestSuite (XML) and --list-suites (CLI) options cannot be combined, only the default test suite is shown' . PHP_EOL;
74+
}
75+
76+
if ($configuration->includeTestSuite() !== '' && !$configuration->hasDefaultTestSuite()) {
77+
$buffer .= 'The --testsuite and --list-suites options cannot be combined, --testsuite is ignored' . PHP_EOL;
78+
}
79+
7380
if ($configuration->hasFilter()) {
7481
$buffer .= 'The --filter and --list-suites options cannot be combined, --filter is ignored' . PHP_EOL;
7582
}
7683

7784
if ($configuration->hasGroups()) {
78-
$buffer .= 'The --group and --list-suites options cannot be combined, --group is ignored' . PHP_EOL;
85+
$buffer .= 'The --group (CLI) and <groups> (XML) options cannot be combined with --list-suites, --group and <groups> are ignored' . PHP_EOL;
7986
}
8087

8188
if ($configuration->hasExcludeGroups()) {
82-
$buffer .= 'The --exclude-group and --list-suites options cannot be combined, --exclude-group is ignored' . PHP_EOL;
83-
}
84-
85-
if ($configuration->includeTestSuite() !== '') {
86-
$buffer .= 'The --testsuite and --list-suites options cannot be combined, --exclude-group is ignored' . PHP_EOL;
89+
$buffer .= 'The --exclude-group (CLI) and <groups> (XML) options cannot be combined with --list-suites, --exclude-group and <groups> are ignored' . PHP_EOL;
8790
}
8891

8992
if ($buffer !== '') {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="../../../../phpunit.xsd"
4+
defaultTestSuite="unit">
5+
<testsuites>
6+
<testsuite name="unit">
7+
<directory>tests/unit</directory>
8+
</testsuite>
9+
10+
<testsuite name="end-to-end">
11+
<directory>tests/end-to-end</directory>
12+
</testsuite>
13+
</testsuites>
14+
</phpunit>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="../../../../phpunit.xsd">
4+
<testsuites>
5+
<testsuite name="unit">
6+
<directory>tests/unit</directory>
7+
</testsuite>
8+
9+
<testsuite name="end-to-end">
10+
<directory>tests/end-to-end</directory>
11+
</testsuite>
12+
</testsuites>
13+
14+
<groups>
15+
<exclude>
16+
<group>default</group>
17+
</exclude>
18+
</groups>
19+
</phpunit>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="../../../../phpunit.xsd">
4+
<testsuites>
5+
<testsuite name="unit">
6+
<directory>tests/unit</directory>
7+
</testsuite>
8+
9+
<testsuite name="end-to-end">
10+
<directory>tests/end-to-end</directory>
11+
</testsuite>
12+
</testsuites>
13+
14+
<groups>
15+
<include>
16+
<group>default</group>
17+
</include>
18+
</groups>
19+
</phpunit>

tests/end-to-end/cli/list-suites.phpt renamed to tests/end-to-end/cli/list-suites/happy-path.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ phpunit --configuration ../_files/multiple-testsuites/phpunit.xml --list-suites
44
<?php declare(strict_types=1);
55
$_SERVER['argv'][] = '--do-not-cache-result';
66
$_SERVER['argv'][] = '--configuration';
7-
$_SERVER['argv'][] = __DIR__ . '/../_files/multiple-testsuites/phpunit.xml';
7+
$_SERVER['argv'][] = __DIR__ . '/../../_files/multiple-testsuites/phpunit.xml';
88
$_SERVER['argv'][] = '--list-suites';
99

10-
require_once __DIR__ . '/../../bootstrap.php';
10+
require_once __DIR__ . '/../../../bootstrap.php';
1111

1212
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
1313
--EXPECTF--
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
phpunit --configuration ../_files/multiple-testsuites/default-test-suite.xml --list-suites
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/../../_files/multiple-testsuites/default-test-suite.xml';
8+
$_SERVER['argv'][] = '--list-suites';
9+
10+
require_once __DIR__ . '/../../../bootstrap.php';
11+
12+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
13+
--EXPECTF--
14+
PHPUnit %s by Sebastian Bergmann and contributors.
15+
16+
The defaultTestSuite (XML) and --list-suites (CLI) options cannot be combined, only the default test suite is shown
17+
18+
Available test suite:
19+
- unit (1 test)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
phpunit --configuration ../_files/multiple-testsuites/phpunit.xml --exclude-group default --list-suites
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/../../_files/multiple-testsuites/phpunit.xml';
8+
$_SERVER['argv'][] = '--exclude-group';
9+
$_SERVER['argv'][] = 'default';
10+
$_SERVER['argv'][] = '--list-suites';
11+
12+
require_once __DIR__ . '/../../../bootstrap.php';
13+
14+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
15+
--EXPECTF--
16+
PHPUnit %s by Sebastian Bergmann and contributors.
17+
18+
The --exclude-group (CLI) and <groups> (XML) options cannot be combined with --list-suites, --exclude-group and <groups> are ignored
19+
20+
Available test suites:
21+
- end-to-end (1 test)
22+
- unit (1 test)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
phpunit --configuration ../_files/multiple-testsuites/exclude-group.xml --list-suites
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/../../_files/multiple-testsuites/exclude-group.xml';
8+
$_SERVER['argv'][] = '--list-suites';
9+
10+
require_once __DIR__ . '/../../../bootstrap.php';
11+
12+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
13+
--EXPECTF--
14+
PHPUnit %s by Sebastian Bergmann and contributors.
15+
16+
The --exclude-group (CLI) and <groups> (XML) options cannot be combined with --list-suites, --exclude-group and <groups> are ignored
17+
18+
Available test suites:
19+
- end-to-end (1 test)
20+
- unit (1 test)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
phpunit --configuration ../_files/multiple-testsuites/phpunit.xml --filter FooTest --list-suites
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/../../_files/multiple-testsuites/phpunit.xml';
8+
$_SERVER['argv'][] = '--filter';
9+
$_SERVER['argv'][] = 'FooTest';
10+
$_SERVER['argv'][] = '--list-suites';
11+
12+
require_once __DIR__ . '/../../../bootstrap.php';
13+
14+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
15+
--EXPECTF--
16+
PHPUnit %s by Sebastian Bergmann and contributors.
17+
18+
The --filter and --list-suites options cannot be combined, --filter is ignored
19+
20+
Available test suites:
21+
- end-to-end (1 test)
22+
- unit (1 test)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
phpunit --configuration ../_files/multiple-testsuites/phpunit.xml --group default --list-suites
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/../../_files/multiple-testsuites/phpunit.xml';
8+
$_SERVER['argv'][] = '--group';
9+
$_SERVER['argv'][] = 'default';
10+
$_SERVER['argv'][] = '--list-suites';
11+
12+
require_once __DIR__ . '/../../../bootstrap.php';
13+
14+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
15+
--EXPECTF--
16+
PHPUnit %s by Sebastian Bergmann and contributors.
17+
18+
The --group (CLI) and <groups> (XML) options cannot be combined with --list-suites, --group and <groups> are ignored
19+
20+
Available test suites:
21+
- end-to-end (1 test)
22+
- unit (1 test)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
phpunit --configuration ../_files/multiple-testsuites/include-group.xml --list-suites
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/../../_files/multiple-testsuites/include-group.xml';
8+
$_SERVER['argv'][] = '--list-suites';
9+
10+
require_once __DIR__ . '/../../../bootstrap.php';
11+
12+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
13+
--EXPECTF--
14+
PHPUnit %s by Sebastian Bergmann and contributors.
15+
16+
The --group (CLI) and <groups> (XML) options cannot be combined with --list-suites, --group and <groups> are ignored
17+
18+
Available test suites:
19+
- end-to-end (1 test)
20+
- unit (1 test)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
phpunit --configuration ../_files/multiple-testsuites/phpunit.xml --testsuite unit --list-suites
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/../../_files/multiple-testsuites/phpunit.xml';
8+
$_SERVER['argv'][] = '--testsuite';
9+
$_SERVER['argv'][] = 'unit';
10+
$_SERVER['argv'][] = '--list-suites';
11+
12+
require_once __DIR__ . '/../../../bootstrap.php';
13+
14+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
15+
--EXPECTF--
16+
PHPUnit %s by Sebastian Bergmann and contributors.
17+
18+
The --testsuite and --list-suites options cannot be combined, --testsuite is ignored
19+
20+
Available test suite:
21+
- unit (1 test)

0 commit comments

Comments
 (0)