Skip to content

Commit

Permalink
Adds phpunit/[email protected] support
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Aug 4, 2023
1 parent 69a0719 commit c67a90d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@
"nunomaduro/larastan": "^2.6.3",
"orchestra/testbench-core": "^8.5.8",
"pestphp/pest": "^2.8.1",
"phpunit/phpunit": "^10.2.2",
"phpunit/phpunit": "^10.3.1",
"sebastian/environment": "^6.0.1",
"spatie/laravel-ignition": "^2.2.0"
},
"conflict": {
"phpunit/phpunit": "<10.1.2"
},
"autoload-dev": {
"psr-4": {
"Tests\\Printer\\": "tests/Printer",
Expand Down
5 changes: 4 additions & 1 deletion src/Adapters/Phpunit/Printers/DefaultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use NunoMaduro\Collision\Adapters\Phpunit\ConfigureIO;
use NunoMaduro\Collision\Adapters\Phpunit\State;
use NunoMaduro\Collision\Adapters\Phpunit\Style;
use NunoMaduro\Collision\Adapters\Phpunit\Support\ResultReflection;
use NunoMaduro\Collision\Adapters\Phpunit\TestResult;
use NunoMaduro\Collision\Exceptions\ShouldNotHappen;
use NunoMaduro\Collision\Exceptions\TestOutcome;
Expand Down Expand Up @@ -368,7 +369,9 @@ public function testRunnerExecutionFinished(ExecutionFinished $event): void
{
$result = Facade::result();

if (Facade::result()->numberOfTests() === 0) {


if (ResultReflection::numberOfTests(Facade::result()) === 0) {
$this->output->writeln([
'',
' <fg=white;options=bold;bg=blue> INFO </> No tests found.',
Expand Down
3 changes: 2 additions & 1 deletion src/Adapters/Phpunit/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Closure;
use NunoMaduro\Collision\Adapters\Phpunit\Printers\DefaultPrinter;
use NunoMaduro\Collision\Adapters\Phpunit\Support\ResultReflection;
use NunoMaduro\Collision\Exceptions\ShouldNotHappen;
use NunoMaduro\Collision\Exceptions\TestException;
use NunoMaduro\Collision\Exceptions\TestOutcome;
Expand Down Expand Up @@ -240,7 +241,7 @@ public function writeRecap(State $state, Info $telemetry, PHPUnitTestResult $res
}
}

$pending = $result->numberOfTests() - $result->numberOfTestsRun();
$pending = ResultReflection::numberOfTests($result) - $result->numberOfTestsRun();
if ($pending > 0) {
$tests[] = "\e[2m$pending pending\e[22m";
}
Expand Down
21 changes: 21 additions & 0 deletions src/Adapters/Phpunit/Support/ResultReflection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace NunoMaduro\Collision\Adapters\Phpunit\Support;

use PHPUnit\TestRunner\TestResult\TestResult;

/**
* @internal
*/
final class ResultReflection
{
/**
* The number of processed tests.
*/
public static function numberOfTests(TestResult $testResult): int
{
return (fn () => $this->numberOfTests)->call($testResult);
}
}

0 comments on commit c67a90d

Please sign in to comment.