From ea967b439f9d987ba0711e41b031ca02dcb33a99 Mon Sep 17 00:00:00 2001 From: AJ Meireles Date: Mon, 17 Jul 2023 11:08:00 -0300 Subject: [PATCH 01/46] Feature: Introducing The Ability to Dump Conditionally --- src/Expectation.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/Expectation.php b/src/Expectation.php index cb9b0361..1733541c 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -118,6 +118,48 @@ final class Expectation exit(1); } + /** + * Dump the expectation value when the result of the condition is truthy. + * + * @param bool $boolean + * @return never + */ + public function ddWhen($boolean, mixed ...$arguments): void + { + if (! $boolean) { + return; + } + + if (function_exists('dd')) { + dd($this->value, ...$arguments); + } + + var_dump($this->value); + + exit(1); + } + + /** + * Dump the expectation value when the result of the condition is falsy. + * + * @param bool $boolean + * @return never + */ + public function ddUnless($boolean, mixed ...$arguments): void + { + if ($boolean) { + return; + } + + if (function_exists('dd')) { + dd($this->value, ...$arguments); + } + + var_dump($this->value); + + exit(1); + } + /** * Send the expectation value to Ray along with all given arguments. * From 8abc0d192039b5328de4c4b050dfce2d64e2dd66 Mon Sep 17 00:00:00 2001 From: AJ Meireles Date: Mon, 17 Jul 2023 14:12:54 -0300 Subject: [PATCH 02/46] applying enhancement to use ddWhen inside ddUnless --- src/Expectation.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Expectation.php b/src/Expectation.php index 1733541c..5328052b 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -147,17 +147,7 @@ final class Expectation */ public function ddUnless($boolean, mixed ...$arguments): void { - if ($boolean) { - return; - } - - if (function_exists('dd')) { - dd($this->value, ...$arguments); - } - - var_dump($this->value); - - exit(1); + $this->ddWhen(! $boolean, ...$arguments); } /** From b00bc4d5ea8186b31ef2df14b16db0e8471591aa Mon Sep 17 00:00:00 2001 From: AJ Meireles Date: Mon, 17 Jul 2023 19:11:06 -0300 Subject: [PATCH 03/46] applying enhancement to use single dd function --- src/Expectation.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Expectation.php b/src/Expectation.php index 5328052b..c8f60d25 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -130,13 +130,7 @@ final class Expectation return; } - if (function_exists('dd')) { - dd($this->value, ...$arguments); - } - - var_dump($this->value); - - exit(1); + $this->dd($this->value, ...$arguments); } /** From 39e0d61dec25a21011e1393e8c42b0c2e481445f Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Thu, 27 Jul 2023 11:10:42 +0200 Subject: [PATCH 04/46] phpstan fix --- src/Expectation.php | 2 +- src/Expectations/OppositeExpectation.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Expectation.php b/src/Expectation.php index dc6a2d81..a868591a 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -430,7 +430,7 @@ final class Expectation { return Targeted::make( $this, - fn (ObjectDescription $object): bool => ! enum_exists($object->name) && $object->reflectionClass->isReadOnly(), + fn (ObjectDescription $object): bool => ! enum_exists($object->name) && $object->reflectionClass->isReadOnly(), //@phpstan-ignore-line 'to be readonly', FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')), ); diff --git a/src/Expectations/OppositeExpectation.php b/src/Expectations/OppositeExpectation.php index da4598f2..bf0351a6 100644 --- a/src/Expectations/OppositeExpectation.php +++ b/src/Expectations/OppositeExpectation.php @@ -109,7 +109,7 @@ final class OppositeExpectation { return Targeted::make( $this->original, - fn (ObjectDescription $object): bool => ! enum_exists($object->name) && ! $object->reflectionClass->isReadOnly(), + fn (ObjectDescription $object): bool => ! enum_exists($object->name) && ! $object->reflectionClass->isReadOnly(), //@phpstan-ignore-line 'not to be readonly', FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')), ); From b60d21dfe2f2875aa642a9a0e33b8214488419c7 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Thu, 27 Jul 2023 11:16:27 +0200 Subject: [PATCH 05/46] snapshots code cleanup --- src/Mixins/Expectation.php | 15 ++++---- src/Repositories/SnapshotRepository.php | 44 ++++++----------------- src/TestSuite.php | 18 ++++++++++ tests/Features/Expect/toMatchSnapshot.php | 24 ++++++------- 4 files changed, 48 insertions(+), 53 deletions(-) diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index b90e601a..1b8cfa42 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -805,6 +805,11 @@ final class Expectation */ public function toMatchSnapshot(string $message = ''): self { + $snapshots = TestSuite::getInstance()->snapshots; + + $testCase = TestSuite::getInstance()->test; + assert($testCase instanceof TestCase); + $string = match (true) { is_string($this->value) => $this->value, is_object($this->value) && method_exists($this->value, '__toString') => $this->value->__toString(), @@ -817,12 +822,8 @@ final class Expectation default => InvalidExpectationValue::expected('array|object|string'), }; - $testCase = TestSuite::getInstance()->test; - assert($testCase instanceof TestCase); - $snapshots = TestSuite::getInstance()->snapshots; - - if ($snapshots->has($testCase, $string)) { - [$filename, $content] = $snapshots->get($testCase, $string); + if ($snapshots->has()) { + [$filename, $content] = $snapshots->get(); Assert::assertSame( $content, @@ -830,7 +831,7 @@ final class Expectation $message === '' ? "Failed asserting that the string value matches its snapshot ($filename)." : $message ); } else { - $filename = $snapshots->save($testCase, $string); + $filename = $snapshots->save($string); $testCase::markTestIncomplete('Snapshot created at ['.$filename.'].'); } diff --git a/src/Repositories/SnapshotRepository.php b/src/Repositories/SnapshotRepository.php index 89a4135e..78b2ed11 100644 --- a/src/Repositories/SnapshotRepository.php +++ b/src/Repositories/SnapshotRepository.php @@ -5,8 +5,7 @@ declare(strict_types=1); namespace Pest\Repositories; use Pest\Exceptions\ShouldNotHappen; -use Pest\Support\Str; -use PHPUnit\Framework\TestCase; +use Pest\TestSuite; /** * @internal @@ -25,11 +24,9 @@ final class SnapshotRepository /** * Checks if the snapshot exists. */ - public function has(TestCase $testCase, string $description): bool + public function has(): bool { - [$filename, $description] = $this->getFilenameAndDescription($testCase); - - return file_exists($this->getSnapshotFilename($filename, $description)); + return file_exists($this->getSnapshotFilename()); } /** @@ -39,11 +36,9 @@ final class SnapshotRepository * * @throws ShouldNotHappen */ - public function get(TestCase $testCase, string $description): array + public function get(): array { - [$filename, $description] = $this->getFilenameAndDescription($testCase); - - $contents = file_get_contents($snapshotFilename = $this->getSnapshotFilename($filename, $description)); + $contents = file_get_contents($snapshotFilename = $this->getSnapshotFilename()); if ($contents === false) { throw ShouldNotHappen::fromMessage('Snapshot file could not be read.'); @@ -57,11 +52,9 @@ final class SnapshotRepository /** * Saves the given snapshot for the given test case. */ - public function save(TestCase $testCase, string $snapshot): string + public function save(string $snapshot): string { - [$filename, $description] = $this->getFilenameAndDescription($testCase); - - $snapshotFilename = $this->getSnapshotFilename($filename, $description); + $snapshotFilename = $this->getSnapshotFilename(); if (! file_exists(dirname($snapshotFilename))) { mkdir(dirname($snapshotFilename), 0755, true); @@ -103,33 +96,16 @@ final class SnapshotRepository } } - /** - * Gets the snapshot's "filename" and "description". - * - * @return array{0: string, 1: string} - */ - private function getFilenameAndDescription(TestCase $testCase): array - { - $filename = (fn () => self::$__filename)->call($testCase, $testCase::class); // @phpstan-ignore-line - - $description = str_replace('__pest_evaluable_', '', $testCase->name()); - $datasetAsString = str_replace('__pest_evaluable_', '', Str::evaluable($testCase->dataSetAsStringWithData())); - - $description = str_replace(' ', '_', $description.$datasetAsString); - - return [$filename, $description]; - } - /** * Gets the snapshot's "filename". */ - private function getSnapshotFilename(string $filename, string $description): string + private function getSnapshotFilename(): string { - $relativePath = str_replace($this->testsPath, '', $filename); + $relativePath = str_replace($this->testsPath, '', TestSuite::getInstance()->getFilename()); // remove extension from filename $relativePath = substr($relativePath, 0, (int) strrpos($relativePath, '.')); - return sprintf('%s/%s.snap', $this->testsPath.'/'.$this->snapshotsPath.$relativePath, $description); + return sprintf('%s/%s.snap', $this->testsPath.'/'.$this->snapshotsPath.$relativePath, TestSuite::getInstance()->getDescription()); } } diff --git a/src/TestSuite.php b/src/TestSuite.php index 3504e764..51c1084d 100644 --- a/src/TestSuite.php +++ b/src/TestSuite.php @@ -11,6 +11,7 @@ use Pest\Repositories\BeforeAllRepository; use Pest\Repositories\BeforeEachRepository; use Pest\Repositories\SnapshotRepository; use Pest\Repositories\TestRepository; +use Pest\Support\Str; use PHPUnit\Framework\TestCase; /** @@ -105,4 +106,21 @@ final class TestSuite return self::$instance; } + + public function getFilename(): string + { + assert($this->test instanceof TestCase); + + return (fn () => self::$__filename)->call($this->test, $this->test::class); // @phpstan-ignore-line + } + + public function getDescription(): string + { + assert($this->test instanceof TestCase); + + $description = str_replace('__pest_evaluable_', '', $this->test->name()); + $datasetAsString = str_replace('__pest_evaluable_', '', Str::evaluable($this->test->dataSetAsStringWithData())); + + return str_replace(' ', '_', $description.$datasetAsString); + } } diff --git a/tests/Features/Expect/toMatchSnapshot.php b/tests/Features/Expect/toMatchSnapshot.php index 29a63a59..91647f48 100644 --- a/tests/Features/Expect/toMatchSnapshot.php +++ b/tests/Features/Expect/toMatchSnapshot.php @@ -16,13 +16,13 @@ beforeEach(function () { }); test('pass', function () { - TestSuite::getInstance()->snapshots->save($this, $this->snapshotable); + TestSuite::getInstance()->snapshots->save($this->snapshotable); expect($this->snapshotable)->toMatchSnapshot(); }); test('pass with `__toString`', function () { - TestSuite::getInstance()->snapshots->save($this, $this->snapshotable); + TestSuite::getInstance()->snapshots->save($this->snapshotable); $object = new class($this->snapshotable) { @@ -40,7 +40,7 @@ test('pass with `__toString`', function () { }); test('pass with `toString`', function () { - TestSuite::getInstance()->snapshots->save($this, $this->snapshotable); + TestSuite::getInstance()->snapshots->save($this->snapshotable); $object = new class($this->snapshotable) { @@ -58,8 +58,8 @@ test('pass with `toString`', function () { }); test('pass with dataset', function ($data) { - TestSuite::getInstance()->snapshots->save($this, $this->snapshotable); - [$filename] = TestSuite::getInstance()->snapshots->get($this, $this->snapshotable); + TestSuite::getInstance()->snapshots->save($this->snapshotable); + [$filename] = TestSuite::getInstance()->snapshots->get(); expect($filename)->toEndWith('pass_with_dataset_with_data_set____my_datas_set_value______my_datas_set_value__.snap') ->and($this->snapshotable)->toMatchSnapshot(); @@ -67,8 +67,8 @@ test('pass with dataset', function ($data) { describe('within describe', function () { test('pass with dataset', function ($data) { - TestSuite::getInstance()->snapshots->save($this, $this->snapshotable); - [$filename] = TestSuite::getInstance()->snapshots->get($this, $this->snapshotable); + TestSuite::getInstance()->snapshots->save($this->snapshotable); + [$filename] = TestSuite::getInstance()->snapshots->get(); expect($filename)->toEndWith('pass_with_dataset_with_data_set____my_datas_set_value______my_datas_set_value__.snap') ->and($this->snapshotable)->toMatchSnapshot(); @@ -76,7 +76,7 @@ describe('within describe', function () { })->with(['my-datas-set-value']); test('pass with `toArray`', function () { - TestSuite::getInstance()->snapshots->save($this, json_encode(['key' => $this->snapshotable], JSON_PRETTY_PRINT)); + TestSuite::getInstance()->snapshots->save(json_encode(['key' => $this->snapshotable], JSON_PRETTY_PRINT)); $object = new class($this->snapshotable) { @@ -96,7 +96,7 @@ test('pass with `toArray`', function () { }); test('pass with array', function () { - TestSuite::getInstance()->snapshots->save($this, json_encode(['key' => $this->snapshotable], JSON_PRETTY_PRINT)); + TestSuite::getInstance()->snapshots->save(json_encode(['key' => $this->snapshotable], JSON_PRETTY_PRINT)); expect([ 'key' => $this->snapshotable, @@ -104,19 +104,19 @@ test('pass with array', function () { }); test('failures', function () { - TestSuite::getInstance()->snapshots->save($this, $this->snapshotable); + TestSuite::getInstance()->snapshots->save($this->snapshotable); expect('contain that does not match snapshot')->toMatchSnapshot(); })->throws(ExpectationFailedException::class, 'Failed asserting that two strings are identical.'); test('failures with custom message', function () { - TestSuite::getInstance()->snapshots->save($this, $this->snapshotable); + TestSuite::getInstance()->snapshots->save($this->snapshotable); expect('contain that does not match snapshot')->toMatchSnapshot('oh no'); })->throws(ExpectationFailedException::class, 'oh no'); test('not failures', function () { - TestSuite::getInstance()->snapshots->save($this, $this->snapshotable); + TestSuite::getInstance()->snapshots->save($this->snapshotable); expect($this->snapshotable)->not->toMatchSnapshot(); })->throws(ExpectationFailedException::class); From 1efb9de04339bc06aeef6252ff194df665806087 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Thu, 27 Jul 2023 11:46:22 +0200 Subject: [PATCH 06/46] multiple snapshots --- src/Mixins/Expectation.php | 3 +- src/Repositories/SnapshotRepository.php | 31 ++++++++++++++++++- .../multiple_snapshot_expectations.snap | 1 + .../multiple_snapshot_expectations__2.snap | 1 + ...with_datasets_with_data_set___1____1_.snap | 1 + ...h_datasets_with_data_set___1____1___2.snap | 1 + ...asets_with_data_set____bar______bar__.snap | 1 + ...ts_with_data_set____bar______bar____2.snap | 1 + ...asets_with_data_set____baz______baz__.snap | 1 + ...ts_with_data_set____baz______baz____2.snap | 1 + ...asets_with_data_set____foo______foo__.snap | 1 + ...ts_with_data_set____foo______foo____2.snap | 1 + .../pass_with______toString___2.snap | 7 +++++ .../pass_with__toArray___2.snap | 3 ++ .../pass_with__toString___2.snap | 7 +++++ .../toMatchSnapshot/pass_with_array__2.snap | 3 ++ tests/Features/Expect/toMatchSnapshot.php | 12 +++++++ 17 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations__2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set___1____1_.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set___1____1___2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____bar______bar__.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____bar______bar____2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____baz______baz__.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____baz______baz____2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____foo______foo__.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____foo______foo____2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with______toString___2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toArray___2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toString___2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with_array__2.snap diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index 1b8cfa42..6eed299a 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -806,6 +806,7 @@ final class Expectation public function toMatchSnapshot(string $message = ''): self { $snapshots = TestSuite::getInstance()->snapshots; + $snapshots->startNewExpectation(); $testCase = TestSuite::getInstance()->test; assert($testCase instanceof TestCase); @@ -833,7 +834,7 @@ final class Expectation } else { $filename = $snapshots->save($string); - $testCase::markTestIncomplete('Snapshot created at ['.$filename.'].'); + //$testCase::markTestIncomplete('Snapshot created at ['.$filename.'].'); } return $this; diff --git a/src/Repositories/SnapshotRepository.php b/src/Repositories/SnapshotRepository.php index 78b2ed11..da321dfb 100644 --- a/src/Repositories/SnapshotRepository.php +++ b/src/Repositories/SnapshotRepository.php @@ -12,6 +12,8 @@ use Pest\TestSuite; */ final class SnapshotRepository { + private static array $expectationsCounter = []; + /** * Creates a snapshot repository instance. */ @@ -106,6 +108,33 @@ final class SnapshotRepository // remove extension from filename $relativePath = substr($relativePath, 0, (int) strrpos($relativePath, '.')); - return sprintf('%s/%s.snap', $this->testsPath.'/'.$this->snapshotsPath.$relativePath, TestSuite::getInstance()->getDescription()); + $description = TestSuite::getInstance()->getDescription(); + + if($this->getCurrentSnapshotCounter() > 1){ + $description .= '__' . $this->getCurrentSnapshotCounter(); + } + + return sprintf('%s/%s.snap', $this->testsPath.'/'.$this->snapshotsPath.$relativePath, $description); + } + + private function getCurrentSnapshotKey(): string + { + return TestSuite::getInstance()->getFilename().'###'.TestSuite::getInstance()->getDescription(); + } + + private function getCurrentSnapshotCounter(): int + { + return self::$expectationsCounter[$this->getCurrentSnapshotKey()] ?? 0; + } + + public function startNewExpectation(): void + { + $key = $this->getCurrentSnapshotKey(); + + if(!isset(self::$expectationsCounter[$key])){ + self::$expectationsCounter[$key] = 0; + } + + self::$expectationsCounter[$key]++; } } diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations__2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations__2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations__2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set___1____1_.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set___1____1_.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set___1____1_.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set___1____1___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set___1____1___2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set___1____1___2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____bar______bar__.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____bar______bar__.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____bar______bar__.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____bar______bar____2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____bar______bar____2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____bar______bar____2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____baz______baz__.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____baz______baz__.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____baz______baz__.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____baz______baz____2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____baz______baz____2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____baz______baz____2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____foo______foo__.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____foo______foo__.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____foo______foo__.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____foo______foo____2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____foo______foo____2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_datasets_with_data_set____foo______foo____2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with______toString___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with______toString___2.snap new file mode 100644 index 00000000..c2b4dc0a --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with______toString___2.snap @@ -0,0 +1,7 @@ +
+
+
+

Snapshot

+
+
+
\ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toArray___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toArray___2.snap new file mode 100644 index 00000000..afd4f5f9 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toArray___2.snap @@ -0,0 +1,3 @@ +{ + "key": "
\n
\n
\n

Snapshot<\/h1>\n <\/div>\n <\/div>\n <\/div>" +} \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toString___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toString___2.snap new file mode 100644 index 00000000..c2b4dc0a --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toString___2.snap @@ -0,0 +1,7 @@ +
+
+
+

Snapshot

+
+
+
\ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with_array__2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with_array__2.snap new file mode 100644 index 00000000..afd4f5f9 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with_array__2.snap @@ -0,0 +1,3 @@ +{ + "key": "
\n
\n
\n

Snapshot<\/h1>\n <\/div>\n <\/div>\n <\/div>" +} \ No newline at end of file diff --git a/tests/Features/Expect/toMatchSnapshot.php b/tests/Features/Expect/toMatchSnapshot.php index 91647f48..655ffbf0 100644 --- a/tests/Features/Expect/toMatchSnapshot.php +++ b/tests/Features/Expect/toMatchSnapshot.php @@ -120,3 +120,15 @@ test('not failures', function () { expect($this->snapshotable)->not->toMatchSnapshot(); })->throws(ExpectationFailedException::class); + +test('multiple snapshot expectations', function () { + expect("foo bar 1")->toMatchSnapshot(); + + expect("foo bar 2")->toMatchSnapshot(); +}); + +test('multiple snapshot expectations with datasets', function () { + expect("foo bar 1")->toMatchSnapshot(); + + expect("foo bar 2")->toMatchSnapshot(); +})->with([1, 'foo', 'bar', 'baz']); From 4e719214c63e96179c9258be18f743015bae3129 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Tue, 1 Aug 2023 17:13:15 +0200 Subject: [PATCH 07/46] fix incomplete tests while updating snapshots --- src/Factories/TestCaseFactory.php | 22 ++++++++++++++++++++++ src/Mixins/Expectation.php | 3 ++- src/TestSuite.php | 9 ++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index cbe50985..7b9da1f9 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -189,7 +189,29 @@ final class TestCaseFactory private static \$__filename = '$filename'; + private array \$__snapshotChanges = []; + $methodsCode + + /** @postCondition */ + protected function __MarkTestIncompleteIfSnapshotHaveChanged(): void + { + if (empty(\$this->__snapshotChanges)) { + return; + } + + if (count(\$this->__snapshotChanges) === 1) { + \$this->markTestIncomplete(\$this->__snapshotChanges[0]); + + return; + } + + \$formattedMessages = implode(PHP_EOL, array_map(function (string \$message) { + return "- \$message"; + }, \$this->__snapshotChanges)); + + \$this->markTestIncomplete(\$formattedMessages); + } } PHP; diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index 6eed299a..fe49cb0f 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -834,7 +834,8 @@ final class Expectation } else { $filename = $snapshots->save($string); - //$testCase::markTestIncomplete('Snapshot created at ['.$filename.'].'); + // $testCase::markTestIncomplete('Snapshot created at ['.$filename.'].'); + TestSuite::getInstance()->registerSnapshotChange("Snapshot created at [$filename]"); } return $this; diff --git a/src/TestSuite.php b/src/TestSuite.php index 51c1084d..e27ec155 100644 --- a/src/TestSuite.php +++ b/src/TestSuite.php @@ -100,7 +100,7 @@ final class TestSuite return self::$instance; } - if (! self::$instance instanceof self) { + if (!self::$instance instanceof self) { Panic::with(new InvalidPestCommand()); } @@ -114,6 +114,13 @@ final class TestSuite return (fn () => self::$__filename)->call($this->test, $this->test::class); // @phpstan-ignore-line } + public function registerSnapshotChange(string $message): void + { + assert($this->test instanceof TestCase); + + (fn () => $this->__snapshotChanges[] = $message)->call($this->test, $this->test::class); // @phpstan-ignore-line + } + public function getDescription(): string { assert($this->test instanceof TestCase); From 844d1759813ca041d911aa1b8a4323de3318cdd6 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Tue, 1 Aug 2023 17:14:49 +0200 Subject: [PATCH 08/46] refactor --- src/TestSuite.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/TestSuite.php b/src/TestSuite.php index e27ec155..5bfc03a2 100644 --- a/src/TestSuite.php +++ b/src/TestSuite.php @@ -114,13 +114,6 @@ final class TestSuite return (fn () => self::$__filename)->call($this->test, $this->test::class); // @phpstan-ignore-line } - public function registerSnapshotChange(string $message): void - { - assert($this->test instanceof TestCase); - - (fn () => $this->__snapshotChanges[] = $message)->call($this->test, $this->test::class); // @phpstan-ignore-line - } - public function getDescription(): string { assert($this->test instanceof TestCase); @@ -130,4 +123,11 @@ final class TestSuite return str_replace(' ', '_', $description.$datasetAsString); } + + public function registerSnapshotChange(string $message): void + { + assert($this->test instanceof TestCase); + + (fn () => $this->__snapshotChanges[] = $message)->call($this->test, $this->test::class); // @phpstan-ignore-line + } } From fe3747f8501d475b651eb6f51da4e0a69ab6c46a Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Tue, 1 Aug 2023 17:15:44 +0200 Subject: [PATCH 09/46] lint --- src/Repositories/SnapshotRepository.php | 6 +++--- src/TestSuite.php | 2 +- tests/Features/Expect/toMatchSnapshot.php | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Repositories/SnapshotRepository.php b/src/Repositories/SnapshotRepository.php index da321dfb..fe71b64a 100644 --- a/src/Repositories/SnapshotRepository.php +++ b/src/Repositories/SnapshotRepository.php @@ -110,8 +110,8 @@ final class SnapshotRepository $description = TestSuite::getInstance()->getDescription(); - if($this->getCurrentSnapshotCounter() > 1){ - $description .= '__' . $this->getCurrentSnapshotCounter(); + if ($this->getCurrentSnapshotCounter() > 1) { + $description .= '__'.$this->getCurrentSnapshotCounter(); } return sprintf('%s/%s.snap', $this->testsPath.'/'.$this->snapshotsPath.$relativePath, $description); @@ -131,7 +131,7 @@ final class SnapshotRepository { $key = $this->getCurrentSnapshotKey(); - if(!isset(self::$expectationsCounter[$key])){ + if (! isset(self::$expectationsCounter[$key])) { self::$expectationsCounter[$key] = 0; } diff --git a/src/TestSuite.php b/src/TestSuite.php index 5bfc03a2..c6e4debd 100644 --- a/src/TestSuite.php +++ b/src/TestSuite.php @@ -100,7 +100,7 @@ final class TestSuite return self::$instance; } - if (!self::$instance instanceof self) { + if (! self::$instance instanceof self) { Panic::with(new InvalidPestCommand()); } diff --git a/tests/Features/Expect/toMatchSnapshot.php b/tests/Features/Expect/toMatchSnapshot.php index 655ffbf0..86320e38 100644 --- a/tests/Features/Expect/toMatchSnapshot.php +++ b/tests/Features/Expect/toMatchSnapshot.php @@ -122,13 +122,13 @@ test('not failures', function () { })->throws(ExpectationFailedException::class); test('multiple snapshot expectations', function () { - expect("foo bar 1")->toMatchSnapshot(); + expect('foo bar 1')->toMatchSnapshot(); - expect("foo bar 2")->toMatchSnapshot(); + expect('foo bar 2')->toMatchSnapshot(); }); test('multiple snapshot expectations with datasets', function () { - expect("foo bar 1")->toMatchSnapshot(); + expect('foo bar 1')->toMatchSnapshot(); - expect("foo bar 2")->toMatchSnapshot(); + expect('foo bar 2')->toMatchSnapshot(); })->with([1, 'foo', 'bar', 'baz']); From 0518971d2f371041ff4fa80c0ac67a09adff1bd4 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Tue, 1 Aug 2023 17:16:50 +0200 Subject: [PATCH 10/46] refactor --- src/TestSuite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TestSuite.php b/src/TestSuite.php index c6e4debd..885baa2f 100644 --- a/src/TestSuite.php +++ b/src/TestSuite.php @@ -128,6 +128,6 @@ final class TestSuite { assert($this->test instanceof TestCase); - (fn () => $this->__snapshotChanges[] = $message)->call($this->test, $this->test::class); // @phpstan-ignore-line + (fn (): string => $this->__snapshotChanges[] = $message)->call($this->test, $this->test::class); // @phpstan-ignore-line } } From 0221c2a643f67ea554170bd48a7668de57648ef3 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Tue, 1 Aug 2023 17:18:55 +0200 Subject: [PATCH 11/46] refactor --- src/Repositories/SnapshotRepository.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Repositories/SnapshotRepository.php b/src/Repositories/SnapshotRepository.php index fe71b64a..1cd3e666 100644 --- a/src/Repositories/SnapshotRepository.php +++ b/src/Repositories/SnapshotRepository.php @@ -12,6 +12,7 @@ use Pest\TestSuite; */ final class SnapshotRepository { + /** @var array */ private static array $expectationsCounter = []; /** From 9afe2296a6b66d1415561181a2f77955d43a6a09 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Wed, 2 Aug 2023 10:23:27 +0200 Subject: [PATCH 12/46] fix line endings on Windows --- src/Mixins/Expectation.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index fe49cb0f..d3d8cbd3 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -827,14 +827,13 @@ final class Expectation [$filename, $content] = $snapshots->get(); Assert::assertSame( - $content, - $string, + strtr($content, ["\r\n" => "\n", "\r" => "\n"]), + strtr($string, ["\r\n" => "\n", "\r" => "\n"]), $message === '' ? "Failed asserting that the string value matches its snapshot ($filename)." : $message ); } else { $filename = $snapshots->save($string); - // $testCase::markTestIncomplete('Snapshot created at ['.$filename.'].'); TestSuite::getInstance()->registerSnapshotChange("Snapshot created at [$filename]"); } From 43107c17436e41e23018ae31705c688168c14784 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 2 Aug 2023 23:01:36 +0100 Subject: [PATCH 13/46] chore: bumps phpunit --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 199d047f..23989940 100644 --- a/composer.json +++ b/composer.json @@ -23,11 +23,11 @@ "nunomaduro/termwind": "^1.15.1", "pestphp/pest-plugin": "^2.0.1", "pestphp/pest-plugin-arch": "^2.2.3", - "phpunit/phpunit": "^10.2.6" + "phpunit/phpunit": "^10.2.7" }, "conflict": { "webmozart/assert": "<1.11.0", - "phpunit/phpunit": ">10.2.6" + "phpunit/phpunit": ">10.2.7" }, "autoload": { "psr-4": { @@ -50,7 +50,7 @@ ] }, "require-dev": { - "pestphp/pest-dev-tools": "^2.12.0", + "pestphp/pest-dev-tools": "^2.14.0", "pestphp/pest-plugin-type-coverage": "^2.0.0", "symfony/process": "^6.3.2" }, From 00109e99767a770338c155b28346fd5842c915ca Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 2 Aug 2023 23:02:00 +0100 Subject: [PATCH 14/46] tests: adds more tests regarding snapshots multiple --- src/Concerns/Testable.php | 23 +++++++++++++++++++ src/Factories/TestCaseFactory.php | 22 ------------------ ...ple_snapshot_expectations_with_describe.snap | 1 + ..._snapshot_expectations_with_describe__2.snap | 1 + ...with_repeat_with_data_set___10____10_.snap | 1 + ...h_repeat_with_data_set___10____10___2.snap | 1 + ...s_with_repeat_with_data_set___1____1_.snap | 1 + ...ith_repeat_with_data_set___1____1___2.snap | 1 + ...s_with_repeat_with_data_set___2____2_.snap | 1 + ...ith_repeat_with_data_set___2____2___2.snap | 1 + ...s_with_repeat_with_data_set___3____3_.snap | 1 + ...ith_repeat_with_data_set___3____3___2.snap | 1 + ...s_with_repeat_with_data_set___4____4_.snap | 1 + ...ith_repeat_with_data_set___4____4___2.snap | 1 + ...s_with_repeat_with_data_set___5____5_.snap | 1 + ...ith_repeat_with_data_set___5____5___2.snap | 1 + ...s_with_repeat_with_data_set___6____6_.snap | 1 + ...ith_repeat_with_data_set___6____6___2.snap | 1 + ...s_with_repeat_with_data_set___7____7_.snap | 1 + ...ith_repeat_with_data_set___7____7___2.snap | 1 + ...s_with_repeat_with_data_set___8____8_.snap | 1 + ...ith_repeat_with_data_set___8____8___2.snap | 1 + ...s_with_repeat_with_data_set___9____9_.snap | 1 + ...ith_repeat_with_data_set___9____9___2.snap | 1 + ...isual_snapshot_of_help_command_output.snap | 2 +- ...isual_snapshot_of_help_command_output.snap | 2 +- tests/.snapshots/success.txt | 18 ++++++++++++++- tests/Features/Expect/toMatchSnapshot.php | 14 +++++++++++ tests/Visual/Parallel.php | 2 +- 29 files changed, 79 insertions(+), 26 deletions(-) create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/_describable__→_multiple_snapshot_expectations_with_describe.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/_describable__→_multiple_snapshot_expectations_with_describe__2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___10____10_.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___10____10___2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___1____1_.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___1____1___2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___2____2_.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___2____2___2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___3____3_.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___3____3___2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___4____4_.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___4____4___2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___5____5_.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___5____5___2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___6____6_.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___6____6___2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___7____7_.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___7____7___2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___8____8_.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___8____8___2.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___9____9_.snap create mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___9____9___2.snap diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index 3268f2ae..e8d00588 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -62,6 +62,11 @@ trait Testable */ private static ?Closure $__afterAll = null; + /** + * The list of snapshot changes, if any. + */ + private array $__snapshotChanges = []; + /** * Resets the test case static properties. */ @@ -331,6 +336,24 @@ trait Testable return ExceptionTrace::ensure(fn (): mixed => call_user_func_array(Closure::bind($closure, $this, $this::class), $arguments)); } + /** @postCondition */ + protected function __MarkTestIncompleteIfSnapshotHaveChanged(): void + { + if (count($this->__snapshotChanges) === 0) { + return; + } + + if (count($this->__snapshotChanges) === 1) { + $this->markTestIncomplete($this->__snapshotChanges[0]); + + return; + } + + $messages = implode(PHP_EOL, array_map(static fn (string $message): string => '- $message', $this->__snapshotChanges)); + + $this->markTestIncomplete($messages); + } + /** * The printable test case name. */ diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index 7b9da1f9..cbe50985 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -189,29 +189,7 @@ final class TestCaseFactory private static \$__filename = '$filename'; - private array \$__snapshotChanges = []; - $methodsCode - - /** @postCondition */ - protected function __MarkTestIncompleteIfSnapshotHaveChanged(): void - { - if (empty(\$this->__snapshotChanges)) { - return; - } - - if (count(\$this->__snapshotChanges) === 1) { - \$this->markTestIncomplete(\$this->__snapshotChanges[0]); - - return; - } - - \$formattedMessages = implode(PHP_EOL, array_map(function (string \$message) { - return "- \$message"; - }, \$this->__snapshotChanges)); - - \$this->markTestIncomplete(\$formattedMessages); - } } PHP; diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/_describable__→_multiple_snapshot_expectations_with_describe.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/_describable__→_multiple_snapshot_expectations_with_describe.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/_describable__→_multiple_snapshot_expectations_with_describe.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/_describable__→_multiple_snapshot_expectations_with_describe__2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/_describable__→_multiple_snapshot_expectations_with_describe__2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/_describable__→_multiple_snapshot_expectations_with_describe__2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___10____10_.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___10____10_.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___10____10_.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___10____10___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___10____10___2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___10____10___2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___1____1_.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___1____1_.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___1____1_.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___1____1___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___1____1___2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___1____1___2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___2____2_.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___2____2_.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___2____2_.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___2____2___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___2____2___2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___2____2___2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___3____3_.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___3____3_.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___3____3_.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___3____3___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___3____3___2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___3____3___2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___4____4_.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___4____4_.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___4____4_.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___4____4___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___4____4___2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___4____4___2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___5____5_.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___5____5_.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___5____5_.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___5____5___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___5____5___2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___5____5___2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___6____6_.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___6____6_.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___6____6_.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___6____6___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___6____6___2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___6____6___2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___7____7_.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___7____7_.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___7____7_.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___7____7___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___7____7___2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___7____7___2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___8____8_.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___8____8_.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___8____8_.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___8____8___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___8____8___2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___8____8___2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___9____9_.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___9____9_.snap new file mode 100644 index 00000000..7b5a8676 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___9____9_.snap @@ -0,0 +1 @@ +foo bar 1 \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___9____9___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___9____9___2.snap new file mode 100644 index 00000000..206d0d02 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/multiple_snapshot_expectations_with_repeat_with_data_set___9____9___2.snap @@ -0,0 +1 @@ +foo bar 2 \ No newline at end of file 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 c630e2d5..2a53ae8f 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.11.0. + Pest Testing Framework 2.12.0. 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 30e2d8c5..c6d73125 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.11.0. + Pest Testing Framework 2.12.0. diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index f9d7233c..f9b5bcd1 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -698,6 +698,22 @@ ✓ failures ✓ failures with custom message ✓ not failures + ✓ multiple snapshot expectations + ✓ multiple snapshot expectations with datasets with (1) + ✓ multiple snapshot expectations with datasets with ('foo') + ✓ multiple snapshot expectations with datasets with ('bar') + ✓ multiple snapshot expectations with datasets with ('baz') + ✓ describable → multiple snapshot expectations with describe + ✓ multiple snapshot expectations with repeat @ repetition 1 of 10 + ✓ multiple snapshot expectations with repeat @ repetition 2 of 10 + ✓ multiple snapshot expectations with repeat @ repetition 3 of 10 + ✓ multiple snapshot expectations with repeat @ repetition 4 of 10 + ✓ multiple snapshot expectations with repeat @ repetition 5 of 10 + ✓ multiple snapshot expectations with repeat @ repetition 6 of 10 + ✓ multiple snapshot expectations with repeat @ repetition 7 of 10 + ✓ multiple snapshot expectations with repeat @ repetition 8 of 10 + ✓ multiple snapshot expectations with repeat @ repetition 9 of 10 + ✓ multiple snapshot expectations with repeat @ repetition 10 of 10 PASS Tests\Features\Expect\toStartWith ✓ pass @@ -1194,4 +1210,4 @@ WARN Tests\Visual\Version - visual snapshot of help command output - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 844 passed (1947 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 860 passed (1979 assertions) \ No newline at end of file diff --git a/tests/Features/Expect/toMatchSnapshot.php b/tests/Features/Expect/toMatchSnapshot.php index 86320e38..2ca6467f 100644 --- a/tests/Features/Expect/toMatchSnapshot.php +++ b/tests/Features/Expect/toMatchSnapshot.php @@ -132,3 +132,17 @@ test('multiple snapshot expectations with datasets', function () { expect('foo bar 2')->toMatchSnapshot(); })->with([1, 'foo', 'bar', 'baz']); + +describe('describable', function () { + test('multiple snapshot expectations with describe', function () { + expect('foo bar 1')->toMatchSnapshot(); + + expect('foo bar 2')->toMatchSnapshot(); + }); +}); + +test('multiple snapshot expectations with repeat', function () { + expect('foo bar 1')->toMatchSnapshot(); + + expect('foo bar 2')->toMatchSnapshot(); +})->repeat(10); diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 406c0f5b..d2d90895 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, 15 skipped, 833 passed (1932 assertions)') + ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 849 passed (1964 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows(); From 8a589022d95bdfc8c0bbd4447b190992ffedd603 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 2 Aug 2023 23:04:35 +0100 Subject: [PATCH 15/46] release: v2.12.0 --- CHANGELOG.md | 10 ++++++++++ src/Pest.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce229105..62c27dc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ ## Unreleased +## [v2.12.0 (2023-08-02)](https://github.com/pestphp/pest/compare/v2.11.0...v2.12.0) + +### Added + +- Allows multiple `toMatchSnapshot` per test ([#881](https://github.com/pestphp/pest/pull/881)) + +### Changed + +- Bumps PHPUnit to `^10.2.7` ([43107c1](https://github.com/pestphp/pest/commit/43107c17436e41e23018ae31705c688168c14784)) + ## [v2.11.0 (2023-08-01)](https://github.com/pestphp/pest/compare/v2.10.1...v2.11.0) ### Added diff --git a/src/Pest.php b/src/Pest.php index 37dc243d..58738882 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '2.11.0'; + return '2.12.0'; } function testDirectory(string $file = ''): string From 60763f2223ec0284cd37ebb45cfbec7d9fb2782e Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Thu, 3 Aug 2023 11:27:01 +0200 Subject: [PATCH 16/46] fix tests --- tests/Features/Expect/toMatchSnapshot.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Features/Expect/toMatchSnapshot.php b/tests/Features/Expect/toMatchSnapshot.php index 2ca6467f..ed5c8458 100644 --- a/tests/Features/Expect/toMatchSnapshot.php +++ b/tests/Features/Expect/toMatchSnapshot.php @@ -36,7 +36,7 @@ test('pass with `__toString`', function () { } }; - expect($object)->toMatchSnapshot()->toMatchSnapshot(); + expect($object)->toMatchSnapshot(); }); test('pass with `toString`', function () { @@ -54,7 +54,7 @@ test('pass with `toString`', function () { } }; - expect($object)->toMatchSnapshot()->toMatchSnapshot(); + expect($object)->toMatchSnapshot(); }); test('pass with dataset', function ($data) { @@ -92,7 +92,7 @@ test('pass with `toArray`', function () { } }; - expect($object)->toMatchSnapshot()->toMatchSnapshot(); + expect($object)->toMatchSnapshot(); }); test('pass with array', function () { @@ -100,7 +100,7 @@ test('pass with array', function () { expect([ 'key' => $this->snapshotable, - ])->toMatchSnapshot()->toMatchSnapshot(); + ])->toMatchSnapshot(); }); test('failures', function () { From cbcea04768f28d750963a67d6b8a5acdac964a9e Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 3 Aug 2023 10:35:38 +0100 Subject: [PATCH 17/46] tests: update snapshots --- tests/Visual/Parallel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index d2d90895..fcb8d7df 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, 15 skipped, 849 passed (1964 assertions)') + ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 849 passed (1960 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows(); From 3742e74adf08415cef3912c10304e9184c1ee90d Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 4 Aug 2023 11:23:55 +0100 Subject: [PATCH 18/46] feat: adds `"phpunit/phpunit": "^10.3.1"` support --- composer.json | 8 +- .../Parallel/Paratest/WrapperRunner.php | 33 ++++--- .../Parallel/Support/CompactPrinter.php | 4 + src/Result.php | 9 +- src/Support/StateGenerator.php | 98 +++++++++++-------- .../pass_with______toString___2.snap | 7 -- .../pass_with__toArray___2.snap | 3 - .../pass_with__toString___2.snap | 7 -- .../toMatchSnapshot/pass_with_array__2.snap | 3 - tests/.snapshots/success.txt | 2 +- 10 files changed, 86 insertions(+), 88 deletions(-) delete mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with______toString___2.snap delete mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toArray___2.snap delete mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toString___2.snap delete mode 100644 tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with_array__2.snap diff --git a/composer.json b/composer.json index 23989940..84953cd4 100644 --- a/composer.json +++ b/composer.json @@ -18,16 +18,16 @@ ], "require": { "php": "^8.1.0", - "brianium/paratest": "^7.2.3", - "nunomaduro/collision": "^7.7.0", + "brianium/paratest": "^7.2.4", + "nunomaduro/collision": "^7.8.0", "nunomaduro/termwind": "^1.15.1", "pestphp/pest-plugin": "^2.0.1", "pestphp/pest-plugin-arch": "^2.2.3", - "phpunit/phpunit": "^10.2.7" + "phpunit/phpunit": "^10.3.1" }, "conflict": { "webmozart/assert": "<1.11.0", - "phpunit/phpunit": ">10.2.7" + "phpunit/phpunit": ">10.3.1" }, "autoload": { "psr-4": { diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 2a1db6bb..248c1bc5 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -13,6 +13,7 @@ use const DIRECTORY_SEPARATOR; use function dirname; use function file_get_contents; use function max; +use NunoMaduro\Collision\Adapters\Phpunit\Support\ResultReflection; use ParaTest\Coverage\CoverageMerger; use ParaTest\JUnit\LogMerger; use ParaTest\JUnit\Writer; @@ -273,7 +274,7 @@ final class WrapperRunner implements RunnerInterface assert($testResult instanceof TestResult); $testResultSum = new TestResult( - $testResultSum->numberOfTests() + $testResult->numberOfTests(), + (int) $testResultSum->hasTests() + (int) $testResult->hasTests(), $testResultSum->numberOfTestsRun() + $testResult->numberOfTestsRun(), $testResultSum->numberOfAssertions() + $testResult->numberOfAssertions(), array_merge_recursive($testResultSum->testErroredEvents(), $testResult->testErroredEvents()), @@ -282,23 +283,23 @@ final class WrapperRunner implements RunnerInterface array_merge_recursive($testResultSum->testSuiteSkippedEvents(), $testResult->testSuiteSkippedEvents()), array_merge_recursive($testResultSum->testSkippedEvents(), $testResult->testSkippedEvents()), array_merge_recursive($testResultSum->testMarkedIncompleteEvents(), $testResult->testMarkedIncompleteEvents()), - array_merge_recursive($testResultSum->testTriggeredDeprecationEvents(), $testResult->testTriggeredDeprecationEvents()), - array_merge_recursive($testResultSum->testTriggeredPhpDeprecationEvents(), $testResult->testTriggeredPhpDeprecationEvents()), array_merge_recursive($testResultSum->testTriggeredPhpunitDeprecationEvents(), $testResult->testTriggeredPhpunitDeprecationEvents()), - array_merge_recursive($testResultSum->testTriggeredErrorEvents(), $testResult->testTriggeredErrorEvents()), - array_merge_recursive($testResultSum->testTriggeredNoticeEvents(), $testResult->testTriggeredNoticeEvents()), - array_merge_recursive($testResultSum->testTriggeredPhpNoticeEvents(), $testResult->testTriggeredPhpNoticeEvents()), - array_merge_recursive($testResultSum->testTriggeredWarningEvents(), $testResult->testTriggeredWarningEvents()), - array_merge_recursive($testResultSum->testTriggeredPhpWarningEvents(), $testResult->testTriggeredPhpWarningEvents()), array_merge_recursive($testResultSum->testTriggeredPhpunitErrorEvents(), $testResult->testTriggeredPhpunitErrorEvents()), array_merge_recursive($testResultSum->testTriggeredPhpunitWarningEvents(), $testResult->testTriggeredPhpunitWarningEvents()), array_merge_recursive($testResultSum->testRunnerTriggeredDeprecationEvents(), $testResult->testRunnerTriggeredDeprecationEvents()), array_merge_recursive($testResultSum->testRunnerTriggeredWarningEvents(), $testResult->testRunnerTriggeredWarningEvents()), + array_merge_recursive($testResultSum->errors(), $testResult->errors()), + array_merge_recursive($testResultSum->deprecations(), $testResult->deprecations()), + array_merge_recursive($testResultSum->notices(), $testResult->notices()), + array_merge_recursive($testResultSum->warnings(), $testResult->warnings()), + array_merge_recursive($testResultSum->phpDeprecations(), $testResult->phpDeprecations()), + array_merge_recursive($testResultSum->phpNotices(), $testResult->phpNotices()), + array_merge_recursive($testResultSum->phpWarnings(), $testResult->phpWarnings()), ); } $testResultSum = new TestResult( - $testResultSum->numberOfTests(), + ResultReflection::numberOfTests($testResultSum), $testResultSum->numberOfTestsRun(), $testResultSum->numberOfAssertions(), $testResultSum->testErroredEvents(), @@ -307,14 +308,7 @@ final class WrapperRunner implements RunnerInterface $testResultSum->testSuiteSkippedEvents(), $testResultSum->testSkippedEvents(), $testResultSum->testMarkedIncompleteEvents(), - $testResultSum->testTriggeredDeprecationEvents(), - $testResultSum->testTriggeredPhpDeprecationEvents(), $testResultSum->testTriggeredPhpunitDeprecationEvents(), - $testResultSum->testTriggeredErrorEvents(), - $testResultSum->testTriggeredNoticeEvents(), - $testResultSum->testTriggeredPhpNoticeEvents(), - $testResultSum->testTriggeredWarningEvents(), - $testResultSum->testTriggeredPhpWarningEvents(), $testResultSum->testTriggeredPhpunitErrorEvents(), $testResultSum->testTriggeredPhpunitWarningEvents(), $testResultSum->testRunnerTriggeredDeprecationEvents(), @@ -322,6 +316,13 @@ final class WrapperRunner implements RunnerInterface $testResultSum->testRunnerTriggeredWarningEvents(), fn (WarningTriggered $event): bool => ! str_contains($event->message(), 'No tests found') )), + $testResultSum->errors(), + $testResultSum->deprecations(), + $testResultSum->notices(), + $testResultSum->warnings(), + $testResultSum->phpDeprecations(), + $testResultSum->phpNotices(), + $testResultSum->phpWarnings(), ); $this->printer->printResults( diff --git a/src/Plugins/Parallel/Support/CompactPrinter.php b/src/Plugins/Parallel/Support/CompactPrinter.php index aff82fa4..d3175214 100644 --- a/src/Plugins/Parallel/Support/CompactPrinter.php +++ b/src/Plugins/Parallel/Support/CompactPrinter.php @@ -134,6 +134,10 @@ final class CompactPrinter null, null, null, + null, + null, + null, + null, ); $telemetry = new Info( diff --git a/src/Result.php b/src/Result.php index 418de7db..d9f1f0e3 100644 --- a/src/Result.php +++ b/src/Result.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Pest; +use NunoMaduro\Collision\Adapters\Phpunit\Support\ResultReflection; use PHPUnit\TestRunner\TestResult\TestResult; use PHPUnit\TextUI\Configuration\Configuration; @@ -44,7 +45,7 @@ final class Result return self::SUCCESS_EXIT; } - if ($configuration->failOnEmptyTestSuite() && $result->numberOfTests() === 0) { + if ($configuration->failOnEmptyTestSuite() && ResultReflection::numberOfTests($result) === 0) { return self::FAILURE_EXIT; } @@ -53,9 +54,9 @@ final class Result $returnCode = self::FAILURE_EXIT; } - $warnings = $result->numberOfTestsWithTestTriggeredPhpunitWarningEvents() - + $result->numberOfTestsWithTestTriggeredWarningEvents() - + $result->numberOfTestsWithTestTriggeredPhpWarningEvents(); + $warnings = $result->numberOfTestsWithTestTriggeredPhpunitWarningEvents() + + +count($result->warnings()) + + count($result->phpWarnings()); if ($configuration->failOnWarning() && $warnings > 0) { $returnCode = self::FAILURE_EXIT; diff --git a/src/Support/StateGenerator.php b/src/Support/StateGenerator.php index da22aac5..cfaea382 100644 --- a/src/Support/StateGenerator.php +++ b/src/Support/StateGenerator.php @@ -74,64 +74,76 @@ final class StateGenerator )); } - foreach ($testResult->testTriggeredDeprecationEvents() as $testResultEvent) { - $testResultEvent = $testResultEvent[0]; + foreach ($testResult->deprecations() as $testResultEvent) { + foreach ($testResultEvent->triggeringTests() as $triggeringTest) { + ['test' => $test] = $triggeringTest; - $state->add(TestResult::fromPestParallelTestCase( - $testResultEvent->test(), - TestResult::DEPRECATED, - ThrowableBuilder::from(new TestOutcome($testResultEvent->message())) - )); + $state->add(TestResult::fromPestParallelTestCase( + $test, + TestResult::DEPRECATED, + ThrowableBuilder::from(new TestOutcome($testResultEvent->description())) + )); + } } - foreach ($testResult->testTriggeredPhpDeprecationEvents() as $testResultEvent) { - $testResultEvent = $testResultEvent[0]; + foreach ($testResult->phpDeprecations() as $testResultEvent) { + foreach ($testResultEvent->triggeringTests() as $triggeringTest) { + ['test' => $test] = $triggeringTest; - $state->add(TestResult::fromPestParallelTestCase( - $testResultEvent->test(), - TestResult::DEPRECATED, - ThrowableBuilder::from(new TestOutcome($testResultEvent->message())) - )); + $state->add(TestResult::fromPestParallelTestCase( + $test, + TestResult::DEPRECATED, + ThrowableBuilder::from(new TestOutcome($testResultEvent->description())) + )); + } } - foreach ($testResult->testTriggeredNoticeEvents() as $testResultEvent) { - $testResultEvent = $testResultEvent[0]; + foreach ($testResult->notices() as $testResultEvent) { + foreach ($testResultEvent->triggeringTests() as $triggeringTest) { + ['test' => $test] = $triggeringTest; - $state->add(TestResult::fromPestParallelTestCase( - $testResultEvent->test(), - TestResult::NOTICE, - ThrowableBuilder::from(new TestOutcome($testResultEvent->message())) - )); + $state->add(TestResult::fromPestParallelTestCase( + $test, + TestResult::NOTICE, + ThrowableBuilder::from(new TestOutcome($testResultEvent->description())) + )); + } } - foreach ($testResult->testTriggeredPhpNoticeEvents() as $testResultEvent) { - $testResultEvent = $testResultEvent[0]; + foreach ($testResult->phpNotices() as $testResultEvent) { + foreach ($testResultEvent->triggeringTests() as $triggeringTest) { + ['test' => $test] = $triggeringTest; - $state->add(TestResult::fromPestParallelTestCase( - $testResultEvent->test(), - TestResult::NOTICE, - ThrowableBuilder::from(new TestOutcome($testResultEvent->message())) - )); + $state->add(TestResult::fromPestParallelTestCase( + $test, + TestResult::NOTICE, + ThrowableBuilder::from(new TestOutcome($testResultEvent->description())) + )); + } } - foreach ($testResult->testTriggeredWarningEvents() as $testResultEvent) { - $testResultEvent = $testResultEvent[0]; + foreach ($testResult->warnings() as $testResultEvent) { + foreach ($testResultEvent->triggeringTests() as $triggeringTest) { + ['test' => $test] = $triggeringTest; - $state->add(TestResult::fromPestParallelTestCase( - $testResultEvent->test(), - TestResult::WARN, - ThrowableBuilder::from(new TestOutcome($testResultEvent->message())) - )); + $state->add(TestResult::fromPestParallelTestCase( + $test, + TestResult::WARN, + ThrowableBuilder::from(new TestOutcome($testResultEvent->description())) + )); + } } - foreach ($testResult->testTriggeredPhpWarningEvents() as $testResultEvent) { - $testResultEvent = $testResultEvent[0]; + foreach ($testResult->phpWarnings() as $testResultEvent) { + foreach ($testResultEvent->triggeringTests() as $triggeringTest) { + ['test' => $test] = $triggeringTest; - $state->add(TestResult::fromPestParallelTestCase( - $testResultEvent->test(), - TestResult::WARN, - ThrowableBuilder::from(new TestOutcome($testResultEvent->message())) - )); + $state->add(TestResult::fromPestParallelTestCase( + $test, + TestResult::WARN, + ThrowableBuilder::from(new TestOutcome($testResultEvent->description())) + )); + } } // for each test that passed, we need to add it to the state @@ -140,7 +152,7 @@ final class StateGenerator new TestMethod( "$i", // @phpstan-ignore-line '', // @phpstan-ignore-line - '', + '', // @phpstan-ignore-line 1, TestDoxBuilder::fromClassNameAndMethodName('', ''), // @phpstan-ignore-line MetadataCollection::fromArray([]), diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with______toString___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with______toString___2.snap deleted file mode 100644 index c2b4dc0a..00000000 --- a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with______toString___2.snap +++ /dev/null @@ -1,7 +0,0 @@ -
-
-
-

Snapshot

-
-
-
\ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toArray___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toArray___2.snap deleted file mode 100644 index afd4f5f9..00000000 --- a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toArray___2.snap +++ /dev/null @@ -1,3 +0,0 @@ -{ - "key": "
\n
\n
\n

Snapshot<\/h1>\n <\/div>\n <\/div>\n <\/div>" -} \ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toString___2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toString___2.snap deleted file mode 100644 index c2b4dc0a..00000000 --- a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toString___2.snap +++ /dev/null @@ -1,7 +0,0 @@ -
-
-
-

Snapshot

-
-
-
\ No newline at end of file diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with_array__2.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with_array__2.snap deleted file mode 100644 index afd4f5f9..00000000 --- a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with_array__2.snap +++ /dev/null @@ -1,3 +0,0 @@ -{ - "key": "
\n
\n
\n

Snapshot<\/h1>\n <\/div>\n <\/div>\n <\/div>" -} \ No newline at end of file diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index f9b5bcd1..66c8c499 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -1210,4 +1210,4 @@ WARN Tests\Visual\Version - visual snapshot of help command output - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 860 passed (1979 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 860 passed (1975 assertions) \ No newline at end of file From 7baa48e0683056c02a9d306e3329a7e5cd3e6cee Mon Sep 17 00:00:00 2001 From: Dylan Bridgman Date: Sat, 5 Aug 2023 12:24:43 +0200 Subject: [PATCH 19/46] TestSuiteLoader will always consider classes from the current file --- overrides/Runner/TestSuiteLoader.php | 16 +++++++++++++++ tests/.snapshots/success.txt | 8 +++++++- tests/.snapshots/todo.txt | 8 +++++++- tests/PHPUnit/CustomTestCase/ChildTest.php | 13 ++++++++++++ tests/PHPUnit/CustomTestCase/ParentTest.php | 22 +++++++++++++++++++++ tests/Visual/Parallel.php | 2 +- 6 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 tests/PHPUnit/CustomTestCase/ChildTest.php create mode 100644 tests/PHPUnit/CustomTestCase/ParentTest.php diff --git a/overrides/Runner/TestSuiteLoader.php b/overrides/Runner/TestSuiteLoader.php index d997aeb0..b6a5e754 100644 --- a/overrides/Runner/TestSuiteLoader.php +++ b/overrides/Runner/TestSuiteLoader.php @@ -60,6 +60,11 @@ final class TestSuiteLoader */ private static array $loadedClasses = []; + /** + * @psalm-var array> + */ + private static array $loadedClassesByFilename = []; + /** * @psalm-var list */ @@ -97,6 +102,17 @@ final class TestSuiteLoader self::$loadedClasses = array_merge($loadedClasses, self::$loadedClasses); + foreach ($loadedClasses as $loadedClass) { + $reflection = new ReflectionClass($loadedClass); + $filename = $reflection->getFileName(); + self::$loadedClassesByFilename[$filename] = [ + $loadedClass, + ...self::$loadedClassesByFilename[$filename] ?? [], + ]; + } + + $loadedClasses = array_merge(self::$loadedClassesByFilename[$suiteClassFile] ?? [], $loadedClasses); + if (empty($loadedClasses)) { return $this->exceptionFor($suiteClassName, $suiteClassFile); } diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 66c8c499..99001dfb 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -1015,9 +1015,15 @@ PASS Tests\PHPUnit\CustomAffixes\snakecasespec ✓ it runs file names like snake_case_spec.php + PASS Tests\CustomTestCase\ChildTest + ✓ override method + PASS Tests\CustomTestCase\ExecutedTest ✓ that gets executed + PASS Tests\CustomTestCase\ParentTest + ✓ override method + PASS Tests\PHPUnit\CustomTestCase\UsesPerDirectory ✓ closure was bound to CustomTestCase @@ -1210,4 +1216,4 @@ WARN Tests\Visual\Version - visual snapshot of help command output - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 860 passed (1975 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 862 passed (1977 assertions) diff --git a/tests/.snapshots/todo.txt b/tests/.snapshots/todo.txt index 1d3687a5..414d1b98 100644 --- a/tests/.snapshots/todo.txt +++ b/tests/.snapshots/todo.txt @@ -19,7 +19,13 @@ ↓ something todo later chained ↓ something todo later chained and with function body + PASS Tests\CustomTestCase\ChildTest + ✓ override method + PASS Tests\CustomTestCase\ExecutedTest ✓ that gets executed - Tests: 13 todos, 1 passed (1 assertions) + PASS Tests\CustomTestCase\ParentTest + ✓ override method + + Tests: 13 todos, 3 passed (3 assertions) diff --git a/tests/PHPUnit/CustomTestCase/ChildTest.php b/tests/PHPUnit/CustomTestCase/ChildTest.php new file mode 100644 index 00000000..15ad37cc --- /dev/null +++ b/tests/PHPUnit/CustomTestCase/ChildTest.php @@ -0,0 +1,13 @@ +getEntity() || true); + } +} diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index fcb8d7df..d5f32b93 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, 15 skipped, 849 passed (1960 assertions)') + ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 851 passed (1962 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows(); From cc242a50d1a7120d80b04a2d6ba55ba6a285d0b1 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 7 Aug 2023 09:32:38 +0100 Subject: [PATCH 20/46] chore: bump dependencies --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 84953cd4..05ac4ea3 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": "^8.1.0", "brianium/paratest": "^7.2.4", - "nunomaduro/collision": "^7.8.0", + "nunomaduro/collision": "^7.8.1", "nunomaduro/termwind": "^1.15.1", "pestphp/pest-plugin": "^2.0.1", "pestphp/pest-plugin-arch": "^2.2.3", From 75a7d77a80461d30a1f10fad0efdb447ffbb4cda Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 7 Aug 2023 10:22:58 +0100 Subject: [PATCH 21/46] Updates snapshots --- tests/.snapshots/success.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 99001dfb..2926dd09 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -1216,4 +1216,4 @@ WARN Tests\Visual\Version - visual snapshot of help command output - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 862 passed (1977 assertions) + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 862 passed (1977 assertions) \ No newline at end of file From 331381eed59dfaef624060f560cda85d15b32e89 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 7 Aug 2023 10:26:55 +0100 Subject: [PATCH 22/46] release: v2.12.1 --- CHANGELOG.md | 6 ++++++ src/Pest.php | 2 +- .../Visual/Help/visual_snapshot_of_help_command_output.snap | 2 +- .../Version/visual_snapshot_of_help_command_output.snap | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62c27dc3..160395ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +## [v2.12.1 (2023-08-07)](https://github.com/pestphp/pest/compare/v2.12.0...v2.12.1) + +### Fixed + +- Running tests from `uses` parent class ([#898](https://github.com/pestphp/pest/pull/898)) + ## [v2.12.0 (2023-08-02)](https://github.com/pestphp/pest/compare/v2.11.0...v2.12.0) ### Added diff --git a/src/Pest.php b/src/Pest.php index 58738882..304fa210 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '2.12.0'; + return '2.12.1'; } 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 2a53ae8f..d40a6527 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.12.0. + Pest Testing Framework 2.12.1. 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 c6d73125..0991bfcd 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.12.0. + Pest Testing Framework 2.12.1. From e3a21384e69d6343f8223578bbc38d80e1224f08 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 7 Aug 2023 10:29:25 +0100 Subject: [PATCH 23/46] release: v2.12.2 --- CHANGELOG.md | 2 +- src/Pest.php | 2 +- .../Visual/Help/visual_snapshot_of_help_command_output.snap | 2 +- .../Visual/Version/visual_snapshot_of_help_command_output.snap | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 160395ee..3d3a35de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -## [v2.12.1 (2023-08-07)](https://github.com/pestphp/pest/compare/v2.12.0...v2.12.1) +## [v2.12.2 (2023-08-07)](https://github.com/pestphp/pest/compare/v2.12.0...v2.12.2) ### Fixed diff --git a/src/Pest.php b/src/Pest.php index 304fa210..29530e23 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '2.12.1'; + return '2.12.2'; } 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 d40a6527..80540a11 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.12.1. + Pest Testing Framework 2.12.2. 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 0991bfcd..ca8b19f0 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.12.1. + Pest Testing Framework 2.12.2. From 306b7eb2a6a57e570d58228b46501ad9ba4062b4 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 9 Aug 2023 12:14:32 +0100 Subject: [PATCH 24/46] feat: adds `ddWhen` and `ddUnless` --- src/Expectation.php | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Expectation.php b/src/Expectation.php index dceca405..476cee1d 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -130,27 +130,35 @@ final class Expectation /** * Dump the expectation value when the result of the condition is truthy. * - * @param bool $boolean - * @return never + * @param (\Closure(TValue): bool)|bool $condition + * @return self */ - public function ddWhen($boolean, mixed ...$arguments): void + public function ddWhen(Closure|bool $condition, mixed ...$arguments): Expectation { - if (! $boolean) { - return; + $condition = $condition instanceof Closure ? $condition($this->value) : $condition; + + if (! $condition) { + return $this; } - $this->dd($this->value, ...$arguments); + $this->dd(...$arguments); } /** * Dump the expectation value when the result of the condition is falsy. * - * @param bool $boolean - * @return never + * @param (\Closure(TValue): bool)|bool $condition + * @return self */ - public function ddUnless($boolean, mixed ...$arguments): void + public function ddUnless(Closure|bool $condition, mixed ...$arguments): Expectation { - $this->ddWhen(! $boolean, ...$arguments); + $condition = $condition instanceof Closure ? $condition($this->value) : $condition; + + if ($condition) { + return $this; + } + + $this->dd(...$arguments); } /** From 47f2ae32c14cd3f15520f5a12a3c36fdec25a2ee Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 9 Aug 2023 12:14:39 +0100 Subject: [PATCH 25/46] release: v2.13.0 --- composer.json | 2 +- src/Pest.php | 2 +- .../Visual/Help/visual_snapshot_of_help_command_output.snap | 2 +- .../Visual/Version/visual_snapshot_of_help_command_output.snap | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 05ac4ea3..7cdb3224 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ ], "require": { "php": "^8.1.0", - "brianium/paratest": "^7.2.4", + "brianium/paratest": "^7.2.5", "nunomaduro/collision": "^7.8.1", "nunomaduro/termwind": "^1.15.1", "pestphp/pest-plugin": "^2.0.1", diff --git a/src/Pest.php b/src/Pest.php index 29530e23..c1e51c39 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '2.12.2'; + return '2.13.0'; } 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 80540a11..9e3dfedd 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.12.2. + Pest Testing Framework 2.13.0. 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 ca8b19f0..b9ad94cf 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.12.2. + Pest Testing Framework 2.13.0. From f1414a0beb43da066cf33276e22ea1209f047667 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 9 Aug 2023 12:16:21 +0100 Subject: [PATCH 26/46] docs: changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d3a35de..8a09e073 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +## [v2.13.0 (2023-08-09)](https://github.com/pestphp/pest/compare/v2.12.2...v2.13.0) + +### Added + +- `expect()->ddWhen` and `expect()->ddUnless` ([306b7eb](https://github.com/pestphp/pest/commit/306b7eb2a6a57e570d58228b46501ad9ba4062b4)) + ## [v2.12.2 (2023-08-07)](https://github.com/pestphp/pest/compare/v2.12.0...v2.12.2) ### Fixed From 54e00dd4dc0e277a92afd4ee93d20519c0c4a1a1 Mon Sep 17 00:00:00 2001 From: JonPurvis Date: Sat, 12 Aug 2023 16:41:15 +0100 Subject: [PATCH 27/46] add expectations for uppercase, lowercase, alpha and alphanumeric --- src/Mixins/Expectation.php | 48 ++++++++++++++++++++++ tests/Features/Expect/toBeAlpha.php | 20 +++++++++ tests/Features/Expect/toBeAlphaNumeric.php | 20 +++++++++ tests/Features/Expect/toBeLowercase.php | 20 +++++++++ tests/Features/Expect/toBeUppercase.php | 20 +++++++++ 5 files changed, 128 insertions(+) create mode 100644 tests/Features/Expect/toBeAlpha.php create mode 100644 tests/Features/Expect/toBeAlphaNumeric.php create mode 100644 tests/Features/Expect/toBeLowercase.php create mode 100644 tests/Features/Expect/toBeUppercase.php diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index d3d8cbd3..19038bfe 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -961,4 +961,52 @@ final class Expectation return $this->exporter->shortenedExport($value); } + + /** + * Asserts that the value is uppercase. + * + * @return self + */ + public function toBeUppercase(string $message = ''): self + { + Assert::assertTrue(ctype_upper($this->value), $message); + + return $this; + } + + /** + * Asserts that the value is lowercase. + * + * @return self + */ + public function toBeLowercase(string $message = ''): self + { + Assert::assertTrue(ctype_lower($this->value), $message); + + return $this; + } + + /** + * Asserts that the value is alphanumeric. + * + * @return self + */ + public function toBeAlphaNumeric(string $message = ''): self + { + Assert::assertTrue(ctype_alnum($this->value), $message); + + return $this; + } + + /** + * Asserts that the value is alpha. + * + * @return self + */ + public function toBeAlpha(string $message = ''): self + { + Assert::assertTrue(ctype_alpha($this->value), $message); + + return $this; + } } diff --git a/tests/Features/Expect/toBeAlpha.php b/tests/Features/Expect/toBeAlpha.php new file mode 100644 index 00000000..659c2de1 --- /dev/null +++ b/tests/Features/Expect/toBeAlpha.php @@ -0,0 +1,20 @@ +toBeAlpha(); + expect('123')->not->toBeAlpha(); +}); + +test('failures', function () { + expect('123')->toBeAlpha(); +})->throws(ExpectationFailedException::class); + +test('failures with custom message', function () { + expect('123')->toBeAlpha('oh no!'); +})->throws(ExpectationFailedException::class, 'oh no!'); + +test('not failures', function () { + expect('abc')->not->toBeAlpha(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Features/Expect/toBeAlphaNumeric.php b/tests/Features/Expect/toBeAlphaNumeric.php new file mode 100644 index 00000000..5f4670e8 --- /dev/null +++ b/tests/Features/Expect/toBeAlphaNumeric.php @@ -0,0 +1,20 @@ +toBeAlphaNumeric(); + expect('-')->not->toBeAlphaNumeric(); +}); + +test('failures', function () { + expect('-')->toBeAlphaNumeric(); +})->throws(ExpectationFailedException::class); + +test('failures with custom message', function () { + expect('-')->toBeAlphaNumeric('oh no!'); +})->throws(ExpectationFailedException::class, 'oh no!'); + +test('not failures', function () { + expect('abc123')->not->toBeAlphaNumeric(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Features/Expect/toBeLowercase.php b/tests/Features/Expect/toBeLowercase.php new file mode 100644 index 00000000..4eda711b --- /dev/null +++ b/tests/Features/Expect/toBeLowercase.php @@ -0,0 +1,20 @@ +toBeLowercase(); + expect('UPPERCASE')->not->toBeLowercase(); +}); + +test('failures', function () { + expect('UPPERCASE')->toBeLowercase(); +})->throws(ExpectationFailedException::class); + +test('failures with custom message', function () { + expect('UPPERCASE')->toBeLowercase('oh no!'); +})->throws(ExpectationFailedException::class, 'oh no!'); + +test('not failures', function () { + expect('lowercase')->not->toBeLowercase(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Features/Expect/toBeUppercase.php b/tests/Features/Expect/toBeUppercase.php new file mode 100644 index 00000000..7a1345d7 --- /dev/null +++ b/tests/Features/Expect/toBeUppercase.php @@ -0,0 +1,20 @@ +toBeUppercase(); + expect('lowercase')->not->toBeUppercase(); +}); + +test('failures', function () { + expect('lowercase')->toBeUppercase(); +})->throws(ExpectationFailedException::class); + +test('failures with custom message', function () { + expect('lowercase')->toBeUppercase('oh no!'); +})->throws(ExpectationFailedException::class, 'oh no!'); + +test('not failures', function () { + expect('UPPERCASE')->not->toBeUppercase(); +})->throws(ExpectationFailedException::class); From f996a48dfa3e39172fdea0b234975dfee5200f3a Mon Sep 17 00:00:00 2001 From: JonPurvis Date: Sat, 12 Aug 2023 18:14:38 +0100 Subject: [PATCH 28/46] fix refacto check --- src/Mixins/Expectation.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index 19038bfe..56e1da09 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -969,7 +969,7 @@ final class Expectation */ public function toBeUppercase(string $message = ''): self { - Assert::assertTrue(ctype_upper($this->value), $message); + Assert::assertTrue(ctype_upper((string) $this->value), $message); return $this; } @@ -981,7 +981,7 @@ final class Expectation */ public function toBeLowercase(string $message = ''): self { - Assert::assertTrue(ctype_lower($this->value), $message); + Assert::assertTrue(ctype_lower((string) $this->value), $message); return $this; } @@ -993,7 +993,7 @@ final class Expectation */ public function toBeAlphaNumeric(string $message = ''): self { - Assert::assertTrue(ctype_alnum($this->value), $message); + Assert::assertTrue(ctype_alnum((string) $this->value), $message); return $this; } @@ -1005,7 +1005,7 @@ final class Expectation */ public function toBeAlpha(string $message = ''): self { - Assert::assertTrue(ctype_alpha($this->value), $message); + Assert::assertTrue(ctype_alpha((string) $this->value), $message); return $this; } From b1a137c5133891045ce65b462e1182912d1f4b68 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 14 Aug 2023 09:41:05 +0100 Subject: [PATCH 29/46] chore: updates snapshot tests --- tests/.snapshots/success.txt | 26 +++++++++++++++++++++++++- tests/Visual/Parallel.php | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 2926dd09..48310246 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -308,6 +308,18 @@ ✓ strict comparisons ✓ failures ✓ failures with custom message + ✓ not failures + + PASS Tests\Features\Expect\toBeAlpha + ✓ pass + ✓ failures + ✓ failures with custom message + ✓ not failures + + PASS Tests\Features\Expect\toBeAlphaNumeric + ✓ pass + ✓ failures + ✓ failures with custom message ✓ not failures PASS Tests\Features\Expect\toBeArray @@ -443,6 +455,12 @@ ✓ passes with DateTime and DateTimeImmutable ✓ failures ✓ failures with custom message + ✓ not failures + + PASS Tests\Features\Expect\toBeLowercase + ✓ pass + ✓ failures + ✓ failures with custom message ✓ not failures PASS Tests\Features\Expect\toBeNAN @@ -518,6 +536,12 @@ ✓ passes as not truthy with ('0') ✓ failures ✓ failures with custom message + ✓ not failures + + PASS Tests\Features\Expect\toBeUppercase + ✓ pass + ✓ failures + ✓ failures with custom message ✓ not failures PASS Tests\Features\Expect\toBeWritableDirectory @@ -1216,4 +1240,4 @@ WARN Tests\Visual\Version - visual snapshot of help command output - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 862 passed (1977 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 878 passed (2013 assertions) \ No newline at end of file diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index d5f32b93..84d89a0d 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, 15 skipped, 851 passed (1962 assertions)') + ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 867 passed (1998 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows(); From df2212055b8a11c881ff2f59a8976c51d03e05ed Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 14 Aug 2023 09:41:14 +0100 Subject: [PATCH 30/46] release: v2.14.0 --- src/Pest.php | 2 +- .../Visual/Help/visual_snapshot_of_help_command_output.snap | 2 +- .../Visual/Version/visual_snapshot_of_help_command_output.snap | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Pest.php b/src/Pest.php index c1e51c39..6740ab53 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '2.13.0'; + return '2.14.0'; } 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 9e3dfedd..a13109ba 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.13.0. + Pest Testing Framework 2.14.0. 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 b9ad94cf..3a032a57 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.13.0. + Pest Testing Framework 2.14.0. From 03648f580c880421f475cf2466fab9982285ebd2 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 14 Aug 2023 09:44:14 +0100 Subject: [PATCH 31/46] docs: update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a09e073..ae3c506a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +## [v2.14.0 (2023-08-14)](https://github.com/pestphp/pest/compare/v2.13.0...v2.14.0) + +### Added + +- `toBeUppercase()`, `toBeLowercase()`, `toBeAlphaNumeric()`, `toBeAlpha()` ([#906](https://github.com/pestphp/pest/pull/906)) + ## [v2.13.0 (2023-08-09)](https://github.com/pestphp/pest/compare/v2.12.2...v2.13.0) ### Added From 398e3ff3b526c8725e9a6d1c223c4e2802613364 Mon Sep 17 00:00:00 2001 From: AJ Meireles Date: Mon, 14 Aug 2023 17:10:58 -0300 Subject: [PATCH 32/46] introducing toBeDigits --- src/Mixins/Expectation.php | 12 ++++++++++++ tests/Features/Expect/toBeDigits.php | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/Features/Expect/toBeDigits.php diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index 56e1da09..cb3ec31d 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -502,6 +502,18 @@ final class Expectation return $this; } + /** + * Asserts that the value contains only digits. + * + * @return self + */ + public function toBeDigits(string $message = ''): self + { + Assert::assertTrue(ctype_digit((string) $this->value), $message); + + return $this; + } + /** * Asserts that the value is of type object. * diff --git a/tests/Features/Expect/toBeDigits.php b/tests/Features/Expect/toBeDigits.php new file mode 100644 index 00000000..7b8d6d98 --- /dev/null +++ b/tests/Features/Expect/toBeDigits.php @@ -0,0 +1,20 @@ +toBeDigits(); + expect('123.14')->not->toBeDigits(); +}); + +test('failures', function () { + expect('123.14')->toBeDigits(); +})->throws(ExpectationFailedException::class); + +test('failures with custom message', function () { + expect('123.14')->toBeDigits('oh no!'); +})->throws(ExpectationFailedException::class, 'oh no!'); + +test('not failures', function () { + expect('445')->not->toBeDigits(); +})->throws(ExpectationFailedException::class); From b1dd18af8a7d5194b6c3e81d2cb88310991a7f6f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 16 Aug 2023 09:46:31 +0100 Subject: [PATCH 33/46] chore: style changes --- .../Runner/Filter/NameFilterIterator.php | 7 ++++--- .../Runner/ResultCache/DefaultResultCache.php | 12 ++++++----- overrides/Runner/TestSuiteLoader.php | 11 +++++----- overrides/TextUI/TestSuiteFilterProcessor.php | 3 ++- src/Bootstrappers/BootFiles.php | 3 ++- src/Expectations/EachExpectation.php | 3 ++- src/Plugins/Help.php | 3 ++- src/Plugins/Parallel.php | 3 ++- .../Parallel/Paratest/ResultPrinter.php | 19 +++++++++--------- .../Parallel/Paratest/WrapperRunner.php | 20 ++++++++++--------- .../Parallel/Support/CompactPrinter.php | 3 ++- src/Plugins/Version.php | 1 + src/Repositories/DatasetsRepository.php | 3 ++- src/Support/Coverage.php | 1 + src/Support/View.php | 3 ++- .../PHPUnit/CustomTestCase/CustomTestCase.php | 3 ++- tests/PHPUnit/CustomTestCase/ExecutedTest.php | 3 ++- tests/PHPUnit/CustomTestCase/ParentTest.php | 3 ++- 18 files changed, 62 insertions(+), 42 deletions(-) diff --git a/overrides/Runner/Filter/NameFilterIterator.php b/overrides/Runner/Filter/NameFilterIterator.php index 391c3ed5..8b740c3f 100644 --- a/overrides/Runner/Filter/NameFilterIterator.php +++ b/overrides/Runner/Filter/NameFilterIterator.php @@ -34,17 +34,18 @@ namespace PHPUnit\Runner\Filter; -use function end; use Exception; -use function implode; use Pest\Contracts\HasPrintableTestCaseName; use PHPUnit\Framework\SelfDescribing; use PHPUnit\Framework\Test; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestSuite; -use function preg_match; use RecursiveFilterIterator; use RecursiveIterator; + +use function end; +use function implode; +use function preg_match; use function sprintf; use function str_replace; diff --git a/overrides/Runner/ResultCache/DefaultResultCache.php b/overrides/Runner/ResultCache/DefaultResultCache.php index 40134011..c64602c0 100644 --- a/overrides/Runner/ResultCache/DefaultResultCache.php +++ b/overrides/Runner/ResultCache/DefaultResultCache.php @@ -45,9 +45,15 @@ declare(strict_types=1); namespace PHPUnit\Runner\ResultCache; +use const DIRECTORY_SEPARATOR; + +use PHPUnit\Framework\TestStatus\TestStatus; +use PHPUnit\Runner\DirectoryCannotBeCreatedException; +use PHPUnit\Runner\Exception; +use PHPUnit\Util\Filesystem; + use function array_keys; use function assert; -use const DIRECTORY_SEPARATOR; use function dirname; use function file_get_contents; use function file_put_contents; @@ -57,10 +63,6 @@ use function is_file; use function json_decode; use function json_encode; use function Pest\version; -use PHPUnit\Framework\TestStatus\TestStatus; -use PHPUnit\Runner\DirectoryCannotBeCreatedException; -use PHPUnit\Runner\Exception; -use PHPUnit\Util\Filesystem; /** * @internal This class is not covered by the backward compatibility promise for PHPUnit diff --git a/overrides/Runner/TestSuiteLoader.php b/overrides/Runner/TestSuiteLoader.php index b6a5e754..9c1a0935 100644 --- a/overrides/Runner/TestSuiteLoader.php +++ b/overrides/Runner/TestSuiteLoader.php @@ -36,18 +36,19 @@ declare(strict_types=1); namespace PHPUnit\Runner; -use function array_diff; -use function array_values; -use function basename; -use function class_exists; use Exception; -use function get_declared_classes; use Pest\Contracts\HasPrintableTestCaseName; use Pest\TestCases\IgnorableTestCase; use Pest\TestSuite; use PHPUnit\Framework\TestCase; use ReflectionClass; use ReflectionException; + +use function array_diff; +use function array_values; +use function basename; +use function class_exists; +use function get_declared_classes; use function substr; /** diff --git a/overrides/TextUI/TestSuiteFilterProcessor.php b/overrides/TextUI/TestSuiteFilterProcessor.php index 31ce5fe6..f4473289 100644 --- a/overrides/TextUI/TestSuiteFilterProcessor.php +++ b/overrides/TextUI/TestSuiteFilterProcessor.php @@ -45,7 +45,6 @@ declare(strict_types=1); namespace PHPUnit\TextUI; -use function array_map; use Pest\Plugins\Only; use PHPUnit\Event; use PHPUnit\Framework\TestSuite; @@ -53,6 +52,8 @@ use PHPUnit\Runner\Filter\Factory; use PHPUnit\TextUI\Configuration\Configuration; use PHPUnit\TextUI\Configuration\FilterNotConfiguredException; +use function array_map; + /** * @internal This class is not covered by the backward compatibility promise for PHPUnit */ diff --git a/src/Bootstrappers/BootFiles.php b/src/Bootstrappers/BootFiles.php index 3add2a70..411fd007 100644 --- a/src/Bootstrappers/BootFiles.php +++ b/src/Bootstrappers/BootFiles.php @@ -7,12 +7,13 @@ namespace Pest\Bootstrappers; use Pest\Contracts\Bootstrapper; use Pest\Support\DatasetInfo; use Pest\Support\Str; -use function Pest\testDirectory; use Pest\TestSuite; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use SebastianBergmann\FileIterator\Facade as PhpUnitFileIterator; +use function Pest\testDirectory; + /** * @internal */ diff --git a/src/Expectations/EachExpectation.php b/src/Expectations/EachExpectation.php index 56cd937b..e5df6e9c 100644 --- a/src/Expectations/EachExpectation.php +++ b/src/Expectations/EachExpectation.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace Pest\Expectations; -use function expect; use Pest\Expectation; +use function expect; + /** * @internal * diff --git a/src/Plugins/Help.php b/src/Plugins/Help.php index b0643461..c8e4d32f 100644 --- a/src/Plugins/Help.php +++ b/src/Plugins/Help.php @@ -6,10 +6,11 @@ namespace Pest\Plugins; use Pest\Contracts\Plugins\HandlesArguments; use Pest\Support\View; -use function Pest\version; use PHPUnit\TextUI\Help as PHPUnitHelp; use Symfony\Component\Console\Output\OutputInterface; +use function Pest\version; + /** * @internal */ diff --git a/src/Plugins/Parallel.php b/src/Plugins/Parallel.php index 3354b743..fd643471 100644 --- a/src/Plugins/Parallel.php +++ b/src/Plugins/Parallel.php @@ -13,11 +13,12 @@ use Pest\Plugins\Parallel\Paratest\CleanConsoleOutput; use Pest\Support\Arr; use Pest\Support\Container; use Pest\TestSuite; -use function Pest\version; use Stringable; use Symfony\Component\Console\Application; use Symfony\Component\Console\Input\ArgvInput; +use function Pest\version; + final class Parallel implements HandlesArguments { use HandleArguments; diff --git a/src/Plugins/Parallel/Paratest/ResultPrinter.php b/src/Plugins/Parallel/Paratest/ResultPrinter.php index f9d96ca2..1e9cc245 100644 --- a/src/Plugins/Parallel/Paratest/ResultPrinter.php +++ b/src/Plugins/Parallel/Paratest/ResultPrinter.php @@ -4,6 +4,16 @@ declare(strict_types=1); namespace Pest\Plugins\Parallel\Paratest; +use ParaTest\Options; +use Pest\Plugins\Parallel\Support\CompactPrinter; +use Pest\Support\StateGenerator; +use PHPUnit\TestRunner\TestResult\TestResult; +use PHPUnit\TextUI\Output\Printer; +use SebastianBergmann\Timer\Duration; +use SplFileInfo; +use Symfony\Component\Console\Formatter\OutputFormatter; +use Symfony\Component\Console\Output\OutputInterface; + use function assert; use function fclose; use function feof; @@ -12,16 +22,7 @@ use function fread; use function fseek; use function ftell; use function fwrite; -use ParaTest\Options; -use Pest\Plugins\Parallel\Support\CompactPrinter; -use Pest\Support\StateGenerator; -use PHPUnit\TestRunner\TestResult\TestResult; -use PHPUnit\TextUI\Output\Printer; -use SebastianBergmann\Timer\Duration; -use SplFileInfo; use function strlen; -use Symfony\Component\Console\Formatter\OutputFormatter; -use Symfony\Component\Console\Output\OutputInterface; /** * @internal diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 248c1bc5..8b75bc4c 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -4,15 +4,8 @@ declare(strict_types=1); namespace Pest\Plugins\Parallel\Paratest; -use function array_merge; -use function array_merge_recursive; -use function array_shift; -use function assert; -use function count; use const DIRECTORY_SEPARATOR; -use function dirname; -use function file_get_contents; -use function max; + use NunoMaduro\Collision\Adapters\Phpunit\Support\ResultReflection; use ParaTest\Coverage\CoverageMerger; use ParaTest\JUnit\LogMerger; @@ -30,11 +23,20 @@ use PHPUnit\TestRunner\TestResult\Facade as TestResultFacade; use PHPUnit\TestRunner\TestResult\TestResult; use PHPUnit\TextUI\Configuration\CodeCoverageFilterRegistry; use PHPUnit\Util\ExcludeList; -use function realpath; use SebastianBergmann\Timer\Timer; use SplFileInfo; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Process\PhpExecutableFinder; + +use function array_merge; +use function array_merge_recursive; +use function array_shift; +use function assert; +use function count; +use function dirname; +use function file_get_contents; +use function max; +use function realpath; use function unlink; use function unserialize; use function usleep; diff --git a/src/Plugins/Parallel/Support/CompactPrinter.php b/src/Plugins/Parallel/Support/CompactPrinter.php index d3175214..25226b10 100644 --- a/src/Plugins/Parallel/Support/CompactPrinter.php +++ b/src/Plugins/Parallel/Support/CompactPrinter.php @@ -16,8 +16,9 @@ use PHPUnit\TestRunner\TestResult\TestResult as PHPUnitTestResult; use SebastianBergmann\Timer\Duration; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; -use function Termwind\render; use Termwind\Terminal; + +use function Termwind\render; use function Termwind\terminal; /** diff --git a/src/Plugins/Version.php b/src/Plugins/Version.php index 8422cb0d..3740f263 100644 --- a/src/Plugins/Version.php +++ b/src/Plugins/Version.php @@ -6,6 +6,7 @@ namespace Pest\Plugins; use Pest\Contracts\Plugins\HandlesArguments; use Pest\Support\View; + use function Pest\version; /** diff --git a/src/Repositories/DatasetsRepository.php b/src/Repositories/DatasetsRepository.php index a43f1a84..1c296fc9 100644 --- a/src/Repositories/DatasetsRepository.php +++ b/src/Repositories/DatasetsRepository.php @@ -10,9 +10,10 @@ use Pest\Exceptions\DatasetAlreadyExists; use Pest\Exceptions\DatasetDoesNotExist; use Pest\Exceptions\ShouldNotHappen; use Pest\Support\Exporter; -use function sprintf; use Traversable; +use function sprintf; + /** * @internal */ diff --git a/src/Support/Coverage.php b/src/Support/Coverage.php index eccff9d3..e0794522 100644 --- a/src/Support/Coverage.php +++ b/src/Support/Coverage.php @@ -10,6 +10,7 @@ use SebastianBergmann\CodeCoverage\Node\Directory; use SebastianBergmann\CodeCoverage\Node\File; use SebastianBergmann\Environment\Runtime; use Symfony\Component\Console\Output\OutputInterface; + use function Termwind\render; use function Termwind\renderUsing; use function Termwind\terminal; diff --git a/src/Support/View.php b/src/Support/View.php index 9d5823a8..a73fd83a 100644 --- a/src/Support/View.php +++ b/src/Support/View.php @@ -5,9 +5,10 @@ declare(strict_types=1); namespace Pest\Support; use Symfony\Component\Console\Output\OutputInterface; +use Termwind\Termwind; + use function Termwind\render; use function Termwind\renderUsing; -use Termwind\Termwind; /** * @internal diff --git a/tests/PHPUnit/CustomTestCase/CustomTestCase.php b/tests/PHPUnit/CustomTestCase/CustomTestCase.php index 8a71327b..8a7a07a4 100644 --- a/tests/PHPUnit/CustomTestCase/CustomTestCase.php +++ b/tests/PHPUnit/CustomTestCase/CustomTestCase.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace Tests\CustomTestCase; -use function PHPUnit\Framework\assertTrue; use PHPUnit\Framework\TestCase; +use function PHPUnit\Framework\assertTrue; + abstract class CustomTestCase extends TestCase { public function assertCustomTrue() diff --git a/tests/PHPUnit/CustomTestCase/ExecutedTest.php b/tests/PHPUnit/CustomTestCase/ExecutedTest.php index 71a32980..29aed3cc 100644 --- a/tests/PHPUnit/CustomTestCase/ExecutedTest.php +++ b/tests/PHPUnit/CustomTestCase/ExecutedTest.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace Tests\CustomTestCase; -use function PHPUnit\Framework\assertTrue; use PHPUnit\Framework\TestCase; +use function PHPUnit\Framework\assertTrue; + class ExecutedTest extends TestCase { public static $executed = false; diff --git a/tests/PHPUnit/CustomTestCase/ParentTest.php b/tests/PHPUnit/CustomTestCase/ParentTest.php index 44d0d452..6ef967d4 100644 --- a/tests/PHPUnit/CustomTestCase/ParentTest.php +++ b/tests/PHPUnit/CustomTestCase/ParentTest.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace Tests\CustomTestCase; -use function PHPUnit\Framework\assertTrue; use PHPUnit\Framework\TestCase; +use function PHPUnit\Framework\assertTrue; + class ParentTest extends TestCase { private function getEntity(): bool From e012517b1643002b36a68096f4a5e26682b1e175 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 16 Aug 2023 09:46:51 +0100 Subject: [PATCH 34/46] chore: bumps phpunit --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 7cdb3224..6b7e7160 100644 --- a/composer.json +++ b/composer.json @@ -23,11 +23,11 @@ "nunomaduro/termwind": "^1.15.1", "pestphp/pest-plugin": "^2.0.1", "pestphp/pest-plugin-arch": "^2.2.3", - "phpunit/phpunit": "^10.3.1" + "phpunit/phpunit": "^10.3.2" }, "conflict": { "webmozart/assert": "<1.11.0", - "phpunit/phpunit": ">10.3.1" + "phpunit/phpunit": ">10.3.2" }, "autoload": { "psr-4": { From a7aa9232415dfea1a880434eec418165bae6be5c Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 16 Aug 2023 09:47:05 +0100 Subject: [PATCH 35/46] release: v2.14.1 --- src/Pest.php | 2 +- .../Visual/Help/visual_snapshot_of_help_command_output.snap | 2 +- .../Visual/Version/visual_snapshot_of_help_command_output.snap | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Pest.php b/src/Pest.php index 6740ab53..1b851c79 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '2.14.0'; + return '2.14.1'; } 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 a13109ba..ed69028a 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.14.0. + Pest Testing Framework 2.14.1. 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 3a032a57..b5d395a6 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.14.0. + Pest Testing Framework 2.14.1. From 72100075d2ae7faa4b6c82d75f5e36b999537df4 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 16 Aug 2023 09:49:07 +0100 Subject: [PATCH 36/46] docs: updates changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae3c506a..31274f87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +## [v2.14.1 (2023-08-16)](https://github.com/pestphp/pest/compare/v2.14.0...v2.14.1) + +### Changed + +- Bumps PHPUnit to `^10.3.2` ([e012517](https://github.com/pestphp/pest/commit/e012517b1643002b36a68096f4a5e26682b1e175)) + ## [v2.14.0 (2023-08-14)](https://github.com/pestphp/pest/compare/v2.13.0...v2.14.0) ### Added From c0a234317b26bc79fcd6393b28c9a799aa517b9e Mon Sep 17 00:00:00 2001 From: AJ Meireles Date: Wed, 16 Aug 2023 14:16:18 -0300 Subject: [PATCH 37/46] introducing issue template --- .github/ISSUE_TEMPLATE/bug_report.yml | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000..ebabc02d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,59 @@ +name: Bug Report +description: Report an Issue or Bug with the Pest +title: "[Bug]: " +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + We're sorry to hear you have a problem. Can you help us solve it by providing the following details. + - type: textarea + id: what-happened + attributes: + label: What Happened + description: What did you expect to happen? + validations: + required: true + - type: textarea + id: how-to-reproduce + attributes: + label: How to Reproduce + description: How did this occur, please add any config values used and provide a set of reliable steps if possible. + placeholder: When I use expect()->toBeTrue() in my tests, I get an error. + validations: + required: true + - type: input + id: pest-version + attributes: + label: Pest Version + description: What version of our Package are you running? Please be as specific as possible + placeholder: 2.14.1 + validations: + required: true + - type: input + id: php-version + attributes: + label: PHP Version + description: What version of PHP are you running? Please be as specific as possible + placeholder: 8.1.20 + validations: + required: true + - type: dropdown + id: operating-systems + attributes: + label: Operation System + description: On which operating systems does the problem occur? You can select more than one. + multiple: true + options: + - macOS + - Windows + - Linux + validations: + required: true + - type: textarea + id: notes + attributes: + label: Notes + description: Use this field to provide any other notes that you feel might be relevant to the issue. + validations: + required: false From 0263fcb2ac09f46be9cd05b0c6eba9d1e15d58c5 Mon Sep 17 00:00:00 2001 From: AJ Meireles Date: Wed, 16 Aug 2023 14:18:09 -0300 Subject: [PATCH 38/46] wip --- .github/ISSUE_TEMPLATE/bug_report.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index ebabc02d..ab584351 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -12,6 +12,7 @@ body: attributes: label: What Happened description: What did you expect to happen? + placeholder: When I use expect()->toBeTrue() in my tests, I get an error validations: required: true - type: textarea @@ -19,7 +20,7 @@ body: attributes: label: How to Reproduce description: How did this occur, please add any config values used and provide a set of reliable steps if possible. - placeholder: When I use expect()->toBeTrue() in my tests, I get an error. + placeholder: Install a fresh Laravel app, add Pest, add a test that uses expect()->toBeTrue() validations: required: true - type: input From f0223b50d039f8616b3c68feba335667c4e1d334 Mon Sep 17 00:00:00 2001 From: AJ Meireles Date: Wed, 16 Aug 2023 15:50:40 -0300 Subject: [PATCH 39/46] introducing sample repository input --- .github/ISSUE_TEMPLATE/bug_report.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index ab584351..ce3259e3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -23,6 +23,12 @@ body: placeholder: Install a fresh Laravel app, add Pest, add a test that uses expect()->toBeTrue() validations: required: true + - type: input + id: repository-sample + attributes: + label: Sample Repository + description: If possible, please provide a sample repository that reproduces the issue. + placeholder: https://github.com.br/your-username/your-repository - type: input id: pest-version attributes: From 0787b37f2c740e824e279225ec7cbfdc3650bcf2 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 17 Aug 2023 11:18:59 +0100 Subject: [PATCH 40/46] chore: style changes --- .../Runner/Filter/NameFilterIterator.php | 7 +++---- .../Runner/ResultCache/DefaultResultCache.php | 12 +++++------ overrides/Runner/TestSuiteLoader.php | 11 +++++----- overrides/TextUI/TestSuiteFilterProcessor.php | 3 +-- src/Bootstrappers/BootFiles.php | 3 +-- src/Expectations/EachExpectation.php | 3 +-- src/Factories/Attributes/Attribute.php | 2 +- src/Factories/TestCaseFactory.php | 2 +- src/KernelDump.php | 2 +- src/Plugins/Help.php | 3 +-- src/Plugins/Parallel.php | 3 +-- .../Parallel/Paratest/ResultPrinter.php | 19 +++++++++--------- .../Parallel/Paratest/WrapperRunner.php | 20 +++++++++---------- .../Parallel/Support/CompactPrinter.php | 3 +-- src/Plugins/Version.php | 1 - src/Repositories/DatasetsRepository.php | 3 +-- src/Support/Coverage.php | 1 - src/Support/View.php | 3 +-- .../PHPUnit/CustomTestCase/CustomTestCase.php | 3 +-- tests/PHPUnit/CustomTestCase/ExecutedTest.php | 3 +-- tests/PHPUnit/CustomTestCase/ParentTest.php | 3 +-- 21 files changed, 45 insertions(+), 65 deletions(-) diff --git a/overrides/Runner/Filter/NameFilterIterator.php b/overrides/Runner/Filter/NameFilterIterator.php index 8b740c3f..391c3ed5 100644 --- a/overrides/Runner/Filter/NameFilterIterator.php +++ b/overrides/Runner/Filter/NameFilterIterator.php @@ -34,18 +34,17 @@ namespace PHPUnit\Runner\Filter; +use function end; use Exception; +use function implode; use Pest\Contracts\HasPrintableTestCaseName; use PHPUnit\Framework\SelfDescribing; use PHPUnit\Framework\Test; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestSuite; +use function preg_match; use RecursiveFilterIterator; use RecursiveIterator; - -use function end; -use function implode; -use function preg_match; use function sprintf; use function str_replace; diff --git a/overrides/Runner/ResultCache/DefaultResultCache.php b/overrides/Runner/ResultCache/DefaultResultCache.php index c64602c0..40134011 100644 --- a/overrides/Runner/ResultCache/DefaultResultCache.php +++ b/overrides/Runner/ResultCache/DefaultResultCache.php @@ -45,15 +45,9 @@ declare(strict_types=1); namespace PHPUnit\Runner\ResultCache; -use const DIRECTORY_SEPARATOR; - -use PHPUnit\Framework\TestStatus\TestStatus; -use PHPUnit\Runner\DirectoryCannotBeCreatedException; -use PHPUnit\Runner\Exception; -use PHPUnit\Util\Filesystem; - use function array_keys; use function assert; +use const DIRECTORY_SEPARATOR; use function dirname; use function file_get_contents; use function file_put_contents; @@ -63,6 +57,10 @@ use function is_file; use function json_decode; use function json_encode; use function Pest\version; +use PHPUnit\Framework\TestStatus\TestStatus; +use PHPUnit\Runner\DirectoryCannotBeCreatedException; +use PHPUnit\Runner\Exception; +use PHPUnit\Util\Filesystem; /** * @internal This class is not covered by the backward compatibility promise for PHPUnit diff --git a/overrides/Runner/TestSuiteLoader.php b/overrides/Runner/TestSuiteLoader.php index 9c1a0935..b6a5e754 100644 --- a/overrides/Runner/TestSuiteLoader.php +++ b/overrides/Runner/TestSuiteLoader.php @@ -36,19 +36,18 @@ declare(strict_types=1); namespace PHPUnit\Runner; +use function array_diff; +use function array_values; +use function basename; +use function class_exists; use Exception; +use function get_declared_classes; use Pest\Contracts\HasPrintableTestCaseName; use Pest\TestCases\IgnorableTestCase; use Pest\TestSuite; use PHPUnit\Framework\TestCase; use ReflectionClass; use ReflectionException; - -use function array_diff; -use function array_values; -use function basename; -use function class_exists; -use function get_declared_classes; use function substr; /** diff --git a/overrides/TextUI/TestSuiteFilterProcessor.php b/overrides/TextUI/TestSuiteFilterProcessor.php index f4473289..31ce5fe6 100644 --- a/overrides/TextUI/TestSuiteFilterProcessor.php +++ b/overrides/TextUI/TestSuiteFilterProcessor.php @@ -45,6 +45,7 @@ declare(strict_types=1); namespace PHPUnit\TextUI; +use function array_map; use Pest\Plugins\Only; use PHPUnit\Event; use PHPUnit\Framework\TestSuite; @@ -52,8 +53,6 @@ use PHPUnit\Runner\Filter\Factory; use PHPUnit\TextUI\Configuration\Configuration; use PHPUnit\TextUI\Configuration\FilterNotConfiguredException; -use function array_map; - /** * @internal This class is not covered by the backward compatibility promise for PHPUnit */ diff --git a/src/Bootstrappers/BootFiles.php b/src/Bootstrappers/BootFiles.php index 411fd007..3add2a70 100644 --- a/src/Bootstrappers/BootFiles.php +++ b/src/Bootstrappers/BootFiles.php @@ -7,13 +7,12 @@ namespace Pest\Bootstrappers; use Pest\Contracts\Bootstrapper; use Pest\Support\DatasetInfo; use Pest\Support\Str; +use function Pest\testDirectory; use Pest\TestSuite; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use SebastianBergmann\FileIterator\Facade as PhpUnitFileIterator; -use function Pest\testDirectory; - /** * @internal */ diff --git a/src/Expectations/EachExpectation.php b/src/Expectations/EachExpectation.php index e5df6e9c..56cd937b 100644 --- a/src/Expectations/EachExpectation.php +++ b/src/Expectations/EachExpectation.php @@ -4,9 +4,8 @@ declare(strict_types=1); namespace Pest\Expectations; -use Pest\Expectation; - use function expect; +use Pest\Expectation; /** * @internal diff --git a/src/Factories/Attributes/Attribute.php b/src/Factories/Attributes/Attribute.php index 9bd43de9..21df216d 100644 --- a/src/Factories/Attributes/Attribute.php +++ b/src/Factories/Attributes/Attribute.php @@ -20,7 +20,7 @@ abstract class Attribute * @param array $attributes * @return array */ - public function __invoke(TestCaseMethodFactory $method, array $attributes): array // @phpstan-ignore-line + public function __invoke(TestCaseMethodFactory $method, array $attributes): array { return $attributes; } diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index cbe50985..98ccb3aa 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -193,7 +193,7 @@ final class TestCaseFactory } PHP; - eval($classCode); // @phpstan-ignore-line + eval($classCode); } catch (ParseError $caught) { throw new RuntimeException(sprintf( "Unable to create test case for test file at %s. \n %s", diff --git a/src/KernelDump.php b/src/KernelDump.php index 39f2004b..6e1833ca 100644 --- a/src/KernelDump.php +++ b/src/KernelDump.php @@ -40,7 +40,7 @@ final class KernelDump */ public function disable(): void { - @ob_clean(); // @phpstan-ignore-line + @ob_clean(); if ($this->buffer !== '') { $this->flush(); diff --git a/src/Plugins/Help.php b/src/Plugins/Help.php index c8e4d32f..b0643461 100644 --- a/src/Plugins/Help.php +++ b/src/Plugins/Help.php @@ -6,11 +6,10 @@ namespace Pest\Plugins; use Pest\Contracts\Plugins\HandlesArguments; use Pest\Support\View; +use function Pest\version; use PHPUnit\TextUI\Help as PHPUnitHelp; use Symfony\Component\Console\Output\OutputInterface; -use function Pest\version; - /** * @internal */ diff --git a/src/Plugins/Parallel.php b/src/Plugins/Parallel.php index fd643471..3354b743 100644 --- a/src/Plugins/Parallel.php +++ b/src/Plugins/Parallel.php @@ -13,12 +13,11 @@ use Pest\Plugins\Parallel\Paratest\CleanConsoleOutput; use Pest\Support\Arr; use Pest\Support\Container; use Pest\TestSuite; +use function Pest\version; use Stringable; use Symfony\Component\Console\Application; use Symfony\Component\Console\Input\ArgvInput; -use function Pest\version; - final class Parallel implements HandlesArguments { use HandleArguments; diff --git a/src/Plugins/Parallel/Paratest/ResultPrinter.php b/src/Plugins/Parallel/Paratest/ResultPrinter.php index 1e9cc245..f9d96ca2 100644 --- a/src/Plugins/Parallel/Paratest/ResultPrinter.php +++ b/src/Plugins/Parallel/Paratest/ResultPrinter.php @@ -4,16 +4,6 @@ declare(strict_types=1); namespace Pest\Plugins\Parallel\Paratest; -use ParaTest\Options; -use Pest\Plugins\Parallel\Support\CompactPrinter; -use Pest\Support\StateGenerator; -use PHPUnit\TestRunner\TestResult\TestResult; -use PHPUnit\TextUI\Output\Printer; -use SebastianBergmann\Timer\Duration; -use SplFileInfo; -use Symfony\Component\Console\Formatter\OutputFormatter; -use Symfony\Component\Console\Output\OutputInterface; - use function assert; use function fclose; use function feof; @@ -22,7 +12,16 @@ use function fread; use function fseek; use function ftell; use function fwrite; +use ParaTest\Options; +use Pest\Plugins\Parallel\Support\CompactPrinter; +use Pest\Support\StateGenerator; +use PHPUnit\TestRunner\TestResult\TestResult; +use PHPUnit\TextUI\Output\Printer; +use SebastianBergmann\Timer\Duration; +use SplFileInfo; use function strlen; +use Symfony\Component\Console\Formatter\OutputFormatter; +use Symfony\Component\Console\Output\OutputInterface; /** * @internal diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 8b75bc4c..248c1bc5 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -4,8 +4,15 @@ declare(strict_types=1); namespace Pest\Plugins\Parallel\Paratest; +use function array_merge; +use function array_merge_recursive; +use function array_shift; +use function assert; +use function count; use const DIRECTORY_SEPARATOR; - +use function dirname; +use function file_get_contents; +use function max; use NunoMaduro\Collision\Adapters\Phpunit\Support\ResultReflection; use ParaTest\Coverage\CoverageMerger; use ParaTest\JUnit\LogMerger; @@ -23,20 +30,11 @@ use PHPUnit\TestRunner\TestResult\Facade as TestResultFacade; use PHPUnit\TestRunner\TestResult\TestResult; use PHPUnit\TextUI\Configuration\CodeCoverageFilterRegistry; use PHPUnit\Util\ExcludeList; +use function realpath; use SebastianBergmann\Timer\Timer; use SplFileInfo; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Process\PhpExecutableFinder; - -use function array_merge; -use function array_merge_recursive; -use function array_shift; -use function assert; -use function count; -use function dirname; -use function file_get_contents; -use function max; -use function realpath; use function unlink; use function unserialize; use function usleep; diff --git a/src/Plugins/Parallel/Support/CompactPrinter.php b/src/Plugins/Parallel/Support/CompactPrinter.php index 25226b10..d3175214 100644 --- a/src/Plugins/Parallel/Support/CompactPrinter.php +++ b/src/Plugins/Parallel/Support/CompactPrinter.php @@ -16,9 +16,8 @@ use PHPUnit\TestRunner\TestResult\TestResult as PHPUnitTestResult; use SebastianBergmann\Timer\Duration; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; -use Termwind\Terminal; - use function Termwind\render; +use Termwind\Terminal; use function Termwind\terminal; /** diff --git a/src/Plugins/Version.php b/src/Plugins/Version.php index 3740f263..8422cb0d 100644 --- a/src/Plugins/Version.php +++ b/src/Plugins/Version.php @@ -6,7 +6,6 @@ namespace Pest\Plugins; use Pest\Contracts\Plugins\HandlesArguments; use Pest\Support\View; - use function Pest\version; /** diff --git a/src/Repositories/DatasetsRepository.php b/src/Repositories/DatasetsRepository.php index 1c296fc9..a43f1a84 100644 --- a/src/Repositories/DatasetsRepository.php +++ b/src/Repositories/DatasetsRepository.php @@ -10,9 +10,8 @@ use Pest\Exceptions\DatasetAlreadyExists; use Pest\Exceptions\DatasetDoesNotExist; use Pest\Exceptions\ShouldNotHappen; use Pest\Support\Exporter; -use Traversable; - use function sprintf; +use Traversable; /** * @internal diff --git a/src/Support/Coverage.php b/src/Support/Coverage.php index e0794522..eccff9d3 100644 --- a/src/Support/Coverage.php +++ b/src/Support/Coverage.php @@ -10,7 +10,6 @@ use SebastianBergmann\CodeCoverage\Node\Directory; use SebastianBergmann\CodeCoverage\Node\File; use SebastianBergmann\Environment\Runtime; use Symfony\Component\Console\Output\OutputInterface; - use function Termwind\render; use function Termwind\renderUsing; use function Termwind\terminal; diff --git a/src/Support/View.php b/src/Support/View.php index a73fd83a..9d5823a8 100644 --- a/src/Support/View.php +++ b/src/Support/View.php @@ -5,10 +5,9 @@ declare(strict_types=1); namespace Pest\Support; use Symfony\Component\Console\Output\OutputInterface; -use Termwind\Termwind; - use function Termwind\render; use function Termwind\renderUsing; +use Termwind\Termwind; /** * @internal diff --git a/tests/PHPUnit/CustomTestCase/CustomTestCase.php b/tests/PHPUnit/CustomTestCase/CustomTestCase.php index 8a7a07a4..8a71327b 100644 --- a/tests/PHPUnit/CustomTestCase/CustomTestCase.php +++ b/tests/PHPUnit/CustomTestCase/CustomTestCase.php @@ -4,9 +4,8 @@ declare(strict_types=1); namespace Tests\CustomTestCase; -use PHPUnit\Framework\TestCase; - use function PHPUnit\Framework\assertTrue; +use PHPUnit\Framework\TestCase; abstract class CustomTestCase extends TestCase { diff --git a/tests/PHPUnit/CustomTestCase/ExecutedTest.php b/tests/PHPUnit/CustomTestCase/ExecutedTest.php index 29aed3cc..71a32980 100644 --- a/tests/PHPUnit/CustomTestCase/ExecutedTest.php +++ b/tests/PHPUnit/CustomTestCase/ExecutedTest.php @@ -4,9 +4,8 @@ declare(strict_types=1); namespace Tests\CustomTestCase; -use PHPUnit\Framework\TestCase; - use function PHPUnit\Framework\assertTrue; +use PHPUnit\Framework\TestCase; class ExecutedTest extends TestCase { diff --git a/tests/PHPUnit/CustomTestCase/ParentTest.php b/tests/PHPUnit/CustomTestCase/ParentTest.php index 6ef967d4..44d0d452 100644 --- a/tests/PHPUnit/CustomTestCase/ParentTest.php +++ b/tests/PHPUnit/CustomTestCase/ParentTest.php @@ -4,9 +4,8 @@ declare(strict_types=1); namespace Tests\CustomTestCase; -use PHPUnit\Framework\TestCase; - use function PHPUnit\Framework\assertTrue; +use PHPUnit\Framework\TestCase; class ParentTest extends TestCase { From f19692a72f786e26b23a41a6f8f6d8905d971f2b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 17 Aug 2023 11:19:11 +0100 Subject: [PATCH 41/46] chore: changes phpstan settings --- composer.json | 2 +- phpstan.neon | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 6b7e7160..5e9cb34c 100644 --- a/composer.json +++ b/composer.json @@ -50,7 +50,7 @@ ] }, "require-dev": { - "pestphp/pest-dev-tools": "^2.14.0", + "pestphp/pest-dev-tools": "^2.15.0", "pestphp/pest-plugin-type-coverage": "^2.0.0", "symfony/process": "^6.3.2" }, diff --git a/phpstan.neon b/phpstan.neon index 1cd3a087..9ed48871 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,5 @@ includes: - vendor/phpstan/phpstan-strict-rules/rules.neon - - vendor/ergebnis/phpstan-rules/rules.neon - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon parameters: @@ -12,12 +11,4 @@ parameters: reportUnmatchedIgnoredErrors: true ignoreErrors: - - "#has a nullable return type declaration.#" - - "#Language construct isset\\(\\) should not be used.#" - - "#is not allowed to extend#" - - "#is concrete, but does not have a Test suffix#" - - "#with a nullable type declaration#" - "#type mixed is not subtype of native#" - - "# with null as default value#" - - "#has parameter \\$closure with default value.#" - - "#has parameter \\$description with default value.#" From 0b261ef97b7ceed20cbeeb2b0b41e08e0a8fcaa1 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 17 Aug 2023 11:19:43 +0100 Subject: [PATCH 42/46] feat: adds `php@8.3` support --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5c80602f..448cb235 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - php: ['8.1', '8.2'] + php: ['8.1', '8.2', '8.3'] dependency-version: [prefer-lowest, prefer-stable] name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} From 492f797dd5e85baf0ca517291917d545725a8a4d Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 17 Aug 2023 11:24:16 +0100 Subject: [PATCH 43/46] chore: style changes --- .../Runner/Filter/NameFilterIterator.php | 7 ++++--- .../Runner/ResultCache/DefaultResultCache.php | 12 ++++++----- overrides/Runner/TestSuiteLoader.php | 11 +++++----- overrides/TextUI/TestSuiteFilterProcessor.php | 3 ++- src/Bootstrappers/BootFiles.php | 3 ++- src/Expectations/EachExpectation.php | 3 ++- src/Plugins/Help.php | 3 ++- src/Plugins/Parallel.php | 3 ++- .../Parallel/Paratest/ResultPrinter.php | 19 +++++++++--------- .../Parallel/Paratest/WrapperRunner.php | 20 ++++++++++--------- .../Parallel/Support/CompactPrinter.php | 3 ++- src/Plugins/Version.php | 1 + src/Repositories/DatasetsRepository.php | 3 ++- src/Support/Coverage.php | 1 + src/Support/View.php | 3 ++- .../PHPUnit/CustomTestCase/CustomTestCase.php | 3 ++- tests/PHPUnit/CustomTestCase/ExecutedTest.php | 3 ++- tests/PHPUnit/CustomTestCase/ParentTest.php | 3 ++- 18 files changed, 62 insertions(+), 42 deletions(-) diff --git a/overrides/Runner/Filter/NameFilterIterator.php b/overrides/Runner/Filter/NameFilterIterator.php index 391c3ed5..8b740c3f 100644 --- a/overrides/Runner/Filter/NameFilterIterator.php +++ b/overrides/Runner/Filter/NameFilterIterator.php @@ -34,17 +34,18 @@ namespace PHPUnit\Runner\Filter; -use function end; use Exception; -use function implode; use Pest\Contracts\HasPrintableTestCaseName; use PHPUnit\Framework\SelfDescribing; use PHPUnit\Framework\Test; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestSuite; -use function preg_match; use RecursiveFilterIterator; use RecursiveIterator; + +use function end; +use function implode; +use function preg_match; use function sprintf; use function str_replace; diff --git a/overrides/Runner/ResultCache/DefaultResultCache.php b/overrides/Runner/ResultCache/DefaultResultCache.php index 40134011..c64602c0 100644 --- a/overrides/Runner/ResultCache/DefaultResultCache.php +++ b/overrides/Runner/ResultCache/DefaultResultCache.php @@ -45,9 +45,15 @@ declare(strict_types=1); namespace PHPUnit\Runner\ResultCache; +use const DIRECTORY_SEPARATOR; + +use PHPUnit\Framework\TestStatus\TestStatus; +use PHPUnit\Runner\DirectoryCannotBeCreatedException; +use PHPUnit\Runner\Exception; +use PHPUnit\Util\Filesystem; + use function array_keys; use function assert; -use const DIRECTORY_SEPARATOR; use function dirname; use function file_get_contents; use function file_put_contents; @@ -57,10 +63,6 @@ use function is_file; use function json_decode; use function json_encode; use function Pest\version; -use PHPUnit\Framework\TestStatus\TestStatus; -use PHPUnit\Runner\DirectoryCannotBeCreatedException; -use PHPUnit\Runner\Exception; -use PHPUnit\Util\Filesystem; /** * @internal This class is not covered by the backward compatibility promise for PHPUnit diff --git a/overrides/Runner/TestSuiteLoader.php b/overrides/Runner/TestSuiteLoader.php index b6a5e754..9c1a0935 100644 --- a/overrides/Runner/TestSuiteLoader.php +++ b/overrides/Runner/TestSuiteLoader.php @@ -36,18 +36,19 @@ declare(strict_types=1); namespace PHPUnit\Runner; -use function array_diff; -use function array_values; -use function basename; -use function class_exists; use Exception; -use function get_declared_classes; use Pest\Contracts\HasPrintableTestCaseName; use Pest\TestCases\IgnorableTestCase; use Pest\TestSuite; use PHPUnit\Framework\TestCase; use ReflectionClass; use ReflectionException; + +use function array_diff; +use function array_values; +use function basename; +use function class_exists; +use function get_declared_classes; use function substr; /** diff --git a/overrides/TextUI/TestSuiteFilterProcessor.php b/overrides/TextUI/TestSuiteFilterProcessor.php index 31ce5fe6..f4473289 100644 --- a/overrides/TextUI/TestSuiteFilterProcessor.php +++ b/overrides/TextUI/TestSuiteFilterProcessor.php @@ -45,7 +45,6 @@ declare(strict_types=1); namespace PHPUnit\TextUI; -use function array_map; use Pest\Plugins\Only; use PHPUnit\Event; use PHPUnit\Framework\TestSuite; @@ -53,6 +52,8 @@ use PHPUnit\Runner\Filter\Factory; use PHPUnit\TextUI\Configuration\Configuration; use PHPUnit\TextUI\Configuration\FilterNotConfiguredException; +use function array_map; + /** * @internal This class is not covered by the backward compatibility promise for PHPUnit */ diff --git a/src/Bootstrappers/BootFiles.php b/src/Bootstrappers/BootFiles.php index 3add2a70..411fd007 100644 --- a/src/Bootstrappers/BootFiles.php +++ b/src/Bootstrappers/BootFiles.php @@ -7,12 +7,13 @@ namespace Pest\Bootstrappers; use Pest\Contracts\Bootstrapper; use Pest\Support\DatasetInfo; use Pest\Support\Str; -use function Pest\testDirectory; use Pest\TestSuite; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use SebastianBergmann\FileIterator\Facade as PhpUnitFileIterator; +use function Pest\testDirectory; + /** * @internal */ diff --git a/src/Expectations/EachExpectation.php b/src/Expectations/EachExpectation.php index 56cd937b..e5df6e9c 100644 --- a/src/Expectations/EachExpectation.php +++ b/src/Expectations/EachExpectation.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace Pest\Expectations; -use function expect; use Pest\Expectation; +use function expect; + /** * @internal * diff --git a/src/Plugins/Help.php b/src/Plugins/Help.php index b0643461..c8e4d32f 100644 --- a/src/Plugins/Help.php +++ b/src/Plugins/Help.php @@ -6,10 +6,11 @@ namespace Pest\Plugins; use Pest\Contracts\Plugins\HandlesArguments; use Pest\Support\View; -use function Pest\version; use PHPUnit\TextUI\Help as PHPUnitHelp; use Symfony\Component\Console\Output\OutputInterface; +use function Pest\version; + /** * @internal */ diff --git a/src/Plugins/Parallel.php b/src/Plugins/Parallel.php index 3354b743..fd643471 100644 --- a/src/Plugins/Parallel.php +++ b/src/Plugins/Parallel.php @@ -13,11 +13,12 @@ use Pest\Plugins\Parallel\Paratest\CleanConsoleOutput; use Pest\Support\Arr; use Pest\Support\Container; use Pest\TestSuite; -use function Pest\version; use Stringable; use Symfony\Component\Console\Application; use Symfony\Component\Console\Input\ArgvInput; +use function Pest\version; + final class Parallel implements HandlesArguments { use HandleArguments; diff --git a/src/Plugins/Parallel/Paratest/ResultPrinter.php b/src/Plugins/Parallel/Paratest/ResultPrinter.php index f9d96ca2..1e9cc245 100644 --- a/src/Plugins/Parallel/Paratest/ResultPrinter.php +++ b/src/Plugins/Parallel/Paratest/ResultPrinter.php @@ -4,6 +4,16 @@ declare(strict_types=1); namespace Pest\Plugins\Parallel\Paratest; +use ParaTest\Options; +use Pest\Plugins\Parallel\Support\CompactPrinter; +use Pest\Support\StateGenerator; +use PHPUnit\TestRunner\TestResult\TestResult; +use PHPUnit\TextUI\Output\Printer; +use SebastianBergmann\Timer\Duration; +use SplFileInfo; +use Symfony\Component\Console\Formatter\OutputFormatter; +use Symfony\Component\Console\Output\OutputInterface; + use function assert; use function fclose; use function feof; @@ -12,16 +22,7 @@ use function fread; use function fseek; use function ftell; use function fwrite; -use ParaTest\Options; -use Pest\Plugins\Parallel\Support\CompactPrinter; -use Pest\Support\StateGenerator; -use PHPUnit\TestRunner\TestResult\TestResult; -use PHPUnit\TextUI\Output\Printer; -use SebastianBergmann\Timer\Duration; -use SplFileInfo; use function strlen; -use Symfony\Component\Console\Formatter\OutputFormatter; -use Symfony\Component\Console\Output\OutputInterface; /** * @internal diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 248c1bc5..8b75bc4c 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -4,15 +4,8 @@ declare(strict_types=1); namespace Pest\Plugins\Parallel\Paratest; -use function array_merge; -use function array_merge_recursive; -use function array_shift; -use function assert; -use function count; use const DIRECTORY_SEPARATOR; -use function dirname; -use function file_get_contents; -use function max; + use NunoMaduro\Collision\Adapters\Phpunit\Support\ResultReflection; use ParaTest\Coverage\CoverageMerger; use ParaTest\JUnit\LogMerger; @@ -30,11 +23,20 @@ use PHPUnit\TestRunner\TestResult\Facade as TestResultFacade; use PHPUnit\TestRunner\TestResult\TestResult; use PHPUnit\TextUI\Configuration\CodeCoverageFilterRegistry; use PHPUnit\Util\ExcludeList; -use function realpath; use SebastianBergmann\Timer\Timer; use SplFileInfo; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Process\PhpExecutableFinder; + +use function array_merge; +use function array_merge_recursive; +use function array_shift; +use function assert; +use function count; +use function dirname; +use function file_get_contents; +use function max; +use function realpath; use function unlink; use function unserialize; use function usleep; diff --git a/src/Plugins/Parallel/Support/CompactPrinter.php b/src/Plugins/Parallel/Support/CompactPrinter.php index d3175214..25226b10 100644 --- a/src/Plugins/Parallel/Support/CompactPrinter.php +++ b/src/Plugins/Parallel/Support/CompactPrinter.php @@ -16,8 +16,9 @@ use PHPUnit\TestRunner\TestResult\TestResult as PHPUnitTestResult; use SebastianBergmann\Timer\Duration; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; -use function Termwind\render; use Termwind\Terminal; + +use function Termwind\render; use function Termwind\terminal; /** diff --git a/src/Plugins/Version.php b/src/Plugins/Version.php index 8422cb0d..3740f263 100644 --- a/src/Plugins/Version.php +++ b/src/Plugins/Version.php @@ -6,6 +6,7 @@ namespace Pest\Plugins; use Pest\Contracts\Plugins\HandlesArguments; use Pest\Support\View; + use function Pest\version; /** diff --git a/src/Repositories/DatasetsRepository.php b/src/Repositories/DatasetsRepository.php index a43f1a84..1c296fc9 100644 --- a/src/Repositories/DatasetsRepository.php +++ b/src/Repositories/DatasetsRepository.php @@ -10,9 +10,10 @@ use Pest\Exceptions\DatasetAlreadyExists; use Pest\Exceptions\DatasetDoesNotExist; use Pest\Exceptions\ShouldNotHappen; use Pest\Support\Exporter; -use function sprintf; use Traversable; +use function sprintf; + /** * @internal */ diff --git a/src/Support/Coverage.php b/src/Support/Coverage.php index eccff9d3..e0794522 100644 --- a/src/Support/Coverage.php +++ b/src/Support/Coverage.php @@ -10,6 +10,7 @@ use SebastianBergmann\CodeCoverage\Node\Directory; use SebastianBergmann\CodeCoverage\Node\File; use SebastianBergmann\Environment\Runtime; use Symfony\Component\Console\Output\OutputInterface; + use function Termwind\render; use function Termwind\renderUsing; use function Termwind\terminal; diff --git a/src/Support/View.php b/src/Support/View.php index 9d5823a8..a73fd83a 100644 --- a/src/Support/View.php +++ b/src/Support/View.php @@ -5,9 +5,10 @@ declare(strict_types=1); namespace Pest\Support; use Symfony\Component\Console\Output\OutputInterface; +use Termwind\Termwind; + use function Termwind\render; use function Termwind\renderUsing; -use Termwind\Termwind; /** * @internal diff --git a/tests/PHPUnit/CustomTestCase/CustomTestCase.php b/tests/PHPUnit/CustomTestCase/CustomTestCase.php index 8a71327b..8a7a07a4 100644 --- a/tests/PHPUnit/CustomTestCase/CustomTestCase.php +++ b/tests/PHPUnit/CustomTestCase/CustomTestCase.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace Tests\CustomTestCase; -use function PHPUnit\Framework\assertTrue; use PHPUnit\Framework\TestCase; +use function PHPUnit\Framework\assertTrue; + abstract class CustomTestCase extends TestCase { public function assertCustomTrue() diff --git a/tests/PHPUnit/CustomTestCase/ExecutedTest.php b/tests/PHPUnit/CustomTestCase/ExecutedTest.php index 71a32980..29aed3cc 100644 --- a/tests/PHPUnit/CustomTestCase/ExecutedTest.php +++ b/tests/PHPUnit/CustomTestCase/ExecutedTest.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace Tests\CustomTestCase; -use function PHPUnit\Framework\assertTrue; use PHPUnit\Framework\TestCase; +use function PHPUnit\Framework\assertTrue; + class ExecutedTest extends TestCase { public static $executed = false; diff --git a/tests/PHPUnit/CustomTestCase/ParentTest.php b/tests/PHPUnit/CustomTestCase/ParentTest.php index 44d0d452..6ef967d4 100644 --- a/tests/PHPUnit/CustomTestCase/ParentTest.php +++ b/tests/PHPUnit/CustomTestCase/ParentTest.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace Tests\CustomTestCase; -use function PHPUnit\Framework\assertTrue; use PHPUnit\Framework\TestCase; +use function PHPUnit\Framework\assertTrue; + class ParentTest extends TestCase { private function getEntity(): bool From c2985ffb319211cc186e30e80c040f2aff0bb182 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 17 Aug 2023 11:28:55 +0100 Subject: [PATCH 44/46] release: v2.15.0 --- CHANGELOG.md | 6 ++++++ src/Pest.php | 2 +- .../Visual/Help/visual_snapshot_of_help_command_output.snap | 2 +- .../Version/visual_snapshot_of_help_command_output.snap | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31274f87..ebeeafe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +## [v2.15.0 (2023-08-17)](https://github.com/pestphp/pest/compare/v2.14.1...v2.15.0) + +### Added + +- PHP 8.3 support ([0b261ef](https://github.com/pestphp/pest/commit/0b261ef97b7ceed20cbeeb2b0b41e08e0a8fcaa1)) + ## [v2.14.1 (2023-08-16)](https://github.com/pestphp/pest/compare/v2.14.0...v2.14.1) ### Changed diff --git a/src/Pest.php b/src/Pest.php index 1b851c79..cb694f20 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '2.14.1'; + return '2.15.0'; } 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 ed69028a..b0b2199c 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.14.1. + Pest Testing Framework 2.15.0. 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 b5d395a6..9751ccf0 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.14.1. + Pest Testing Framework 2.15.0. From 7914224ff7420fa2da7097116656cc9e8089d055 Mon Sep 17 00:00:00 2001 From: AJ Meireles Date: Thu, 17 Aug 2023 15:50:15 -0300 Subject: [PATCH 45/46] introducing https://schema.phpunit.de/10.3/phpunit.xsd --- stubs/init-laravel/phpunit.xml.stub | 2 +- stubs/init/phpunit.xml.stub | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/init-laravel/phpunit.xml.stub b/stubs/init-laravel/phpunit.xml.stub index eb13aff1..9ce6b780 100644 --- a/stubs/init-laravel/phpunit.xml.stub +++ b/stubs/init-laravel/phpunit.xml.stub @@ -1,6 +1,6 @@ diff --git a/stubs/init/phpunit.xml.stub b/stubs/init/phpunit.xml.stub index ada83de9..70a8572e 100644 --- a/stubs/init/phpunit.xml.stub +++ b/stubs/init/phpunit.xml.stub @@ -1,6 +1,6 @@ From d218afaf777b84fbc9b176b0ffd8aaf776f90b9f Mon Sep 17 00:00:00 2001 From: AJ Meireles Date: Thu, 17 Aug 2023 18:50:23 -0300 Subject: [PATCH 46/46] introducing new proposal of the PR template --- .github/PULL_REQUEST_TEMPLATE.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6b729631..742d2bc8 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,10 +1,16 @@ -| Q | A -| ------------- | --- -| Bug fix? | yes/no -| New feature? | yes/no -| Fixed tickets | #... - +### What: + +- [ ] Bug Fix +- [ ] New Feature + +### Description: + + + +### Related: + +