feat: adds support for global helpers

This commit is contained in:
Nuno Maduro
2020-05-13 22:51:50 +02:00
parent 2d85842777
commit 6fc55becc8
6 changed files with 151 additions and 3 deletions

View File

@ -8,6 +8,7 @@ use Pest\PendingObjects\BeforeEachCall;
use Pest\PendingObjects\TestCall;
use Pest\PendingObjects\UsesCall;
use Pest\Support\Backtrace;
use Pest\Support\HigherOrderTapProxy;
use Pest\TestSuite;
use PHPUnit\Framework\TestCase;
@ -59,8 +60,12 @@ function uses(string ...$classAndTraits): UsesCall
*
* @return TestCall|TestCase|mixed
*/
function test(string $description, Closure $closure = null): TestCall
function test(string $description = null, Closure $closure = null)
{
if ($description === null && TestSuite::getInstance()->test) {
return new HigherOrderTapProxy(TestSuite::getInstance()->test);
}
$filename = Backtrace::file();
return new TestCall(TestSuite::getInstance(), $filename, $description, $closure);