diff --git a/composer.json b/composer.json index 2f2ffd62..f832fda5 100644 --- a/composer.json +++ b/composer.json @@ -78,6 +78,9 @@ ] }, "extra": { + "branch-alias": { + "dev-master": "0.2.x-dev" + }, "laravel": { "providers": [ "Pest\\Laravel\\PestServiceProvider" diff --git a/phpstan.neon b/phpstan.neon index 759697e0..866178f7 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -20,3 +20,4 @@ parameters: - "# with null as default value#" - "#Using \\$this in static method#" - "#has parameter \\$closure with default value.#" + - "#has parameter \\$description with default value.#" diff --git a/src/Console/Command.php b/src/Console/Command.php index b4dc3c75..290dbe04 100644 --- a/src/Console/Command.php +++ b/src/Console/Command.php @@ -88,6 +88,8 @@ final class Command extends BaseCommand */ $this->arguments = AddsDefaults::to($this->arguments); + LoadStructure::in($this->testSuite->rootPath); + $testRunner = new TestRunner($this->arguments['loader']); $testSuite = $this->arguments['test']; @@ -109,7 +111,6 @@ final class Command extends BaseCommand $this->arguments['test'] = $testSuite; } - LoadStructure::in($this->testSuite->rootPath); AddsTests::to($testSuite, $this->testSuite); return $testRunner; diff --git a/src/Repositories/TestRepository.php b/src/Repositories/TestRepository.php index 2aefe320..3f4cb99e 100644 --- a/src/Repositories/TestRepository.php +++ b/src/Repositories/TestRepository.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Pest\Repositories; +use Pest\Exceptions\ShouldNotHappen; use Pest\Exceptions\TestAlreadyExist; use Pest\Exceptions\TestCaseAlreadyInUse; use Pest\Exceptions\TestCaseClassOrTraitNotFound; @@ -54,7 +55,6 @@ final class TestRepository if ($testCase->class !== \PHPUnit\Framework\TestCase::class) { throw new TestCaseAlreadyInUse($testCase->class, $class, $filename); } - $testCase->class = $class; } elseif (trait_exists($class)) { $testCase->traits[] = $class; @@ -62,9 +62,9 @@ final class TestRepository } $testCase - ->factoryProxies - // Consider set the real line here. - ->add($filename, 0, 'addGroups', [$groups]); + ->factoryProxies + // Consider set the real line here. + ->add($filename, 0, 'addGroups', [$groups]); } }; @@ -113,6 +113,10 @@ final class TestRepository */ public function set(TestCaseFactory $test): void { + if ($test->description === null) { + throw ShouldNotHappen::fromMessage('Trying to create a test without description.'); + } + if (array_key_exists(sprintf('%s@%s', $test->filename, $test->description), $this->state)) { throw new TestAlreadyExist($test->filename, $test->description); } diff --git a/tests/Features/HigherOrderMessages.php b/tests/Features/HigherOrderTests.php similarity index 100% rename from tests/Features/HigherOrderMessages.php rename to tests/Features/HigherOrderTests.php diff --git a/tests/Features/PendingHigherOrderTests.php b/tests/Features/PendingHigherOrderTests.php new file mode 100644 index 00000000..de178c51 --- /dev/null +++ b/tests/Features/PendingHigherOrderTests.php @@ -0,0 +1,29 @@ +get($route); +} + +trait Gettable +{ + /** + * @return TestCase|Gettable + */ + public function get(string $route) + { + assertNotEmpty($route); + + return $this; + } +} + +get('foo')->get('bar')->assertTrue(true); +get('foo')->assertTrue(true);