Wrap functions in function_exists

This commit is contained in:
Oliver Nybroe
2021-05-19 08:23:45 +02:00
parent 9027411004
commit dd78cc9a50

View File

@ -12,6 +12,7 @@ use Pest\Support\HigherOrderTapProxy;
use Pest\TestSuite;
use PHPUnit\Framework\TestCase;
if (!function_exists('beforeAll')) {
/**
* Runs the given closure before all tests in the current file.
*/
@ -19,7 +20,9 @@ function beforeAll(Closure $closure): void
{
TestSuite::getInstance()->beforeAll->set($closure);
}
}
if (!function_exists('beforeEach')) {
/**
* Runs the given closure before each test in the current file.
*
@ -31,7 +34,9 @@ function beforeEach(Closure $closure = null): BeforeEachCall
return new BeforeEachCall(TestSuite::getInstance(), $filename, $closure);
}
}
if (!function_exists('dataset')) {
/**
* Registers the given dataset.
*
@ -41,7 +46,9 @@ function dataset(string $name, $dataset): void
{
Datasets::set($name, $dataset);
}
}
if (!function_exists('uses')) {
/**
* The uses function binds the given
* arguments to test closures.
@ -52,7 +59,9 @@ function uses(string ...$classAndTraits): UsesCall
return new UsesCall($filename, $classAndTraits);
}
}
if (!function_exists('test')) {
/**
* Adds the given closure as a test. The first argument
* is the test description; the second argument is
@ -70,7 +79,9 @@ function test(string $description = null, Closure $closure = null)
return new TestCall(TestSuite::getInstance(), $filename, $description, $closure);
}
}
if (!function_exists('it')) {
/**
* Adds the given closure as a test. The first argument
* is the test description; the second argument is
@ -84,7 +95,9 @@ function it(string $description, Closure $closure = null): TestCall
return test($description, $closure);
}
}
if (!function_exists('afterEach')) {
/**
* Runs the given closure after each test in the current file.
*
@ -96,7 +109,9 @@ function afterEach(Closure $closure = null): AfterEachCall
return new AfterEachCall(TestSuite::getInstance(), $filename, $closure);
}
}
if (!function_exists('afterAll')) {
/**
* Runs the given closure after all tests in the current file.
*/
@ -104,3 +119,4 @@ function afterAll(Closure $closure): void
{
TestSuite::getInstance()->afterAll->set($closure);
}
}