From 6bad9d302b0d4562b5d0d74a5914e506948763e0 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 25 Sep 2022 11:38:25 +0100 Subject: [PATCH 01/21] Fixes coverage size --- src/Support/Coverage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Support/Coverage.php b/src/Support/Coverage.php index 3d409ceb..743c73ab 100644 --- a/src/Support/Coverage.php +++ b/src/Support/Coverage.php @@ -85,7 +85,7 @@ final class Coverage $totalWidth = (new Terminal())->getWidth(); - $dottedLineLength = $totalWidth <= 70 ? $totalWidth : 70; + $dottedLineLength = $totalWidth - 6; $totalCoverage = $codeCoverage->getReport()->percentageOfExecutedLines(); From 5c4e98cf0c3b566aa017d9639a73df59d6832aa0 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 25 Sep 2022 11:40:38 +0100 Subject: [PATCH 02/21] Docs --- src/Repositories/TestRepository.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Repositories/TestRepository.php b/src/Repositories/TestRepository.php index dce67e78..ff302cf7 100644 --- a/src/Repositories/TestRepository.php +++ b/src/Repositories/TestRepository.php @@ -84,6 +84,9 @@ final class TestRepository } } + /** + * Gets the test case factory from the given filename. + */ public function get(string $filename): TestCaseFactory { return $this->testCases[$filename]; From e2ab53ed53798d1827988d16436c8e844d36243a Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 25 Sep 2022 11:40:56 +0100 Subject: [PATCH 03/21] Fixes symlinked namespaces --- src/Factories/TestCaseFactory.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index 0036be01..3e37d5e3 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -122,6 +122,8 @@ final class TestCaseFactory $rootPath = TestSuite::getInstance()->rootPath; $relativePath = str_replace($rootPath.DIRECTORY_SEPARATOR, '', $filename); + $relativePath = ltrim($relativePath, DIRECTORY_SEPARATOR); + $basename = basename($relativePath, '.php'); $dotPos = strpos($basename, '.'); @@ -208,7 +210,13 @@ final class TestCaseFactory eval($classCode); } catch (ParseError $caught) { - throw new RuntimeException(sprintf('Unable to create test case for test file at %s', $filename), 1, $caught); + + + throw new RuntimeException(sprintf( + "Unable to create test case for test file at %s. \n %s", + $filename, + $classCode + ), 1, $caught); } } From a73744c081c65414e37a50d68cceac2a157fd8e1 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 25 Sep 2022 11:41:13 +0100 Subject: [PATCH 04/21] Fixes symlinked autoloads --- bin/pest | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/pest b/bin/pest index ac1e98b6..dbf4be95 100755 --- a/bin/pest +++ b/bin/pest @@ -26,13 +26,20 @@ use Symfony\Component\Console\Output\OutputInterface; } } + // Used when Pest is symlinked. + $symlinkedPath = getcwd() . '/vendor/autoload.php'; + // Used when Pest is required using composer. $vendorPath = dirname(__DIR__, 4) . '/vendor/autoload.php'; // Used when Pest maintainers are running Pest tests. $localPath = dirname(__DIR__) . '/vendor/autoload.php'; - if (file_exists($vendorPath)) { + if (file_exists($symlinkedPath)) { + include_once $symlinkedPath; + $autoloadPath = $symlinkedPath; + + } else if (file_exists($vendorPath)) { include_once $vendorPath; $autoloadPath = $vendorPath; } else { From 8d4fa06ba3631c0a381285c3b144a21ab85c918d Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 25 Sep 2022 16:36:32 +0100 Subject: [PATCH 05/21] Removes unused code --- src/Factories/TestCaseFactory.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index 3e37d5e3..ee4daf84 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -210,8 +210,6 @@ final class TestCaseFactory eval($classCode); } catch (ParseError $caught) { - - throw new RuntimeException(sprintf( "Unable to create test case for test file at %s. \n %s", $filename, From 42c10f9a62059e476446dd0128f2593a9b16066a Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 25 Sep 2022 16:37:13 +0100 Subject: [PATCH 06/21] Rebuilds snapshots --- tests/.snapshots/help-command.txt | 1 + tests/.snapshots/success.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/.snapshots/help-command.txt b/tests/.snapshots/help-command.txt index 9fd71c08..2480c45e 100644 --- a/tests/.snapshots/help-command.txt +++ b/tests/.snapshots/help-command.txt @@ -60,6 +60,7 @@ --columns .................... Number of columns to use for progress output --columns max ............ Use maximum number of columns for progress output --stderr ................................. Write to STDERR instead of STDOUT + --no-output ............................................. Disable all output --display-incomplete .................. Display details for incomplete tests --display-skipped ........................ Display details for skipped tests --display-deprecations . Display details for deprecations triggered by tests diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index c23ef369..b5d2c5f9 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -818,4 +818,4 @@ PASS Tests\Visual\Version ✓ visual snapshot of help command output - Tests: 4 incomplete, 1 todo, 18 skipped, 562 passed (1460 assertions) + Tests: 4 incomplete, 1 todo, 18 skipped, 562 passed (1460 assertions) \ No newline at end of file From f214a78c75b46b916f8e449c0d9f7825dedb2319 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 25 Sep 2022 23:40:21 +0100 Subject: [PATCH 07/21] Removes symlinked autoload code --- bin/pest | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/bin/pest b/bin/pest index dbf4be95..ac1e98b6 100755 --- a/bin/pest +++ b/bin/pest @@ -26,20 +26,13 @@ use Symfony\Component\Console\Output\OutputInterface; } } - // Used when Pest is symlinked. - $symlinkedPath = getcwd() . '/vendor/autoload.php'; - // Used when Pest is required using composer. $vendorPath = dirname(__DIR__, 4) . '/vendor/autoload.php'; // Used when Pest maintainers are running Pest tests. $localPath = dirname(__DIR__) . '/vendor/autoload.php'; - if (file_exists($symlinkedPath)) { - include_once $symlinkedPath; - $autoloadPath = $symlinkedPath; - - } else if (file_exists($vendorPath)) { + if (file_exists($vendorPath)) { include_once $vendorPath; $autoloadPath = $vendorPath; } else { From 129325db8ef3ef1a1800f2ea800cbcf29b5433e7 Mon Sep 17 00:00:00 2001 From: Dan Ang Date: Tue, 27 Sep 2022 22:47:02 +0200 Subject: [PATCH 08/21] Add windows support to Backtrace --- src/Support/Backtrace.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Support/Backtrace.php b/src/Support/Backtrace.php index 56ac4fc9..33a44a2e 100644 --- a/src/Support/Backtrace.php +++ b/src/Support/Backtrace.php @@ -28,7 +28,9 @@ final class Backtrace foreach (debug_backtrace(self::BACKTRACE_OPTIONS) as $trace) { assert(array_key_exists(self::FILE, $trace)); - if (Str::endsWith($trace[self::FILE], 'overrides/Runner/TestSuiteLoader.php')) { + $traceFile = str_replace(DIRECTORY_SEPARATOR, '/', $trace[self::FILE]); + + if (Str::endsWith($traceFile, 'overrides/Runner/TestSuiteLoader.php')) { break; } From e105afce838f93fd221558f35a0b25769cf4094b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 26 Oct 2022 14:36:46 +0100 Subject: [PATCH 09/21] Updates sponsors --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ba14dc26..df01d6b1 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,6 @@ We would like to extend our thanks to the following sponsors for funding Pest de ### Platinum Sponsors - **[Advent](https://advent.dev)** -- **[Localazy](https://localazy.com)** - **[Spatie](https://spatie.be)** - **[Worksome](https://www.worksome.com/)** @@ -36,6 +35,7 @@ We would like to extend our thanks to the following sponsors for funding Pest de - [Auth0](https://auth0.com) - [Codecourse](https://codecourse.com/) - [Laracasts](https://laracasts.com/) +- [Localazy](https://localazy.com) - [Hyvor](https://hyvor.com/) - [Fathom Analytics](https://usefathom.com/) - [Meema](https://meema.io) From e37f3d3d453103a77fe54976186ed22434bdbce2 Mon Sep 17 00:00:00 2001 From: Alex Manase Date: Sun, 30 Oct 2022 13:05:09 +0200 Subject: [PATCH 10/21] ignore the keys returned by the datasets Generator for storing them into an array --- src/Repositories/DatasetsRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Repositories/DatasetsRepository.php b/src/Repositories/DatasetsRepository.php index f6874fc3..f4c7c11d 100644 --- a/src/Repositories/DatasetsRepository.php +++ b/src/Repositories/DatasetsRepository.php @@ -156,7 +156,7 @@ final class DatasetsRepository } if ($datasets[$index] instanceof Traversable) { - $datasets[$index] = iterator_to_array($datasets[$index]); + $datasets[$index] = iterator_to_array($datasets[$index], false); } // @phpstan-ignore-next-line From 3aab10774e36724909e1e3be00bbb87b1e459e89 Mon Sep 17 00:00:00 2001 From: Alex Manase Date: Sun, 30 Oct 2022 13:16:07 +0200 Subject: [PATCH 11/21] wip --- tests/.snapshots/success.txt | 7 ++++++- tests/Datasets/Numbers.php | 17 +++++++++++++++++ tests/Features/Datasets.php | 19 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index b5d2c5f9..14a80f82 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -102,6 +102,11 @@ ✓ more than two datasets with (2) / (4) / (5) ✓ more than two datasets with (2) / (4) / (6) ✓ more than two datasets did the job right + ✓ eager registered wrapped datasets with Generator functions with (1) + ✓ eager registered wrapped datasets with Generator functions with (2) + ✓ eager registered wrapped datasets with Generator functions with (3) + ✓ eager registered wrapped datasets with Generator functions with (4) + ✓ eager registered wrapped datasets with Generator functions did the job right ✓ it can resolve a dataset after the test case is available with (Closure Object (...)) #1 ✓ it can resolve a dataset after the test case is available with (Closure Object (...)) #2 ✓ it can resolve a dataset after the test case is available with shared yield sets with (Closure Object (...)) #1 @@ -818,4 +823,4 @@ PASS Tests\Visual\Version ✓ visual snapshot of help command output - Tests: 4 incomplete, 1 todo, 18 skipped, 562 passed (1460 assertions) \ No newline at end of file + Tests: 4 incomplete, 1 todo, 18 skipped, 566 passed (1465 assertions) \ No newline at end of file diff --git a/tests/Datasets/Numbers.php b/tests/Datasets/Numbers.php index 2b718699..fc2d81b7 100644 --- a/tests/Datasets/Numbers.php +++ b/tests/Datasets/Numbers.php @@ -13,3 +13,20 @@ dataset('numbers.closure.wrapped', function () { dataset('numbers.array', [[1], [2]]); dataset('numbers.array.wrapped', [1, 2]); + +dataset('numbers.generators.wrapped', function () { + yield from firstSetOfNumbers(); + yield from secondSetOfNumbers(); +}); + +function firstSetOfNumbers(): Generator +{ + yield 1; + yield 2; +} + +function secondSetOfNumbers(): Generator +{ + yield 3; + yield 4; +} diff --git a/tests/Features/Datasets.php b/tests/Features/Datasets.php index 183b2d3b..7d24a649 100644 --- a/tests/Features/Datasets.php +++ b/tests/Features/Datasets.php @@ -230,6 +230,25 @@ test('more than two datasets did the job right', function () use ($state) { expect($state->text)->toBe('121212121212131423241314232411122122111221221112212213142324135136145146235236245246'); }); +$wrapped_generator_state = new stdClass(); +$wrapped_generator_state->text = ''; +$wrapped_generator_function_datasets = [1, 2, 3, 4]; + +test( + 'eager registered wrapped datasets with Generator functions', + function (int $text) use ( + $wrapped_generator_state, + $wrapped_generator_function_datasets + ) { + $wrapped_generator_state->text .= $text; + expect(in_array($text, $wrapped_generator_function_datasets))->toBe(true); + } +)->with('numbers.generators.wrapped'); + +test('eager registered wrapped datasets with Generator functions did the job right', function () use ($wrapped_generator_state) { + expect($wrapped_generator_state->text)->toBe('1234'); +}); + it('can resolve a dataset after the test case is available', function ($result) { expect($result)->toBe('bar'); })->with([ From 649047f087b2fc10d382ef1c0ca5c48d173ac5e9 Mon Sep 17 00:00:00 2001 From: Alex Manase Date: Sun, 30 Oct 2022 13:17:56 +0200 Subject: [PATCH 12/21] formatting --- tests/Features/Datasets.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Features/Datasets.php b/tests/Features/Datasets.php index 7d24a649..073b1e68 100644 --- a/tests/Features/Datasets.php +++ b/tests/Features/Datasets.php @@ -230,8 +230,8 @@ test('more than two datasets did the job right', function () use ($state) { expect($state->text)->toBe('121212121212131423241314232411122122111221221112212213142324135136145146235236245246'); }); -$wrapped_generator_state = new stdClass(); -$wrapped_generator_state->text = ''; +$wrapped_generator_state = new stdClass(); +$wrapped_generator_state->text = ''; $wrapped_generator_function_datasets = [1, 2, 3, 4]; test( From 7683d791f4c8b40e07a619f30cb667fc2e102c28 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 9 Nov 2022 20:10:22 +0000 Subject: [PATCH 13/21] chore: bumps dependencies --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8fa5a4a8..31b8bdb7 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": "^8.1.0", "nunomaduro/collision": "^7.0.0", - "nunomaduro/termwind": "^1.14.0", + "nunomaduro/termwind": "^1.14.2", "pestphp/pest-plugin": "^2.0.0", "phpunit/phpunit": "10.0.x-dev" }, From f6cfd425c62c11ca3f6d9667fe9bfd4cb8bfbb2c Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 9 Nov 2022 20:15:51 +0000 Subject: [PATCH 14/21] tests: updates snapshots --- tests/.snapshots/help-command.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/.snapshots/help-command.txt b/tests/.snapshots/help-command.txt index 2480c45e..f6caacbc 100644 --- a/tests/.snapshots/help-command.txt +++ b/tests/.snapshots/help-command.txt @@ -60,6 +60,8 @@ --columns .................... Number of columns to use for progress output --columns max ............ Use maximum number of columns for progress output --stderr ................................. Write to STDERR instead of STDOUT + --no-progress .................... Disable output of test execution progress + --no-results ................................ Disable output of test results --no-output ............................................. Disable all output --display-incomplete .................. Display details for incomplete tests --display-skipped ........................ Display details for skipped tests @@ -69,8 +71,7 @@ --display-warnings ......... Display details for warnings triggered by tests --reverse-list .............................. Print defects in reverse order --teamcity ............... Report test execution progress in TeamCity format - --testdox ................. Report test execution progress in TestDox format - --no-interaction ........................ Disable TestDox progress animation + --testdox ............................ Report test results in TestDox format LOGGING OPTIONS: --log-junit ................ Log test execution in JUnit XML format to file From 348bd4b923f31cfddfc90a60f2a432e36bc0300d Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 9 Nov 2022 20:31:35 +0000 Subject: [PATCH 15/21] feat: improves feedback when test misses description --- src/Exceptions/TestDescriptionMissing.php | 24 +++++++++++++++++++++++ src/Factories/TestCaseFactory.php | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/Exceptions/TestDescriptionMissing.php diff --git a/src/Exceptions/TestDescriptionMissing.php b/src/Exceptions/TestDescriptionMissing.php new file mode 100644 index 00000000..67f75930 --- /dev/null +++ b/src/Exceptions/TestDescriptionMissing.php @@ -0,0 +1,24 @@ +description === null) { - throw ShouldNotHappen::fromMessage('The test description may not be empty.'); + throw new TestDescriptionMissing($method->filename); } if (array_key_exists($method->description, $this->methods)) { From 3e325e336455402f2596cb9c5f9e5786c8ba7f6c Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 9 Nov 2022 20:34:18 +0000 Subject: [PATCH 16/21] chore: improves type checking --- phpstan.neon | 1 + src/Expectations/HigherOrderExpectation.php | 1 - src/Factories/TestCaseFactory.php | 2 +- src/Mixins/Expectation.php | 1 - 4 files changed, 2 insertions(+), 3 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 0a1cba5c..d8b81f41 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -12,6 +12,7 @@ parameters: reportUnmatchedIgnoredErrors: true ignoreErrors: + - '#Cannot instantiate interface PHPUnit\\Util\\Exception#' - "#with a nullable type declaration#" - "#type mixed is not subtype of native#" - "#is not allowed to extend#" diff --git a/src/Expectations/HigherOrderExpectation.php b/src/Expectations/HigherOrderExpectation.php index 2008f582..c7685ace 100644 --- a/src/Expectations/HigherOrderExpectation.php +++ b/src/Expectations/HigherOrderExpectation.php @@ -161,7 +161,6 @@ final class HigherOrderExpectation */ private function getValue(): mixed { - // @phpstan-ignore-next-line return $this->shouldReset ? $this->original->value : $this->expectation->value; } diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index a2b32548..4591d9f1 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -8,9 +8,9 @@ use ParseError; use Pest\Concerns; use Pest\Contracts\HasPrintableTestCaseName; use Pest\Exceptions\DatasetMissing; -use Pest\Exceptions\TestDescriptionMissing; use Pest\Exceptions\ShouldNotHappen; use Pest\Exceptions\TestAlreadyExist; +use Pest\Exceptions\TestDescriptionMissing; use Pest\Factories\Concerns\HigherOrderable; use Pest\Plugins\Environment; use Pest\Support\Reflection; diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index 0714d9a3..886ffab2 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -524,7 +524,6 @@ final class Expectation { Assert::assertIsString($this->value, $message); - // @phpstan-ignore-next-line Assert::assertJson($this->value, $message); return $this; From 6a3cc48d6b11493e3488fc24874680877b32f6a2 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 9 Nov 2022 21:00:48 +0000 Subject: [PATCH 17/21] 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 14a80f82..af0bfcef 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -823,4 +823,4 @@ PASS Tests\Visual\Version ✓ visual snapshot of help command output - Tests: 4 incomplete, 1 todo, 18 skipped, 566 passed (1465 assertions) \ No newline at end of file + Tests: 4 incomplete, 1 todo, 18 skipped, 567 passed (1465 assertions) \ No newline at end of file From 9281060ab546b4e0286cdb135ad861763fd6a4ca Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 18 Nov 2022 02:24:54 +0000 Subject: [PATCH 18/21] fix: risky tests on oposite expectations --- src/Expectations/OppositeExpectation.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Expectations/OppositeExpectation.php b/src/Expectations/OppositeExpectation.php index beed91a8..923db2d3 100644 --- a/src/Expectations/OppositeExpectation.php +++ b/src/Expectations/OppositeExpectation.php @@ -6,6 +6,7 @@ namespace Pest\Expectations; use Pest\Expectation; use Pest\Support\Arr; +use PHPUnit\Framework\Assert; use PHPUnit\Framework\ExpectationFailedException; use SebastianBergmann\Exporter\Exporter; @@ -64,6 +65,8 @@ final class OppositeExpectation /* @phpstan-ignore-next-line */ $this->original->{$name}(...$arguments); } catch (ExpectationFailedException) { + Assert::assertTrue(true); + return $this->original; } @@ -80,6 +83,8 @@ final class OppositeExpectation try { $this->original->{$name}; // @phpstan-ignore-line } catch (ExpectationFailedException) { // @phpstan-ignore-line + Assert::assertTrue(true); + return $this->original; } From f9397924fa947b289ec079c935240aad4b0c4f0f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 18 Nov 2022 02:28:33 +0000 Subject: [PATCH 19/21] revert(fix): on risky expecatations --- src/Expectations/OppositeExpectation.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Expectations/OppositeExpectation.php b/src/Expectations/OppositeExpectation.php index 923db2d3..beed91a8 100644 --- a/src/Expectations/OppositeExpectation.php +++ b/src/Expectations/OppositeExpectation.php @@ -6,7 +6,6 @@ namespace Pest\Expectations; use Pest\Expectation; use Pest\Support\Arr; -use PHPUnit\Framework\Assert; use PHPUnit\Framework\ExpectationFailedException; use SebastianBergmann\Exporter\Exporter; @@ -65,8 +64,6 @@ final class OppositeExpectation /* @phpstan-ignore-next-line */ $this->original->{$name}(...$arguments); } catch (ExpectationFailedException) { - Assert::assertTrue(true); - return $this->original; } @@ -83,8 +80,6 @@ final class OppositeExpectation try { $this->original->{$name}; // @phpstan-ignore-line } catch (ExpectationFailedException) { // @phpstan-ignore-line - Assert::assertTrue(true); - return $this->original; } From 17cc194ad145214fc7714e6886f570c41001b348 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 21 Nov 2022 12:09:32 +0000 Subject: [PATCH 20/21] Adds sponsor --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index df01d6b1..4febffd5 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ We would like to extend our thanks to the following sponsors for funding Pest de ### Platinum Sponsors - **[Advent](https://advent.dev)** +- **[Forge](https://forge.laravel.com)** - **[Spatie](https://spatie.be)** - **[Worksome](https://www.worksome.com/)** From d77715b0fe82699d30d23a2dde48d6b0be813a38 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 21 Nov 2022 20:47:47 +0000 Subject: [PATCH 21/21] fix: `--filter` option --- .../Runner/Filter/NameFilterIterator.php | 2 +- src/Concerns/Testable.php | 29 ++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/overrides/Runner/Filter/NameFilterIterator.php b/overrides/Runner/Filter/NameFilterIterator.php index be5151aa..4ff7b6f7 100644 --- a/overrides/Runner/Filter/NameFilterIterator.php +++ b/overrides/Runner/Filter/NameFilterIterator.php @@ -156,7 +156,7 @@ final class NameFilterIterator extends RecursiveFilterIterator if ($test instanceof HasPrintableTestCaseName) { return [ $test::getPrintableTestCaseName(), - $test::getPrintableTestCaseMethodName(), + $test->getPrintableTestCaseMethodName(), ]; } diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index e63c9a8e..36d47e38 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -22,7 +22,12 @@ trait Testable /** * Test method description. */ - private static string $__description; + private string $__description; + + /** + * Test "latest" method description. + */ + private static string $__latestDescription; /** * The Test Case "test" closure. @@ -69,7 +74,7 @@ trait Testable if ($test->hasMethod($name)) { $method = $test->getMethod($name); - self::$__description = $method->description; + $this->__description = self::$__latestDescription = $method->description; $this->__test = $method->getClosure($this); } } @@ -169,7 +174,7 @@ trait Testable */ protected function setUp(): void { - self::$__description = $this->name(); + $this->__description = self::$__latestDescription = $this->name(); TestSuite::getInstance()->test = $this; @@ -221,7 +226,7 @@ trait Testable { $method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name()); - self::$__description = $this->dataName() ? $method->description.' with '.$this->dataName() : $method->description; + $this->__description = self::$__latestDescription = $this->dataName() ? $method->description.' with '.$this->dataName() : $method->description; if (count($arguments) !== 1) { return $arguments; @@ -258,7 +263,7 @@ trait Testable } /** - * Gets the Test Case name that should be used by printers. + * The printable test case name. */ public static function getPrintableTestCaseName(): string { @@ -266,10 +271,18 @@ trait Testable } /** - * Gets the Test Case name that should be used by printers. + * The printable test case method name. */ - public static function getPrintableTestCaseMethodName(): string + public function getPrintableTestCaseMethodName(): string { - return self::$__description; + return $this->__description; + } + + /** + * The latest printable test case method name. + */ + public static function getLatestPrintableTestCaseMethodName(): string + { + return self::$__latestDescription; } }