Documentation

RerouteTest extends TestCase
in package

A reroute forks the input of the current request, points it to the new path and dispatches it. The dispatch needs routes and controllers, so the framework of these tests only records the request it would dispatch.

Table of Contents

$framework  : RecordingFramework
$temporaryDirectories  : array<string|int, mixed>
aliases()  : array<string|int, mixed>
rootDirectories()  : array<string|int, mixed>
testAnAliasOverlaysTheCurrentPath()  : void
testAnEmptyPathReroutesToTheStartPage()  : void
testEveryRerouteAddsItsRequestToTheStack()  : void
testTheInputOfTheReroutedRequestPointsBackToTheOriginalOne()  : void
testTheOriginalRequestIsLeftAsItWas()  : void
testTheReroutedPathLiesBelowTheRootDirectory()  : void
testTheReroutedPathReplacesTheArgumentsOfACommandLineCall()  : void
testTheReroutedRequestIsTheOneThatGetsDispatched()  : void
testTheReroutedRequestKeepsTheDataOfTheOriginalOne()  : void
testTheReroutedRequestKeepsTheQueryString()  : void
testTheReroutedRequestPointsToTheNewPath()  : void
testTheResponseReroutesToTheGivenPath()  : void
testTheRouteParametersOfTheOriginalRequestAreNotCarriedOver()  : void
testTheStoreOfTheRequestSurvivesAReroute()  : void
testTheStoreSurvivesARerouteOfAReroute()  : void
testWithoutTheAliasFlagThePathReplacesTheCurrentOne()  : void
assertThrows()  : Throwable
Asserts that the action throws exactly this class, no subclass of it, with exactly this message. expectException() accepts subclasses and a message that only contains the expected one.
bootFramework()  : ZubZet
Provides the framework instance the global helpers (zubzet(), config(), request(), ...) work on. It holds exactly the given settings: nothing is read from a config file, nothing connects, and there is no request, response, database or user until the test sets one.
callHidden()  : mixed
Calls a method that is not public. Only for logic that has no public way in; a test goes through the public method wherever there is one.
currentUser()  : User
Makes a user without database access the current one, the one user() returns. Its constructor would identify it through the database, so it is left out: the user is anonymous unless the test says otherwise.
inDirectory()  : mixed
Runs the action with the given directory as the working directory, for code that reads relative paths. The previous directory is restored afterwards, also when the action throws.
input()  : State
An input without any data. The with...() methods of the state fill it:
removeSetting()  : void
Removes a setting, as if its line was missing in the config file.
request()  : Request
Makes the given input the current request, the one request() returns.
requireArgon2id()  : void
Skips the test on a PHP built without Argon2. The framework hashes with PASSWORD_ARGON2ID unconditionally and composer.json does not require the support, so the tests that reach it have to tolerate its absence.
response()  : Response
Makes a new response the current one, the one response() returns.
setHiddenStatic()  : void
Sets a static property that is not public. Only for state a class keeps for the whole process and offers no way to reset.
setSettings()  : void
Changes single settings of the booted framework and keeps the others.
setUp()  : void
tearDown()  : void
temporaryDirectory()  : string
An empty directory with a trailing slash, removed after the test.
boot()  : void
clearEndpoint()  : void
clearRuntimeCaches()  : void
current()  : Request

Properties

$temporaryDirectories

private array<string|int, mixed> $temporaryDirectories = []

Methods

aliases()

public static aliases() : array<string|int, mixed>
Return values
array<string|int, mixed> —

rootDirectories()

public static rootDirectories() : array<string|int, mixed>
Return values
array<string|int, mixed> —

testAnAliasOverlaysTheCurrentPath()

public testAnAliasOverlaysTheCurrentPath(string $uri, array<string|int, mixed> $path, array<string|int, mixed> $expected) : void
Parameters
$uri : string
$path : array<string|int, mixed>
$expected : array<string|int, mixed>
Tags
dataProvider

aliases

Return values
void —

testAnEmptyPathReroutesToTheStartPage()

public testAnEmptyPathReroutesToTheStartPage() : void
Return values
void —

testEveryRerouteAddsItsRequestToTheStack()

public testEveryRerouteAddsItsRequestToTheStack() : void
Return values
void —

testTheInputOfTheReroutedRequestPointsBackToTheOriginalOne()

public testTheInputOfTheReroutedRequestPointsBackToTheOriginalOne() : void
Return values
void —

testTheOriginalRequestIsLeftAsItWas()

public testTheOriginalRequestIsLeftAsItWas() : void
Return values
void —

testTheReroutedPathLiesBelowTheRootDirectory()

public testTheReroutedPathLiesBelowTheRootDirectory(string $rootDirectory, string $rootFolder, string $uri) : void
Parameters
$rootDirectory : string
$rootFolder : string
$uri : string
Tags
dataProvider

rootDirectories

Return values
void —

testTheReroutedPathReplacesTheArgumentsOfACommandLineCall()

public testTheReroutedPathReplacesTheArgumentsOfACommandLineCall() : void
Return values
void —

