Skip to content

Commit

Permalink
cover more code with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marac19901990 committed Dec 31, 2023
1 parent 7e8a5ae commit a0d23d0
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/TextUI/Command/Commands/ListGroupsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private function warnAboutConflictingOptions(): string
}

if ($configuration->includeTestSuite() !== '') {
$buffer .= 'The --testsuite and --list-groups options cannot be combined, --exclude-group is ignored' . PHP_EOL;
$buffer .= 'The --testsuite and --list-groups options cannot be combined, --testsuite is ignored' . PHP_EOL;
}

if (!empty($buffer)) {
Expand Down
48 changes: 48 additions & 0 deletions tests/end-to-end/cli/exclude-filter/match.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--TEST--
phpunit --exclude-filter one tests/FooTest.php
--FILE--
<?php declare(strict_types=1);
$traceFile = tempnam(sys_get_temp_dir(), __FILE__);

$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--no-output';
$_SERVER['argv'][] = '--log-events-text';
$_SERVER['argv'][] = $traceFile;
$_SERVER['argv'][] = '--exclude-filter';
$_SERVER['argv'][] = 'testone';
$_SERVER['argv'][] = __DIR__ . '/../../_files/groups/tests/FooTest.php';

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

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);

print file_get_contents($traceFile);

unlink($traceFile);
--EXPECTF--
PHPUnit Started (PHPUnit %s using %s)
Test Runner Configured
Test Suite Loaded (3 tests)
Event Facade Sealed
Test Runner Started
Test Suite Sorted
Test Suite Filtered (3 tests)
Test Runner Execution Started (3 tests)
Test Suite Started (PHPUnit\TestFixture\Groups\FooTest, 3 tests)
Test Preparation Started (PHPUnit\TestFixture\Groups\FooTest::testOne)
Test Prepared (PHPUnit\TestFixture\Groups\FooTest::testOne)
Test Passed (PHPUnit\TestFixture\Groups\FooTest::testOne)
Test Finished (PHPUnit\TestFixture\Groups\FooTest::testOne)
Test Preparation Started (PHPUnit\TestFixture\Groups\FooTest::testTwo)
Test Prepared (PHPUnit\TestFixture\Groups\FooTest::testTwo)
Test Passed (PHPUnit\TestFixture\Groups\FooTest::testTwo)
Test Finished (PHPUnit\TestFixture\Groups\FooTest::testTwo)
Test Preparation Started (PHPUnit\TestFixture\Groups\FooTest::testThree)
Test Prepared (PHPUnit\TestFixture\Groups\FooTest::testThree)
Test Passed (PHPUnit\TestFixture\Groups\FooTest::testThree)
Test Finished (PHPUnit\TestFixture\Groups\FooTest::testThree)
Test Suite Finished (PHPUnit\TestFixture\Groups\FooTest, 3 tests)
Test Runner Execution Finished
Test Runner Finished
PHPUnit Finished (Shell Exit Code: 0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
phpunit --list-groups --exclude-filter name
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--list-groups';
$_SERVER['argv'][] = '--exclude-filter';
$_SERVER['argv'][] = 'name';

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

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

The --exclude-filter and --list-groups options cannot be combined, --exclude-filter is ignored

Available test group(s):

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
phpunit --list-groups --exclude-group name
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--list-groups';
$_SERVER['argv'][] = '--exclude-group';
$_SERVER['argv'][] = 'name';

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

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

The --exclude-group and --list-groups options cannot be combined, --exclude-group is ignored

Available test group(s):

20 changes: 20 additions & 0 deletions tests/end-to-end/cli/group/failure/list-groups-and-filter.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
phpunit --list-groups --filter name
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--list-groups';
$_SERVER['argv'][] = '--filter';
$_SERVER['argv'][] = 'name';

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

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

The --filter and --list-groups options cannot be combined, --filter is ignored

Available test group(s):

20 changes: 20 additions & 0 deletions tests/end-to-end/cli/group/failure/list-groups-and-group.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
phpunit --list-groups --group name
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--list-groups';
$_SERVER['argv'][] = '--group';
$_SERVER['argv'][] = 'name';

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

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

The --group and --list-groups options cannot be combined, --group is ignored

Available test group(s):

20 changes: 20 additions & 0 deletions tests/end-to-end/cli/group/failure/list-groups-and-testsuite.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
phpunit --list-groups --testsuite name
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--list-groups';
$_SERVER['argv'][] = '--testsuite';
$_SERVER['argv'][] = 'name';

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

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

The --testsuite and --list-groups options cannot be combined, --testsuite is ignored

Available test group(s):

0 comments on commit a0d23d0

Please sign in to comment.