trait InteractsWithPest

Traits

Properties

static protected string|bool|null $cacheApplicationBootstrapFile

Cached application bootstrap file path.

from  InteractsWithTestCase
static protected null|array<class-string, class-string> $cachedTestCaseUses

Cached traits used by test case.

from  InteractsWithTestCase
static protected array<int, array{key: class-string, instance: object}> $testCaseTestingFeatures

Programmatically added class-level testing features.

from  InteractsWithTestCase
static protected array<int, array{key: class-string, instance: object}> $testCaseMethodTestingFeatures

Programmatically added method-level testing features.

from  InteractsWithTestCase
protected null|Closure): void $testCaseSetUpCallback

The cached test case setUp resolver.

from  InteractsWithPHPUnit
protected null|Closure): void $testCaseTearDownCallback

The cached test case tearDown resolver.

from  InteractsWithPHPUnit
static protected array<string, array<int, array{key: class-string, instance: object}>> $cachedTestCaseClassAttributes

Cached class attributes by class name.

from  InteractsWithPHPUnit
static protected array<string, array<int, array{key: class-string, instance: object}>> $cachedTestCaseMethodAttributes

Cached method attributes by "class:method" key.

from  InteractsWithPHPUnit
null|Application $app from  InteractsWithPHPUnit

Methods

static bool
usesTestingConcern(string|null $trait = null)

Check if the test case uses a specific trait.

static bool
usesRefreshDatabaseTestingConcern()

Determine if the test case uses refresh-database testing concerns.

static array
cachedUsesForTestCase()

Cache and return traits used by test case.

static void
usesTestingFeature(object $attribute, int $flag = Attribute::TARGET_CLASS)

Programmatically add a testing feature attribute.

static Collection
resolvePhpUnitAttributesForMethod(string $className, string|null $methodName = null)

Resolve PHPUnit method attributes for specific method.

void
setUpTheTestEnvironmentUsingTestCase()

Execute BeforeEach lifecycle attributes.

void
tearDownTheTestEnvironmentUsingTestCase()

Execute AfterEach lifecycle attributes.

static void
setUpBeforeClassUsingTestCase()

Execute BeforeAll lifecycle attributes.

static void
tearDownAfterClassUsingTestCase()

Execute AfterAll lifecycle attributes and clear caches.

bool
isRunningTestCase()

Determine if the object is running as a PHPUnit test case.

string|null
resolvePhpUnitTestClassName()

Resolve the PHPUnit test class name.

string|null
resolvePhpUnitTestMethodName()

Resolve the PHPUnit test method name.

resolvePhpUnitAttributes()

Resolve and cache PHPUnit attributes for current test.

void
setUpTheEnvironmentUsing(Closure $setUp)

Define the setUp environment using callback.

void
tearDownTheEnvironmentUsing(Closure $tearDown)

Define the tearDown environment using callback.

static void
setUpBeforeClassUsingPHPUnit()

Cache uses for test case before class runs.

static void
tearDownAfterClassUsingPHPUnit()

Clear PHPUnit caches after class teardown.

bool
isRunningTestCaseUsingPest()

Determine if the trait is used within testing using Pest.

static bool
isRunningViaPestPrinter(object|string $object)

Determine if the object implements Pest test runner.

Details

static bool usesTestingConcern(string|null $trait = null)

Check if the test case uses a specific trait.

Parameters

string|null $trait

Return Value

bool

static bool usesRefreshDatabaseTestingConcern()

Determine if the test case uses refresh-database testing concerns.

Return Value

bool

static array cachedUsesForTestCase()

Cache and return traits used by test case.

Return Value

array

static void usesTestingFeature(object $attribute, int $flag = Attribute::TARGET_CLASS)

Programmatically add a testing feature attribute.

Parameters

object $attribute
int $flag

Return Value

void

abstract static protected Collection resolvePhpUnitAttributesForMethod(string $className, string|null $methodName = null)

Resolve PHPUnit method attributes for specific method.

Parameters

string $className
string|null $methodName

Return Value

Collection

protected void setUpTheTestEnvironmentUsingTestCase()

Execute BeforeEach lifecycle attributes.

Return Value

void

protected void tearDownTheTestEnvironmentUsingTestCase()

Execute AfterEach lifecycle attributes.

Return Value

void

static void setUpBeforeClassUsingTestCase()

Execute BeforeAll lifecycle attributes.

Return Value

void

static void tearDownAfterClassUsingTestCase()

Execute AfterAll lifecycle attributes and clear caches.

Return Value

void

bool isRunningTestCase()

Determine if the object is running as a PHPUnit test case.

Return Value

bool

string|null resolvePhpUnitTestClassName()

Resolve the PHPUnit test class name.

Return Value

string|null

string|null resolvePhpUnitTestMethodName()

Resolve the PHPUnit test method name.

Return Value

string|null

protected Collection resolvePhpUnitAttributes()

Resolve and cache PHPUnit attributes for current test.

Return Value

Collection

in InteractsWithPHPUnit at line 142
void setUpTheEnvironmentUsing(Closure $setUp)

Define the setUp environment using callback.

Parameters

Closure $setUp

Return Value

void

in InteractsWithPHPUnit at line 152
void tearDownTheEnvironmentUsing(Closure $tearDown)

Define the tearDown environment using callback.

Parameters

Closure $tearDown

Return Value

void

in InteractsWithPHPUnit at line 160
static void setUpBeforeClassUsingPHPUnit()

Cache uses for test case before class runs.

Return Value

void

in InteractsWithPHPUnit at line 168
static void tearDownAfterClassUsingPHPUnit()

Clear PHPUnit caches after class teardown.

Return Value

void

at line 17
bool isRunningTestCaseUsingPest()

Determine if the trait is used within testing using Pest.

Return Value

bool

at line 25
static protected bool isRunningViaPestPrinter(object|string $object)

Determine if the object implements Pest test runner.

Parameters

object|string $object

Return Value

bool