testTheReroutedRequestIsTheOneThatGetsDispatched()

public testTheReroutedRequestIsTheOneThatGetsDispatched() : void
Return values
void —

testTheReroutedRequestKeepsTheDataOfTheOriginalOne()

public testTheReroutedRequestKeepsTheDataOfTheOriginalOne() : void
Return values
void —

testTheReroutedRequestKeepsTheQueryString()

public testTheReroutedRequestKeepsTheQueryString() : void
Return values
void —

testTheReroutedRequestPointsToTheNewPath()

public testTheReroutedRequestPointsToTheNewPath() : void
Return values
void —

testTheResponseReroutesToTheGivenPath()

public testTheResponseReroutesToTheGivenPath() : void
Return values
void —

testTheRouteParametersOfTheOriginalRequestAreNotCarriedOver()

public testTheRouteParametersOfTheOriginalRequestAreNotCarriedOver() : void
Return values
void —

testTheStoreOfTheRequestSurvivesAReroute()

public testTheStoreOfTheRequestSurvivesAReroute() : void
Return values
void —

testTheStoreSurvivesARerouteOfAReroute()

public testTheStoreSurvivesARerouteOfAReroute() : void
Return values
void —

testWithoutTheAliasFlagThePathReplacesTheCurrentOne()

public testWithoutTheAliasFlagThePathReplacesTheCurrentOne() : void
Return values
void —

assertThrows()

Asserts that the action throws exactly this class, no subclass of it, with exactly this message. expectException() accepts subclasses and a message that only contains the expected one.

protected assertThrows(class-string<\Throwable> $class, string $message, callable $action) : Throwable
Parameters
$class : class-string<\Throwable>
$message : string
$action : callable
Return values
Throwable —

bootFramework()

Provides the framework instance the global helpers (zubzet(), config(), request(), ...) work on. It holds exactly the given settings: nothing is read from a config file, nothing connects, and there is no request, response, database or user until the test sets one.

protected bootFramework([array<string, mixed> $settings = [] ]) : ZubZet
Parameters
$settings : array<string, mixed> = []

What config() returns

Return values
ZubZet —

callHidden()

Calls a method that is not public. Only for logic that has no public way in; a test goes through the public method wherever there is one.

protected callHidden(object|class-string $target, string $method, mixed ...$arguments) : mixed
Parameters
$target : object|class-string

An object, or a class name for a static method

$method : string
$arguments : mixed
Return values
mixed —

currentUser()

Makes a user without database access the current one, the one user() returns. Its constructor would identify it through the database, so it is left out: the user is anonymous unless the test says otherwise.

protected currentUser([bool $loggedIn = false ]) : User
Parameters
$loggedIn : bool = false
Return values
User —

inDirectory()

Runs the action with the given directory as the working directory, for code that reads relative paths. The previous directory is restored afterwards, also when the action throws.

protected inDirectory(string $directory, callable $action) : mixed
Parameters
$directory : string
$action : callable
Return values
mixed —

input()

An input without any data. The with...() methods of the state fill it:

protected input([string $requestOrder = "GPC" ]) : State

$this->input()->withMethod("POST")->withPost(["name" => "value"])

REQUEST is put together from GET, POST and COOKIE in the given order, whatever the php.ini of the machine says, so a test sees the same REQUEST everywhere.

Parameters
$requestOrder : string = "GPC"
Return values
State —

removeSetting()

Removes a setting, as if its line was missing in the config file.

protected removeSetting(string $key) : void
Parameters
$key : string
Return values
void —

request()

Makes the given input the current request, the one request() returns.

protected request([State|null $input = null ]) : Request

Boots the framework without settings when the test has not done so.

Parameters
$input : State|null = null
Return values
Request —

requireArgon2id()

Skips the test on a PHP built without Argon2. The framework hashes with PASSWORD_ARGON2ID unconditionally and composer.json does not require the support, so the tests that reach it have to tolerate its absence.

protected requireArgon2id() : void
Return values
void —

response()

Makes a new response the current one, the one response() returns.

protected response() : Response

Boots the framework without settings when the test has not done so.

Return values
Response —

setHiddenStatic()

Sets a static property that is not public. Only for state a class keeps for the whole process and offers no way to reset.

protected setHiddenStatic(class-string $class, string $property, mixed $value) : void
Parameters
$class : class-string
$property : string
$value : mixed
Return values
void —

setSettings()

Changes single settings of the booted framework and keeps the others.

protected setSettings(array<string, mixed> $settings) : void
Parameters
$settings : array<string, mixed>
Return values
void —

setUp()

protected setUp() : void
Return values
void —

tearDown()

protected tearDown() : void
Return values
void —

temporaryDirectory()

An empty directory with a trailing slash, removed after the test.

protected temporaryDirectory() : string
Return values
string —

boot()

private boot([array<string, mixed> $settings = [] ]) : void
Parameters
$settings : array<string, mixed> = []
Return values
void —

clearEndpoint()

private clearEndpoint() : void
Return values
void —

clearRuntimeCaches()

private clearRuntimeCaches() : void
Return values
void —

Search results