trait HandlesRoutes

Traits

Properties

static protected array<class-string, array<class-string, class-string>> $cachedTestCaseUses

Cached traits used by each test case class.

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
protected bool $syncTestbenchRoutesHasRun

Whether Testbench routes have been synchronized for this test.

protected bool $testbenchRouteCleanupRegistered

Whether route file cleanup has been registered for this test.

protected bool $reloadingApplicationForCachedRoutes

Whether defineCacheRoutes() is reloading the application to load cached routes.

protected array<int, string> $testbenchRouteFiles

Route files written by this test instance.

Methods

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

Determine if the test case uses the given trait, or the Testing trait by default.

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()

Load test fixtures and 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.

void
setUpApplicationRoutes(Application $app)

Setup application routes.

void
defineRoutes(Router $router)

Define routes setup.

void
defineWebRoutes(Router $router)

Define web routes setup.

void
defineStashRoutes(Closure|string $route)

Define stash routes setup.

void
defineCacheRoutes(Closure|string $route, bool $cached = true)

Define cache routes setup.

void
syncTestbenchRoutes()

Synchronize Testbench routes.

void
registerTestbenchRouteCleanup(Filesystem $files, string $cachedRoutesPath)

Register cleanup for route files and route cache written by this test.

string
testbenchRouteFilePath(string $basePath)

Get a route file path owned by this test instance.

Details

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

Determine if the test case uses the given trait, or the Testing trait by default.

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()

internal  
 

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()

internal  
 

Execute BeforeEach lifecycle attributes.

Return Value

void

protected void tearDownTheTestEnvironmentUsingTestCase()

internal  
 

Execute AfterEach lifecycle attributes.

Return Value

void

static void setUpBeforeClassUsingTestCase()

internal  
 

Load test fixtures and execute BeforeAll lifecycle attributes.

Return Value

void

static void tearDownAfterClassUsingTestCase()

internal  
 

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()

internal  
 

Resolve the PHPUnit test class name.

Return Value

string|null

string|null resolvePhpUnitTestMethodName()

internal  
 

Resolve the PHPUnit test method name.

Return Value

string|null

in InteractsWithPHPUnit at line 100
protected Collection resolvePhpUnitAttributes()

internal  
 

Resolve and cache PHPUnit attributes for current test.

Return Value

Collection

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

internal  
 

Define the setUp environment using callback.

Parameters

Closure $setUp

Return Value

void

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

internal  
 

Define the tearDown environment using callback.

Parameters

Closure $tearDown

Return Value

void

in InteractsWithPHPUnit at line 168
static void setUpBeforeClassUsingPHPUnit()

internal  
 

Cache uses for test case before class runs.

Return Value

void

in InteractsWithPHPUnit at line 178
static void tearDownAfterClassUsingPHPUnit()

internal  
 

Clear PHPUnit caches after class teardown.

Return Value

void

at line 60
protected void setUpApplicationRoutes(Application $app)

internal  
 

Setup application routes.

Parameters

Application $app

Return Value

void

at line 87
protected void defineRoutes(Router $router)

Define routes setup.

Parameters

Router $router

Return Value

void

at line 97
protected void defineWebRoutes(Router $router)

Define web routes setup.

Parameters

Router $router

Return Value

void

at line 107
protected void defineStashRoutes(Closure|string $route)

Define stash routes setup.

Parameters

Closure|string $route

Return Value

void

at line 117
protected void defineCacheRoutes(Closure|string $route, bool $cached = true)

Define cache routes setup.

Parameters

Closure|string $route
bool $cached

Return Value

void

at line 194
protected void syncTestbenchRoutes()

internal  
 

Synchronize Testbench routes.

Return Value

void

at line 213
protected void registerTestbenchRouteCleanup(Filesystem $files, string $cachedRoutesPath)

Register cleanup for route files and route cache written by this test.

Parameters

Filesystem $files
string $cachedRoutesPath

Return Value

void

at line 266
protected string testbenchRouteFilePath(string $basePath)

Get a route file path owned by this test instance.

Parameters

string $basePath

Return Value

string