Skip to content

Commit

Permalink
Merge branch '10.5' into 11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jul 30, 2024
2 parents 68a4fff + 8f432cf commit 1cacb78
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog-11.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes of the PHPUnit 11.2 release series are documented in this fi
### Fixed

* [#5887](https://github.com/sebastianbergmann/phpunit/pull/5887): Issue baseline generator does not correctly handle ignoring suppressed issues
* [#5908](https://github.com/sebastianbergmann/phpunit/issues/5908): `--list-tests` and `--list-tests-xml` CLI options do not report error when data provider method throws exception

## [11.2.8] - 2024-07-18

Expand Down
33 changes: 31 additions & 2 deletions src/TextUI/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,40 @@ public function run(array $argv): int
// @codeCoverageIgnoreEnd
}

private function execute(Command\Command $command): never
private function execute(Command\Command $command, bool $requiresResultCollectedFromEvents = false): never
{
if ($requiresResultCollectedFromEvents) {
try {
TestResultFacade::init();
EventFacade::instance()->seal();

$resultCollectedFromEvents = TestResultFacade::result();
} catch (EventFacadeIsSealedException|UnknownSubscriberTypeException) {
}
}

print Version::getVersionString() . PHP_EOL . PHP_EOL;

$result = $command->execute();

print $result->output();

exit($result->shellExitCode());
$shellExitCode = $result->shellExitCode();

if (isset($resultCollectedFromEvents) &&
$resultCollectedFromEvents->hasTestTriggeredPhpunitErrorEvents()) {
$shellExitCode = Result::EXCEPTION;

print PHP_EOL . PHP_EOL . 'There were errors:' . PHP_EOL;

foreach ($resultCollectedFromEvents->testTriggeredPhpunitErrorEvents() as $events) {
foreach ($events as $event) {
print PHP_EOL . trim($event->message()) . PHP_EOL;
}
}
}

exit($shellExitCode);
}

private function loadBootstrapScript(string $filename): void
Expand Down Expand Up @@ -457,6 +482,7 @@ private function executeCommandsThatRequireTheTestSuite(Configuration $configura
$testSuite,
),
),
true,
);
}

Expand All @@ -468,6 +494,7 @@ private function executeCommandsThatRequireTheTestSuite(Configuration $configura
$testSuite,
),
),
true,
);
}

Expand All @@ -480,6 +507,7 @@ private function executeCommandsThatRequireTheTestSuite(Configuration $configura
),
$cliConfiguration->listTestsXml(),
),
true,
);
}

Expand All @@ -491,6 +519,7 @@ private function executeCommandsThatRequireTheTestSuite(Configuration $configura
$testSuite,
),
),
true,
);
}
}
Expand Down
27 changes: 27 additions & 0 deletions tests/end-to-end/regression/5908-list-tests-xml.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
https://github.com/sebastianbergmann/phpunit/issues/5908
--FILE--
<?php declare(strict_types=1);
$file = tempnam(sys_get_temp_dir(), __FILE__);

$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--list-tests-xml';
$_SERVER['argv'][] = $file;
$_SERVER['argv'][] = __DIR__ . '/5908/Issue5908Test.php';

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

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

unlink($file);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Wrote list of tests that would have been run to %s


There were errors:

The data provider specified for PHPUnit\TestFixture\Issue5908\Issue5908Test::testOne is invalid
message
22 changes: 22 additions & 0 deletions tests/end-to-end/regression/5908-list-tests.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
https://github.com/sebastianbergmann/phpunit/issues/5908
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--list-tests';
$_SERVER['argv'][] = __DIR__ . '/5908/Issue5908Test.php';

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

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

Available test(s):


There were errors:

The data provider specified for PHPUnit\TestFixture\Issue5908\Issue5908Test::testOne is invalid
message
27 changes: 27 additions & 0 deletions tests/end-to-end/regression/5908/Issue5908Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture\Issue5908;

use Exception;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class Issue5908Test extends TestCase
{
public static function provider(): array
{
throw new Exception('message');
}

#[DataProvider('provider')]
public function testOne(int $value): void
{
}
}

0 comments on commit 1cacb78

Please sign in to comment.