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": {
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "0.2.x-dev"
|
||||||
|
},
|
||||||
"laravel": {
|
"laravel": {
|
||||||
"providers": [
|
"providers": [
|
||||||
"Pest\\Laravel\\PestServiceProvider"
|
"Pest\\Laravel\\PestServiceProvider"
|
||||||
|
|||||||
@ -20,3 +20,4 @@ parameters:
|
|||||||
- "# with null as default value#"
|
- "# with null as default value#"
|
||||||
- "#Using \\$this in static method#"
|
- "#Using \\$this in static method#"
|
||||||
- "#has parameter \\$closure with default value.#"
|
- "#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);
|
$this->arguments = AddsDefaults::to($this->arguments);
|
||||||
|
|
||||||
|
LoadStructure::in($this->testSuite->rootPath);
|
||||||
|
|
||||||
$testRunner = new TestRunner($this->arguments['loader']);
|
$testRunner = new TestRunner($this->arguments['loader']);
|
||||||
$testSuite = $this->arguments['test'];
|
$testSuite = $this->arguments['test'];
|
||||||
|
|
||||||
@ -109,7 +111,6 @@ final class Command extends BaseCommand
|
|||||||
$this->arguments['test'] = $testSuite;
|
$this->arguments['test'] = $testSuite;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadStructure::in($this->testSuite->rootPath);
|
|
||||||
AddsTests::to($testSuite, $this->testSuite);
|
AddsTests::to($testSuite, $this->testSuite);
|
||||||
|
|
||||||
return $testRunner;
|
return $testRunner;
|
||||||
|
|||||||
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Pest\Repositories;
|
namespace Pest\Repositories;
|
||||||
|
|
||||||
|
use Pest\Exceptions\ShouldNotHappen;
|
||||||
use Pest\Exceptions\TestAlreadyExist;
|
use Pest\Exceptions\TestAlreadyExist;
|
||||||
use Pest\Exceptions\TestCaseAlreadyInUse;
|
use Pest\Exceptions\TestCaseAlreadyInUse;
|
||||||
use Pest\Exceptions\TestCaseClassOrTraitNotFound;
|
use Pest\Exceptions\TestCaseClassOrTraitNotFound;
|
||||||
@ -54,7 +55,6 @@ final class TestRepository
|
|||||||
if ($testCase->class !== \PHPUnit\Framework\TestCase::class) {
|
if ($testCase->class !== \PHPUnit\Framework\TestCase::class) {
|
||||||
throw new TestCaseAlreadyInUse($testCase->class, $class, $filename);
|
throw new TestCaseAlreadyInUse($testCase->class, $class, $filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$testCase->class = $class;
|
$testCase->class = $class;
|
||||||
} elseif (trait_exists($class)) {
|
} elseif (trait_exists($class)) {
|
||||||
$testCase->traits[] = $class;
|
$testCase->traits[] = $class;
|
||||||
@ -62,9 +62,9 @@ final class TestRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
$testCase
|
$testCase
|
||||||
->factoryProxies
|
->factoryProxies
|
||||||
// Consider set the real line here.
|
// Consider set the real line here.
|
||||||
->add($filename, 0, 'addGroups', [$groups]);
|
->add($filename, 0, 'addGroups', [$groups]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -113,6 +113,10 @@ final class TestRepository
|
|||||||
*/
|
*/
|
||||||
public function set(TestCaseFactory $test): void
|
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)) {
|
if (array_key_exists(sprintf('%s@%s', $test->filename, $test->description), $this->state)) {
|
||||||
throw new TestAlreadyExist($test->filename, $test->description);
|
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