mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Handles tests where a static closure is provided
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
use Pest\Exceptions\DatasetMissing;
|
||||
use Pest\Exceptions\TestAlreadyExist;
|
||||
use Pest\Exceptions\TestClosureMustNotBeStatic;
|
||||
use Pest\Factories\TestCaseMethodFactory;
|
||||
use Pest\TestSuite;
|
||||
|
||||
@ -16,6 +17,22 @@ it('does not allow to add the same test description twice', function () {
|
||||
sprintf('A test with the description `%s` already exists in the filename `%s`.', 'bar', 'foo'),
|
||||
);
|
||||
|
||||
it('does not allow static closures', function () {
|
||||
$testSuite = new TestSuite(getcwd(), 'tests');
|
||||
$method = new TestCaseMethodFactory('foo', 'bar', static function () {
|
||||
|
||||
});
|
||||
|
||||
$testSuite->tests->set($method);
|
||||
})->throws(
|
||||
TestClosureMustNotBeStatic::class,
|
||||
sprintf(
|
||||
'The test `%s` closure must not be static in %s.',
|
||||
'bar',
|
||||
'foo',
|
||||
)
|
||||
);
|
||||
|
||||
it('alerts users about tests with arguments but no input', function () {
|
||||
$testSuite = new TestSuite(getcwd(), 'tests');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user