From 55f6b5696e946464c4c22a39c96ac7d5ce0c401f Mon Sep 17 00:00:00 2001 From: Morten Harders Date: Tue, 21 May 2024 08:13:20 +0200 Subject: [PATCH 1/4] Added toBeList expectation --- src/Mixins/Expectation.php | 12 ++++++++++++ tests/Features/Expect/toBeList.php | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/Features/Expect/toBeList.php diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index 71117657..ffaeea30 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -467,6 +467,18 @@ final class Expectation return $this; } + /** + * Asserts that the value is a list. + * + * @return self + */ + public function toBeList(string $message = ''): self + { + Assert::assertIsList($this->value, $message); + + return $this; + } + /** * Asserts that the value is of type bool. * diff --git a/tests/Features/Expect/toBeList.php b/tests/Features/Expect/toBeList.php new file mode 100644 index 00000000..a10115da --- /dev/null +++ b/tests/Features/Expect/toBeList.php @@ -0,0 +1,20 @@ +toBeList(); + expect(['a' => 1, 'b' => 2, 'c' => 3])->not->toBeList(); +}); + +test('failures', function () { + expect(null)->toBeList(); +})->throws(ExpectationFailedException::class); + +test('failures with custom message', function () { + expect(null)->toBeList('oh no!'); +})->throws(ExpectationFailedException::class, 'oh no!'); + +test('not failures', function () { + expect(['a', 'b', 'c'])->not->toBeList(); +})->throws(ExpectationFailedException::class); From 3c6c89a6ade4dab9884e78e77dfd49fd85af13c0 Mon Sep 17 00:00:00 2001 From: Morten Harders Date: Tue, 21 May 2024 08:15:32 +0200 Subject: [PATCH 2/4] Added test to toBeList --- tests/Features/Expect/toBeList.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Features/Expect/toBeList.php b/tests/Features/Expect/toBeList.php index a10115da..095fda9d 100644 --- a/tests/Features/Expect/toBeList.php +++ b/tests/Features/Expect/toBeList.php @@ -5,6 +5,7 @@ use PHPUnit\Framework\ExpectationFailedException; test('pass', function () { expect([1, 2, 3])->toBeList(); expect(['a' => 1, 'b' => 2, 'c' => 3])->not->toBeList(); + expect('1, 2, 3')->not->toBeList(); }); test('failures', function () { From 9fc607a2b886be0424bf5d56c1bd3dbac68f3b8b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 10 Jun 2024 22:52:21 +0100 Subject: [PATCH 3/4] Fixes wrong stub --- stubs/init-laravel/TestCase.php.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/init-laravel/TestCase.php.stub b/stubs/init-laravel/TestCase.php.stub index 2932d4a6..fe1ffc2f 100644 --- a/stubs/init-laravel/TestCase.php.stub +++ b/stubs/init-laravel/TestCase.php.stub @@ -6,5 +6,5 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { - use CreatesApplication; + // } From e8f122bf47585c06431e0056189ec6bfd6f41f57 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 10 Jun 2024 23:02:16 +0100 Subject: [PATCH 4/4] release: 2.34.8 --- composer.json | 4 ++-- src/Pest.php | 2 +- .../Help/visual_snapshot_of_help_command_output.snap | 2 +- .../Version/visual_snapshot_of_help_command_output.snap | 2 +- tests/.snapshots/success.txt | 8 +++++++- tests/Visual/Parallel.php | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 0dbb150f..a08ae7ce 100644 --- a/composer.json +++ b/composer.json @@ -52,8 +52,8 @@ }, "require-dev": { "pestphp/pest-dev-tools": "^2.16.0", - "pestphp/pest-plugin-type-coverage": "^2.8.1", - "symfony/process": "^6.4.0|^7.0.4" + "pestphp/pest-plugin-type-coverage": "^2.8.3", + "symfony/process": "^6.4.0|^7.1.1" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/src/Pest.php b/src/Pest.php index e14a51e3..6d85c02c 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '2.34.7'; + return '2.34.8'; } function testDirectory(string $file = ''): string 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 ace633a5..2fe3fafc 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 2.34.7. + Pest Testing Framework 2.34.8. USAGE: pest [options] 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 4afe228d..576b6425 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 2.34.7. + Pest Testing Framework 2.34.8. diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 1eb62e1d..2fbed06e 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -511,6 +511,12 @@ ✓ passes with strings ✓ failures ✓ failures with custom message + ✓ not failures + + PASS Tests\Features\Expect\toBeList + ✓ pass + ✓ failures + ✓ failures with custom message ✓ not failures PASS Tests\Features\Expect\toBeLowercase @@ -1418,4 +1424,4 @@ WARN Tests\Visual\Version - visual snapshot of help command output - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 20 skipped, 1009 passed (2395 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 20 skipped, 1013 passed (2405 assertions) \ No newline at end of file diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 3a9e8aac..29079723 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -16,7 +16,7 @@ $run = function () { test('parallel', function () use ($run) { expect($run('--exclude-group=integration')) - ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 994 passed (2348 assertions)') + ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 998 passed (2358 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows();