Adds support for receiving datasets in higher order tests

This commit is contained in:
luke
2021-07-21 07:40:19 +01:00
parent 47ceb2419b
commit 371620d161
3 changed files with 26 additions and 2 deletions

View File

@ -60,6 +60,21 @@ final class Reflection
return Closure::fromCallable($callable)->bindTo(TestSuite::getInstance()->test)(...$args);
}
/**
* Bind a callable to the TestCase and return the result,
* passing in the current dataset values as arguments.
*
* @return mixed
*/
public static function bindCallableWithData(callable $callable)
{
$test = TestSuite::getInstance()->test;
return $test === null
? static::bindCallable($callable)
: Closure::fromCallable($callable)->bindTo($test)(...$test->getProvidedData());
}
/**
* Infers the file name from the given closure.
*/