feat: clarfies that high order testing does not support bound datasets

This commit is contained in:
Nuno Maduro
2024-01-25 14:08:56 +00:00
parent 1d2fe2de2d
commit 2562d36518
3 changed files with 33 additions and 4 deletions

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Pest\Support;
use Closure;
use InvalidArgumentException;
use Pest\Exceptions\ShouldNotHappen;
use Pest\TestSuite;
use ReflectionClass;
@ -66,9 +67,17 @@ final class Reflection
{
$test = TestSuite::getInstance()->test;
return $test instanceof \PHPUnit\Framework\TestCase
? Closure::fromCallable($callable)->bindTo($test)(...$test->providedData())
: self::bindCallable($callable);
if (! $test instanceof \PHPUnit\Framework\TestCase) {
return self::bindCallable($callable);
}
foreach ($test->providedData() as $value) {
if ($value instanceof Closure) {
throw new InvalidArgumentException('Bound datasets are not supported while doing high order testing.');
}
}
return Closure::fromCallable($callable)->bindTo($test)(...$test->providedData());
}
/**