feat(pending-higher-order-tests): adds code and tests

This commit is contained in:
Nuno Maduro
2020-06-04 01:33:33 +02:00
parent b0680b7e2c
commit c81dce0f6d
6 changed files with 43 additions and 5 deletions

View File

@ -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;

View File

@ -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);
}