Compare commits

...

6 Commits

Author SHA1 Message Date
17d407a26a Updates changelog 2021-06-07 15:27:33 +01:00
cdc3bd3f45 Merge pull request #308 from titouanmathis/fix/test-key-separator
Fix/test key separator
2021-06-07 15:22:05 +01:00
95b4192c0d Fix visual success test 2021-06-07 10:40:11 +02:00
4c911cd0eb docs: update changelog 2021-06-07 08:59:27 +01:00
574cd11a40 Add tests 2021-06-04 02:08:12 +02:00
c04d6d946d Fix a bug where plugins could not be used in a path containing an @
Fix #307
2021-06-03 14:15:20 +02:00
5 changed files with 40 additions and 5 deletions

View File

@ -4,10 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). 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) ## [v1.3.1 (2021-06-06)](https://github.com/pestphp/pest/compare/v1.3.0...v1.3.1)
### Added ### Added
- Added for PHPUnit 9.5.5 ([#310](https://github.com/pestphp/pest/pull/310)) - 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) ## [v1.3.0 (2021-05-23)](https://github.com/pestphp/pest/compare/v1.2.1...v1.3.0)
### Added ### Added
- Named datasets no longer show the arguments ([#302](https://github.com/pestphp/pest/pull/302)) - Named datasets no longer show the arguments ([#302](https://github.com/pestphp/pest/pull/302))

View File

@ -6,7 +6,7 @@ namespace Pest;
function version(): string function version(): string
{ {
return '1.3.0'; return '1.3.2';
} }
function testDirectory(string $file = ''): string function testDirectory(string $file = ''): string

View File

@ -19,6 +19,11 @@ use PHPUnit\Framework\TestCase;
*/ */
final class TestRepository final class TestRepository
{ {
/**
* @var string
*/
private const SEPARATOR = '>>>';
/** /**
* @var array<string, TestCaseFactory> * @var array<string, TestCaseFactory>
*/ */
@ -50,7 +55,7 @@ final class TestRepository
[$classOrTraits, $groups, $hooks] = $uses; [$classOrTraits, $groups, $hooks] = $uses;
$setClassName = function (TestCaseFactory $testCase, string $key) use ($path, $classOrTraits, $groups, $startsWith, $hooks): void { $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))) { if ((!is_dir($path) && $filename === $path) || (is_dir($path) && $startsWith($filename, $path))) {
foreach ($classOrTraits as $class) { /** @var string $class */ foreach ($classOrTraits as $class) { /** @var string $class */
@ -131,10 +136,10 @@ final class TestRepository
throw ShouldNotHappen::fromMessage('Trying to create a test without description.'); 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); 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;
} }
} }

View File

@ -122,6 +122,10 @@
PASS Tests\PHPUnit\CustomAffixes\AdditionalFileExtensionspec PASS Tests\PHPUnit\CustomAffixes\AdditionalFileExtensionspec
✓ it runs file names like `AdditionalFileExtension.spec.php` ✓ 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 PASS Tests\PHPUnit\CustomAffixes\ManyExtensionsclasstest
✓ it runs file names like `ManyExtensions.class.test.php` ✓ it runs file names like `ManyExtensions.class.test.php`
@ -220,5 +224,5 @@
✓ it is a test ✓ it is a test
✓ it uses correct parent class ✓ it uses correct parent class
Tests: 7 skipped, 120 passed Tests: 7 skipped, 122 passed

View File

@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
class MyCustomClassTest extends PHPUnit\Framework\TestCase
{
public function assertTrueIsTrue()
{
$this->assertTrue(true);
}
}
uses(MyCustomClassTest::class);
test('custom traits can be used', function () {
$this->assertTrueIsTrue();
});
test('trait applied in this file')->assertTrueIsTrue();