feat: throw user-friendly exception for missing argument data

This commit is contained in:
jordanbrauer
2021-06-16 01:01:34 -05:00
parent 9d66893d5a
commit 6a7ee90ff5

View File

@ -5,11 +5,13 @@ declare(strict_types=1);
namespace Pest\Repositories;
use Closure;
use Pest\Exceptions\DatasetMissing;
use Pest\Exceptions\ShouldNotHappen;
use Pest\Exceptions\TestAlreadyExist;
use Pest\Exceptions\TestCaseAlreadyInUse;
use Pest\Exceptions\TestCaseClassOrTraitNotFound;
use Pest\Factories\TestCaseFactory;
use Pest\Support\Reflection;
use Pest\Support\Str;
use Pest\TestSuite;
use PHPUnit\Framework\TestCase;
@ -140,6 +142,14 @@ final class TestRepository
throw new TestAlreadyExist($test->filename, $test->description);
}
if ($test->dependent === false && count($test->datasets) === 0) {
$arguments = Reflection::getFunctionArguments($test->test);
if (count($arguments) > 0) {
throw new DatasetMissing($test->filename, $test->description, $arguments);
}
}
$this->state[sprintf('%s%s%s', $test->filename, self::SEPARATOR, $test->description)] = $test;
}
}