From c04d6d946da3c8a5ac5b85c2c14bdcc22e5e2e1a Mon Sep 17 00:00:00 2001 From: Titouan Mathis Date: Wed, 2 Jun 2021 18:35:55 +0200 Subject: [PATCH 1/5] Fix a bug where plugins could not be used in a path containing an `@` Fix #307 --- src/Repositories/TestRepository.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Repositories/TestRepository.php b/src/Repositories/TestRepository.php index ab49291e..b2eb4893 100644 --- a/src/Repositories/TestRepository.php +++ b/src/Repositories/TestRepository.php @@ -19,6 +19,11 @@ use PHPUnit\Framework\TestCase; */ final class TestRepository { + /** + * @var string + */ + private const SEPARATOR = '>>>'; + /** * @var array */ @@ -50,7 +55,7 @@ final class TestRepository [$classOrTraits, $groups, $hooks] = $uses; $setClassName = function (TestCaseFactory $testCase, string $key) use ($path, $classOrTraits, $groups, $startsWith, $hooks): void { - [$filename] = explode('@', $key); + [$filename] = explode(self::SEPARATOR, $key); if ((!is_dir($path) && $filename === $path) || (is_dir($path) && $startsWith($filename, $path))) { foreach ($classOrTraits as $class) { /** @var string $class */ @@ -131,10 +136,10 @@ final class TestRepository throw ShouldNotHappen::fromMessage('Trying to create a test without description.'); } - if (array_key_exists(sprintf('%s@%s', $test->filename, $test->description), $this->state)) { + if (array_key_exists(sprintf('%s%s%s', $test->filename, self::SEPARATOR, $test->description), $this->state)) { throw new TestAlreadyExist($test->filename, $test->description); } - $this->state[sprintf('%s@%s', $test->filename, $test->description)] = $test; + $this->state[sprintf('%s%s%s', $test->filename, self::SEPARATOR, $test->description)] = $test; } } From 574cd11a40f98194c2880860db9ba80edcacdc14 Mon Sep 17 00:00:00 2001 From: Titouan Mathis Date: Fri, 4 Jun 2021 02:08:12 +0200 Subject: [PATCH 2/5] Add tests --- .../FolderWithAn@/ExampleTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/PHPUnit/CustomAffixes/FolderWithAn@/ExampleTest.php diff --git a/tests/PHPUnit/CustomAffixes/FolderWithAn@/ExampleTest.php b/tests/PHPUnit/CustomAffixes/FolderWithAn@/ExampleTest.php new file mode 100644 index 00000000..351e0612 --- /dev/null +++ b/tests/PHPUnit/CustomAffixes/FolderWithAn@/ExampleTest.php @@ -0,0 +1,19 @@ +assertTrue(true); + } +} + +uses(MyCustomClassTest::class); + +test('custom traits can be used', function () { + $this->assertTrueIsTrue(); +}); + +test('trait applied in this file')->assertTrueIsTrue(); From 4c911cd0eb4d6d1a69f94730e3b885841504f067 Mon Sep 17 00:00:00 2001 From: Owen Voke Date: Mon, 7 Jun 2021 08:59:27 +0100 Subject: [PATCH 3/5] docs: update changelog --- CHANGELOG.md | 3 +++ src/Pest.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aba3fe63..449b6694 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Added for PHPUnit 9.5.5 ([#310](https://github.com/pestphp/pest/pull/310)) +### Changed +- Lock minimum Pest plugin versions ([#306](https://github.com/pestphp/pest/pull/306)) + ## [v1.3.0 (2021-05-23)](https://github.com/pestphp/pest/compare/v1.2.1...v1.3.0) ### Added - Named datasets no longer show the arguments ([#302](https://github.com/pestphp/pest/pull/302)) diff --git a/src/Pest.php b/src/Pest.php index d0ae86c4..4dda7ccd 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '1.3.0'; + return '1.3.1'; } function testDirectory(string $file = ''): string From 95b4192c0d756562aebd012ed6af235b11832de9 Mon Sep 17 00:00:00 2001 From: Titouan Mathis Date: Mon, 7 Jun 2021 10:40:11 +0200 Subject: [PATCH 4/5] Fix visual success test --- tests/.snapshots/success.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index d89b30e8..d392dedc 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -122,6 +122,10 @@ PASS Tests\PHPUnit\CustomAffixes\AdditionalFileExtensionspec ✓ it runs file names like `AdditionalFileExtension.spec.php` + PASS Tests\PHPUnit\CustomAffixes\FolderWithAn\ExampleTest + ✓ custom traits can be used + ✓ trait applied in this file + PASS Tests\PHPUnit\CustomAffixes\ManyExtensionsclasstest ✓ it runs file names like `ManyExtensions.class.test.php` @@ -220,5 +224,5 @@ ✓ it is a test ✓ it uses correct parent class - Tests: 7 skipped, 120 passed + Tests: 7 skipped, 122 passed \ No newline at end of file From 17d407a26a9466779c58372fdb2502a0c5a0dc26 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 7 Jun 2021 15:27:33 +0100 Subject: [PATCH 5/5] Updates changelog --- CHANGELOG.md | 4 ++++ src/Pest.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 449b6694..a901ee7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [v.1.3.2 (2021-06-07)](https://github.com/pestphp/pest/compare/v1.3.1...v1.3.2) +### Fixed +- Test cases with the @ symbol in the directory fail ([#308](https://github.com/pestphp/pest/pull/308)) + ## [v1.3.1 (2021-06-06)](https://github.com/pestphp/pest/compare/v1.3.0...v1.3.1) ### Added - Added for PHPUnit 9.5.5 ([#310](https://github.com/pestphp/pest/pull/310)) diff --git a/src/Pest.php b/src/Pest.php index 4dda7ccd..505d1ac6 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '1.3.1'; + return '1.3.2'; } function testDirectory(string $file = ''): string