mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat(pending-higher-order-tests): adds code and tests
This commit is contained in:
@ -78,6 +78,9 @@
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.2.x-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Pest\\Laravel\\PestServiceProvider"
|
||||
|
||||
@ -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.#"
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
@ -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);
|
||||
}
|
||||
|
||||
29
tests/Features/PendingHigherOrderTests.php
Normal file
29
tests/Features/PendingHigherOrderTests.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
uses(Gettable::class);
|
||||
|
||||
/**
|
||||
* @return TestCase|Gettable
|
||||
*/
|
||||
function get(string $route)
|
||||
{
|
||||
return test()->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);
|
||||
Reference in New Issue
Block a user