From 791734a29cf597beec9d44309fcf6f7a83b9fa97 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 20 Apr 2025 22:19:25 +0100 Subject: [PATCH] Fixes tests --- composer.json | 10 +- src/Pest.php | 2 +- .../Parallel/Paratest/WrapperRunner.php | 5 + .../Parallel/Support/CompactPrinter.php | 16 +-- ...isual_snapshot_of_help_command_output.snap | 4 +- ...isual_snapshot_of_help_command_output.snap | 2 +- tests/Arch.php | 98 +++++++++---------- tests/Unit/Preset.php | 2 +- 8 files changed, 73 insertions(+), 66 deletions(-) diff --git a/composer.json b/composer.json index 62e09636..d2a1461f 100644 --- a/composer.json +++ b/composer.json @@ -76,11 +76,11 @@ "test:lint": "pint --test", "test:type:check": "phpstan analyse --ansi --memory-limit=-1 --debug", "test:type:coverage": "php -d memory_limit=-1 bin/pest --type-coverage --min=100", - "test:unit": "php bin/pest --colors=always --exclude-group=integration --compact", - "test:inline": "php bin/pest --colors=always --configuration=phpunit.inline.xml", - "test:parallel": "php bin/pest --colors=always --exclude-group=integration --parallel --processes=3", - "test:integration": "php bin/pest --colors=always --group=integration -v", - "update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always --update-snapshots", + "test:unit": "php bin/pest --exclude-group=integration --compact", + "test:inline": "php bin/pest --configuration=phpunit.inline.xml", + "test:parallel": "php bin/pest --exclude-group=integration --parallel --processes=3", + "test:integration": "php bin/pest --group=integration -v", + "update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --update-snapshots", "test": [ "@test:refacto", "@test:lint", diff --git a/src/Pest.php b/src/Pest.php index db27e206..d23cfd5c 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '3.8.2'; + return '4.0.0-alpha.1'; } function testDirectory(string $file = ''): string diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 282749d3..48c88e7b 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -313,6 +313,7 @@ final class WrapperRunner implements RunnerInterface $testResult = unserialize($contents); assert($testResult instanceof TestResult); + $testResultSum = new TestResult( (int) $testResultSum->hasTests() + (int) $testResult->hasTests(), $testResultSum->numberOfTestsRun() + $testResult->numberOfTestsRun(), @@ -325,8 +326,10 @@ final class WrapperRunner implements RunnerInterface array_merge_recursive($testResultSum->testMarkedIncompleteEvents(), $testResult->testMarkedIncompleteEvents()), array_merge_recursive($testResultSum->testTriggeredPhpunitDeprecationEvents(), $testResult->testTriggeredPhpunitDeprecationEvents()), array_merge_recursive($testResultSum->testTriggeredPhpunitErrorEvents(), $testResult->testTriggeredPhpunitErrorEvents()), + array_merge_recursive($testResultSum->testTriggeredPhpunitNoticeEvents(), $testResult->testTriggeredPhpunitNoticeEvents()), array_merge_recursive($testResultSum->testTriggeredPhpunitWarningEvents(), $testResult->testTriggeredPhpunitWarningEvents()), array_merge_recursive($testResultSum->testRunnerTriggeredDeprecationEvents(), $testResult->testRunnerTriggeredDeprecationEvents()), + array_merge_recursive($testResultSum->testRunnerTriggeredNoticeEvents(), $testResult->testRunnerTriggeredNoticeEvents()), array_merge_recursive($testResultSum->testRunnerTriggeredWarningEvents(), $testResult->testRunnerTriggeredWarningEvents()), array_merge_recursive($testResultSum->errors(), $testResult->errors()), array_merge_recursive($testResultSum->deprecations(), $testResult->deprecations()), @@ -351,8 +354,10 @@ final class WrapperRunner implements RunnerInterface $testResultSum->testMarkedIncompleteEvents(), $testResultSum->testTriggeredPhpunitDeprecationEvents(), $testResultSum->testTriggeredPhpunitErrorEvents(), + $testResultSum->testTriggeredPhpunitNoticeEvents(), $testResultSum->testTriggeredPhpunitWarningEvents(), $testResultSum->testRunnerTriggeredDeprecationEvents(), + $testResultSum->testRunnerTriggeredNoticeEvents(), array_values(array_filter( $testResultSum->testRunnerTriggeredWarningEvents(), fn (WarningTriggered $event): bool => ! str_contains($event->message(), 'No tests found') diff --git a/src/Plugins/Parallel/Support/CompactPrinter.php b/src/Plugins/Parallel/Support/CompactPrinter.php index 25226b10..bc2e1c3f 100644 --- a/src/Plugins/Parallel/Support/CompactPrinter.php +++ b/src/Plugins/Parallel/Support/CompactPrinter.php @@ -131,14 +131,14 @@ final class CompactPrinter $status['collected'], $status['threshold'], $status['roots'], - null, - null, - null, - null, - null, - null, - null, - null, + 0.00, + 0.00, + 0.00, + 0.00, + false, + false, + false, + 0, ); $telemetry = new Info( diff --git a/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap b/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap index da7acad7..9966d901 100644 --- a/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap +++ b/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap @@ -1,5 +1,5 @@ - Pest Testing Framework 3.8.2. + Pest Testing Framework 4.0.0-alpha.1. USAGE: pest [options] @@ -68,6 +68,7 @@ --fail-on-risky Signal failure using shell exit code when a test was considered risky --fail-on-deprecation Signal failure using shell exit code when a deprecation was triggered --fail-on-phpunit-deprecation Signal failure using shell exit code when a PHPUnit deprecation was triggered + --fail-on-phpunit-notice Signal failure using shell exit code when a PHPUnit notice was triggered --fail-on-notice Signal failure using shell exit code when a notice was triggered --fail-on-skipped Signal failure using shell exit code when a test was skipped --fail-on-incomplete Signal failure using shell exit code when a test was marked incomplete @@ -88,6 +89,7 @@ --display-skipped ........................ Display details for skipped tests --display-deprecations . Display details for deprecations triggered by tests --display-phpunit-deprecations .... Display details for PHPUnit deprecations + --display-phpunit-notices .............. Display details for PHPUnit notices --display-errors ............. Display details for errors triggered by tests --display-notices ........... Display details for notices triggered by tests --display-warnings ......... Display details for warnings triggered by tests diff --git a/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap b/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap index cd2d2cfb..c9dea0d5 100644 --- a/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap +++ b/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap @@ -1,3 +1,3 @@ - Pest Testing Framework 3.8.2. + Pest Testing Framework 4.0.0-alpha.1. diff --git a/tests/Arch.php b/tests/Arch.php index 4dcc983e..d8deb460 100644 --- a/tests/Arch.php +++ b/tests/Arch.php @@ -2,57 +2,57 @@ use Pest\Expectation; -// arch()->preset()->php()->ignoring([ -// Expectation::class, -// 'debug_backtrace', -// 'var_export', -// 'xdebug_info', -// ]); +arch()->preset()->php()->ignoring([ + Expectation::class, + 'debug_backtrace', + 'var_export', + 'xdebug_info', +]); -// arch()->preset()->strict()->ignoring([ -// 'usleep', -// ]); +arch()->preset()->strict()->ignoring([ + 'usleep', +]); -// arch()->preset()->security()->ignoring([ -// 'eval', -// 'str_shuffle', -// 'exec', -// 'unserialize', -// 'extract', -// 'assert', -// ]); +arch()->preset()->security()->ignoring([ + 'eval', + 'str_shuffle', + 'exec', + 'unserialize', + 'extract', + 'assert', +]); -// arch('globals') -// ->expect(['dd', 'dump', 'ray', 'die', 'var_dump', 'sleep']) -// ->not->toBeUsed() -// ->ignoring(Expectation::class); +arch('globals') + ->expect(['dd', 'dump', 'ray', 'die', 'var_dump', 'sleep']) + ->not->toBeUsed() + ->ignoring(Expectation::class); -// arch('dependencies') -// ->expect('Pest') -// ->toOnlyUse([ -// 'dd', -// 'dump', -// 'expect', -// 'uses', -// 'Termwind', -// 'ParaTest', -// 'Pest\Arch', -// 'Pest\Mutate\Contracts\Configuration', -// 'Pest\Mutate\Decorators\TestCallDecorator', -// 'Pest\Mutate\Repositories\ConfigurationRepository', -// 'Pest\Plugin', -// 'NunoMaduro\Collision', -// 'Whoops', -// 'Symfony\Component\Console', -// 'Symfony\Component\Process', -// ])->ignoring(['Composer', 'PHPUnit', 'SebastianBergmann']); +arch('dependencies') + ->expect('Pest') + ->toOnlyUse([ + 'dd', + 'dump', + 'expect', + 'uses', + 'Termwind', + 'ParaTest', + 'Pest\Arch', + 'Pest\Mutate\Contracts\Configuration', + 'Pest\Mutate\Decorators\TestCallDecorator', + 'Pest\Mutate\Repositories\ConfigurationRepository', + 'Pest\Plugin', + 'NunoMaduro\Collision', + 'Whoops', + 'Symfony\Component\Console', + 'Symfony\Component\Process', + ])->ignoring(['Composer', 'PHPUnit', 'SebastianBergmann']); -// arch('contracts') -// ->expect('Pest\Contracts') -// ->toOnlyUse([ -// 'NunoMaduro\Collision\Contracts', -// 'Pest\Factories\TestCaseMethodFactory', -// 'Symfony\Component\Console', -// 'Pest\Arch\Contracts', -// 'Pest\PendingCalls', -// ])->toBeInterfaces(); +arch('contracts') + ->expect('Pest\Contracts') + ->toOnlyUse([ + 'NunoMaduro\Collision\Contracts', + 'Pest\Factories\TestCaseMethodFactory', + 'Symfony\Component\Console', + 'Pest\Arch\Contracts', + 'Pest\PendingCalls', + ])->toBeInterfaces(); diff --git a/tests/Unit/Preset.php b/tests/Unit/Preset.php index e777982b..bdf461a7 100644 --- a/tests/Unit/Preset.php +++ b/tests/Unit/Preset.php @@ -10,4 +10,4 @@ test('preset invalid name', function () { $this->preset()->myAnotherFramework(); })->throws(InvalidArgumentException::class, 'The preset [myAnotherFramework] does not exist. The available presets are [php, laravel, strict, security, relaxed, myFramework].'); -// arch()->preset()->myFramework(); +arch()->preset()->myFramework();