Documentation

ResponseOutputTest extends TestCase
in package

What the response prints. json() and the cookie functions send headers, which PHP refuses once the test runner has printed anything, so every test runs in a process of its own. The headers themselves are not visible on the command line, the e2e suite asserts them.

Tags
runTestsInSeparateProcesses
preserveGlobalState

disabled

Table of Contents

$temporaryDirectories  : array<string|int, mixed>
acceptHeaders()  : array<string|int, mixed>
hosts()  : array<string|int, mixed>
jsonValues()  : array<string|int, mixed>
testARestReplyIsJsonForAClientThatAsksForItAndPlainTextOtherwise()  : void
testFrameworkCookiesAreSecureOnAnHttpsHost()  : void
testGenerateRestNamesThePathBelowTheRootDirectory()  : void
testGenerateRestNamesThePathOfTheCurrentRequest()  : void
testJsonDoesNotEndTheRequest()  : void
testJsonPassesTheEncodingOptionsOn()  : void
testJsonPrintsTheEncodedValue()  : void
testJsonThrowsForAValueThatCannotBeEncodedAndPrintsNothing()  : void
testUnsetCookieOfAnUnknownCookieChangesNothing()  : void
testUnsetCookieRemovesTheCookieFromTheCurrentRequest()  : 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.
clearEndpoint()  : void
clearRuntimeCaches()  : void
printed()  : string

Properties

$temporaryDirectories

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

Methods

acceptHeaders()

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

hosts()

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

jsonValues()

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

testARestReplyIsJsonForAClientThatAsksForItAndPlainTextOtherwise()

public testARestReplyIsJsonForAClientThatAsksForItAndPlainTextOtherwise(string|null $accept, string $expected) : void
Parameters
$accept : string|null
$expected : string
Tags
dataProvider

acceptHeaders

Return values
void —

testFrameworkCookiesAreSecureOnAnHttpsHost()

public testFrameworkCookiesAreSecureOnAnHttpsHost(mixed $host, bool $secure) : void
Parameters
$host : mixed
$secure : bool
Tags
dataProvider

hosts

Return values
void —

testGenerateRestNamesThePathBelowTheRootDirectory()

public testGenerateRestNamesThePathBelowTheRootDirectory() : void
Return values
void —

testGenerateRestNamesThePathOfTheCurrentRequest()

public testGenerateRestNamesThePathOfTheCurrentRequest() : void
Return values
void —

testJsonDoesNotEndTheRequest()

public testJsonDoesNotEndTheRequest() : void
Return values
void —

testJsonPassesTheEncodingOptionsOn()

public testJsonPassesTheEncodingOptionsOn() : void
Return values
void —

testJsonPrintsTheEncodedValue()

public testJsonPrintsTheEncodedValue(mixed $value, string $expected) : void
Parameters
$value : mixed
$expected : string
Tags
dataProvider

jsonValues

Return values
void —

testJsonThrowsForAValueThatCannotBeEncodedAndPrintsNothing()

public testJsonThrowsForAValueThatCannotBeEncodedAndPrintsNothing() : void
Return values
void —

testUnsetCookieOfAnUnknownCookieChangesNothing()

public testUnsetCookieOfAnUnknownCookieChangesNothing() : void
Return values
void —

testUnsetCookieRemovesTheCookieFromTheCurrentRequest()

public testUnsetCookieRemovesTheCookieFromTheCurrentRequest() : 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 —

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 —

clearEndpoint()

private clearEndpoint() : void
Return values
void —

clearRuntimeCaches()

private clearRuntimeCaches() : void
Return values
void —

printed()

private printed(callable $action) : string
Parameters
$action : callable
Return values
string —

Search results