Documentation

RequestTest extends TestCase
in package

The base of every unit test that needs more than the class under test.

A test asks for what it needs and gets it without a web server, a database or a config file:

$this->bootFramework(["rootDirectory" => "sub"]);
$request = $this->request($this->input()->withUrl("http://localhost/sub/a/b"));

Everything handed out here is taken back after the test, so no test sees the settings, the request or the cached values of another one.

Table of Contents

ERROR_TOO_LARGE  = "Body too large"
FORM_ACTION  = "target-action"
HOST  = "http://localhost:8080"
SLUG_URI  = "/Core/readable/"
$temporaryDirectories  : array<string|int, mixed>
actions()  : array<string|int, mixed>
contentTypes()  : array<string|int, mixed>
formActionsThatDifferOnlyLoosely()  : array<string|int, mixed>
formActionsThatLookEmpty()  : array<string|int, mixed>
hostShapes()  : array<string|int, mixed>
ipHeaders()  : array<string|int, mixed>
methods()  : array<string|int, mixed>
parameterComparisons()  : array<string|int, mixed>
pathsBelowTheRootDirectory()  : array<string|int, mixed>
pathsOutsideTheRootDirectory()  : array<string|int, mixed>
scalarBodies()  : array<string|int, mixed>
testABodyOfOnlyWhitespaceIsMalformed()  : void
testAcceptsABodyOfAnyLengthWithoutALimit()  : void
testAcceptsABodyOfExactlyMaxBytes()  : void
testAcceptsAnEmptyObjectAndAnEmptyList()  : void
testAcceptsDeepNestingWithoutALimit()  : void
testAcceptsNestingOfThirtyLevelsWithTheDefaultMaxDepth()  : void
testAcceptsNestingUpToMaxDepth()  : void
testAPathEndingInAColonAndDigitsIsASingleSegment()  : void
testCliDispatchAllowsTheConsolePermissionWithBoolResultAndSuperUserFlagsToo()  : void
testCliDispatchConstructGateAllowsTheActionToRun()  : void
testComparesTheFormActionStrictly()  : void
testCountsTheBodyInBytesNotCharacters()  : void
testDecodesTheBodyOfEveryMethod()  : void
testDecodesTheBodyWhateverTheContentTypeIs()  : void
testDoesNotMatchAListOfFormActions()  : void
testDoesNotMatchANamedActionOnADifferentFormAction()  : void
testDoesNotMatchANamedActionWhenNoFormActionWasPosted()  : void
testGetBodyIsNullWithoutABody()  : void
testGetCurrentUrlConcatenatesConfigHostWithTheRequestUri()  : void
testGetCurrentUrlIgnoresTheIncomingHostHeaderConfigHostWins()  : void
testGetCurrentUrlIsTheHostAloneWithoutARequestUri()  : void
testGetCurrentUrlPicksUpADynamicAttributesHostOverrideMidRequest()  : void
testGetDomainIsEmptyWithoutAHostSetting()  : void
testGetDomainStripsSchemePortTrailingSlashAcrossHostShapes()  : void
testGetExecutionTimeIncreasesByTheInActionSleepDuration()  : void
testGetExecutionTimeIsNullWithoutAStartTime()  : void
testGetParametersComparesTheParameterAsText()  : void
testGetParametersReturnsAParameterOfZero()  : void
testGetParametersSkipsControllerAndActionAndTheOffset()  : void
testGetParametersSlicesByTheLength()  : void
testGetParametersWithALengthOfOneReturnsTheParameterOrFalse()  : void
testGetParametersWithANegativeOffsetReachesControllerAndAction()  : void
testGetReadableParameter0AMissingSegmentGivesEmptyStrings()  : void
testGetReadableParameter0ATrailingDashLeavesAnEmptyId()  : void
testGetReadableParameter0SingleSegmentTheValueBecomesIdTextEmpty()  : void
testGetReadableParameter0TwoSegmentSlugIdIsTheTrailingToken()  : void
testGetReadableParameter0TypicalSeoSlugSplitsIdOffTheTail()  : void
testGetReadableParameter1OffsetSkipsOneParameterBeforeSplitting()  : void
testGetUrlPartsCutsAtTheFirstQuestionMarkOnly()  : void
testGetUrlPartsDoesNotDecodeSegmentsAndKeepsASlashInsideAQuery()  : void
testGetUrlPartsIgnoresSlashesAroundTheRootDirectory()  : void
testGetUrlPartsIgnoresSlashesAtBothEnds()  : void
testGetUrlPartsKeepsAnEmptySegmentBetweenTwoSlashes()  : void
testGetUrlPartsKeepsAPathThatIsNotBelowTheRootDirectory()  : void
testGetUrlPartsKeepsASegmentOfZero()  : void
testGetUrlPartsKeepsWhatWasSetBeforehandAndCachesTheFirstResult()  : void
testGetUrlPartsOfAnUriWithoutSegmentsIsEmpty()  : void
testGetUrlPartsReturnsTheParsedPathSegmentsVerbatimByDefault()  : void
testGetUrlPartsSkipsADoubledSlashAfterTheRootDirectory()  : void
testGetUrlPartsStripsOneRootDirectorySegment()  : void
testGetUrlPartsStripsTheRootDirectoryOfAPathBelowIt()  : void
testGetUrlPartsStripsTwoRootDirectorySegmentsMultiFolder()  : void
testHttpDispatchWithBoolResultTrueDeniesTheSuperUserToo()  : void
testHttpDispatchWithBoolResultTrueReturnsFalseWithoutExiting()  : void
testIpIsAnEmptyStringWithoutAnyAddress()  : void
testIpResolvesFromHeaderPriorityChain()  : void
testIpReturnsAForwardedChainUnsplit()  : void
testIsActionComparesThePostedActionAsText()  : void
testIsNoFormDataWithoutTheIsFormDataFlagEvenWithAFormAction()  : void
testKeepsIntegersBeyondPhpIntMaxAsStrings()  : void
testMatchesAFormActionThatLooksEmpty()  : void
testMatchesANamedActionOnlyOnTheExactFormAction()  : void
testMatchesAnyFormSubmissionWhenCalledWithoutAnAction()  : void
testRefererReflectsTheRefererHeaderAndIsNullWhenAbsent()  : void
testRejectsABodyBeyondMaxBytesWith413()  : void
testRejectsABodyOneByteBeyondMaxBytes()  : void
testRejectsALeadingBomWith400()  : void
testRejectsAnUnescapedControlCharacterWith400()  : void
testRejectsInvalidUtf8With400()  : void
testRejectsMalformedJsonWith400()  : void
testRejectsNestingBeyondMaxDepthWith400()  : void
testRejectsNestingBeyondTheLimitOfPhp()  : void
testReturnsATopLevelListAsArray()  : void
testReturnsJsonThatIsNoObjectAndNoListAsItsValue()  : void
testReturnsNullForAFormPostSoTheActionCanReadThePostedFields()  : void
testReturnsNullWithoutABody()  : void
testRoundTripsAJsonObjectNextToTheRawBody()  : void
testUrlPartsKeepASegmentThatEndsInAColonAndDigits()  : void
testUserAgentIsNullWhenAbsent()  : void
testUserAgentReturnsTheUserAgentHeaderVerbatim()  : void
urisWithAZero()  : array<string|int, mixed>
urisWithoutSegments()  : array<string|int, mixed>
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.
assertMalformed()  : void
assertRejected()  : void
clearEndpoint()  : void
clearRuntimeCaches()  : void
formDataMatches()  : array<string|int, mixed>
httpRequest()  : Request
jsonRequest()  : Request
requestFor()  : Request
requestStartedAgo()  : Request

Constants

ERROR_TOO_LARGE

private mixed ERROR_TOO_LARGE = "Body too large"

FORM_ACTION

private mixed FORM_ACTION = "target-action"

Properties

$temporaryDirectories

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

Methods

actions()

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

contentTypes()

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

formActionsThatDifferOnlyLoosely()

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

formActionsThatLookEmpty()

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

hostShapes()

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

ipHeaders()

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

methods()

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

parameterComparisons()

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

pathsBelowTheRootDirectory()

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

pathsOutsideTheRootDirectory()

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

scalarBodies()

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

testABodyOfOnlyWhitespaceIsMalformed()

public testABodyOfOnlyWhitespaceIsMalformed() : void
Return values
void —

testAcceptsABodyOfAnyLengthWithoutALimit()

public testAcceptsABodyOfAnyLengthWithoutALimit() : void
Return values
void —

testAcceptsABodyOfExactlyMaxBytes()

public testAcceptsABodyOfExactlyMaxBytes() : void
Return values
void —

testAcceptsAnEmptyObjectAndAnEmptyList()

public testAcceptsAnEmptyObjectAndAnEmptyList() : void
Return values
void —

testAcceptsDeepNestingWithoutALimit()

public testAcceptsDeepNestingWithoutALimit() : void
Return values
void —

testAcceptsNestingOfThirtyLevelsWithTheDefaultMaxDepth()

public testAcceptsNestingOfThirtyLevelsWithTheDefaultMaxDepth() : void
Return values
void —

testAcceptsNestingUpToMaxDepth()

public testAcceptsNestingUpToMaxDepth() : void
Return values
void —

testAPathEndingInAColonAndDigitsIsASingleSegment()

public testAPathEndingInAColonAndDigitsIsASingleSegment() : void
Return values
void —

testCliDispatchAllowsTheConsolePermissionWithBoolResultAndSuperUserFlagsToo()

public testCliDispatchAllowsTheConsolePermissionWithBoolResultAndSuperUserFlagsToo() : void
Return values
void —

testCliDispatchConstructGateAllowsTheActionToRun()

public testCliDispatchConstructGateAllowsTheActionToRun() : void
Return values
void —

testComparesTheFormActionStrictly()

public testComparesTheFormActionStrictly(string $posted, string $expected) : void
Parameters
$posted : string
$expected : string
Tags
dataProvider

formActionsThatDifferOnlyLoosely

Return values
void —

testCountsTheBodyInBytesNotCharacters()

public testCountsTheBodyInBytesNotCharacters() : void
Return values
void —

testDecodesTheBodyOfEveryMethod()

public testDecodesTheBodyOfEveryMethod(string|null $method) : void
Parameters
$method : string|null
Tags
dataProvider

methods

Return values
void —

testDecodesTheBodyWhateverTheContentTypeIs()

public testDecodesTheBodyWhateverTheContentTypeIs(string $contentType) : void
Parameters
$contentType : string
Tags
dataProvider

contentTypes

Return values
void —

testDoesNotMatchAListOfFormActions()

public testDoesNotMatchAListOfFormActions() : void
Return values
void —

testDoesNotMatchANamedActionOnADifferentFormAction()

public testDoesNotMatchANamedActionOnADifferentFormAction() : void
Return values
void —

testDoesNotMatchANamedActionWhenNoFormActionWasPosted()

public testDoesNotMatchANamedActionWhenNoFormActionWasPosted() : void
Return values
void —

testGetBodyIsNullWithoutABody()

public testGetBodyIsNullWithoutABody() : void
Return values
void —

testGetCurrentUrlConcatenatesConfigHostWithTheRequestUri()

public testGetCurrentUrlConcatenatesConfigHostWithTheRequestUri() : void
Return values
void —

testGetCurrentUrlIgnoresTheIncomingHostHeaderConfigHostWins()

public testGetCurrentUrlIgnoresTheIncomingHostHeaderConfigHostWins() : void
Return values
void —

testGetCurrentUrlIsTheHostAloneWithoutARequestUri()

public testGetCurrentUrlIsTheHostAloneWithoutARequestUri() : void
Return values
void —

testGetCurrentUrlPicksUpADynamicAttributesHostOverrideMidRequest()

public testGetCurrentUrlPicksUpADynamicAttributesHostOverrideMidRequest() : void
Return values
void —

testGetDomainIsEmptyWithoutAHostSetting()

public testGetDomainIsEmptyWithoutAHostSetting() : void
Return values
void —

testGetDomainStripsSchemePortTrailingSlashAcrossHostShapes()

public testGetDomainStripsSchemePortTrailingSlashAcrossHostShapes(string $host, string $expected) : void
Parameters
$host : string
$expected : string
Tags
dataProvider

hostShapes

Return values
void —

testGetExecutionTimeIncreasesByTheInActionSleepDuration()

public testGetExecutionTimeIncreasesByTheInActionSleepDuration() : void
Return values
void —

testGetExecutionTimeIsNullWithoutAStartTime()

public testGetExecutionTimeIsNullWithoutAStartTime() : void
Return values
void —

testGetParametersComparesTheParameterAsText()

public testGetParametersComparesTheParameterAsText(string $parameter, mixed $value, bool $equal) : void
Parameters
$parameter : string
$value : mixed
$equal : bool
Tags
dataProvider

parameterComparisons

Return values
void —

testGetParametersReturnsAParameterOfZero()

public testGetParametersReturnsAParameterOfZero() : void
Return values
void —

testGetParametersSkipsControllerAndActionAndTheOffset()

public testGetParametersSkipsControllerAndActionAndTheOffset() : void
Return values
void —

testGetParametersSlicesByTheLength()

public testGetParametersSlicesByTheLength() : void
Return values
void —

testGetParametersWithALengthOfOneReturnsTheParameterOrFalse()

public testGetParametersWithALengthOfOneReturnsTheParameterOrFalse() : void
Return values
void —

testGetParametersWithANegativeOffsetReachesControllerAndAction()

public testGetParametersWithANegativeOffsetReachesControllerAndAction() : void
Return values
void —

testGetReadableParameter0AMissingSegmentGivesEmptyStrings()

public testGetReadableParameter0AMissingSegmentGivesEmptyStrings() : void
Return values
void —

testGetReadableParameter0ATrailingDashLeavesAnEmptyId()

public testGetReadableParameter0ATrailingDashLeavesAnEmptyId() : void
Return values
void —

testGetReadableParameter0SingleSegmentTheValueBecomesIdTextEmpty()

public testGetReadableParameter0SingleSegmentTheValueBecomesIdTextEmpty() : void
Return values
void —

testGetReadableParameter0TwoSegmentSlugIdIsTheTrailingToken()

public testGetReadableParameter0TwoSegmentSlugIdIsTheTrailingToken() : void
Return values
void —

testGetReadableParameter0TypicalSeoSlugSplitsIdOffTheTail()

public testGetReadableParameter0TypicalSeoSlugSplitsIdOffTheTail() : void
Return values
void —

testGetReadableParameter1OffsetSkipsOneParameterBeforeSplitting()

public testGetReadableParameter1OffsetSkipsOneParameterBeforeSplitting() : void
Return values
void —

testGetUrlPartsCutsAtTheFirstQuestionMarkOnly()

public testGetUrlPartsCutsAtTheFirstQuestionMarkOnly() : void
Return values
void —

testGetUrlPartsDoesNotDecodeSegmentsAndKeepsASlashInsideAQuery()

public testGetUrlPartsDoesNotDecodeSegmentsAndKeepsASlashInsideAQuery() : void
Return values
void —

testGetUrlPartsIgnoresSlashesAroundTheRootDirectory()

public testGetUrlPartsIgnoresSlashesAroundTheRootDirectory() : void
Return values
void —

testGetUrlPartsIgnoresSlashesAtBothEnds()

public testGetUrlPartsIgnoresSlashesAtBothEnds() : void
Return values
void —

testGetUrlPartsKeepsAnEmptySegmentBetweenTwoSlashes()

public testGetUrlPartsKeepsAnEmptySegmentBetweenTwoSlashes() : void
Return values
void —

testGetUrlPartsKeepsAPathThatIsNotBelowTheRootDirectory()

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

pathsOutsideTheRootDirectory

Return values
void —

testGetUrlPartsKeepsASegmentOfZero()

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

urisWithAZero

Return values
void —

testGetUrlPartsKeepsWhatWasSetBeforehandAndCachesTheFirstResult()

public testGetUrlPartsKeepsWhatWasSetBeforehandAndCachesTheFirstResult() : void
Return values
void —

testGetUrlPartsOfAnUriWithoutSegmentsIsEmpty()

public testGetUrlPartsOfAnUriWithoutSegmentsIsEmpty(string $uri) : void
Parameters
$uri : string
Tags
dataProvider

urisWithoutSegments

Return values
void —

testGetUrlPartsReturnsTheParsedPathSegmentsVerbatimByDefault()

public testGetUrlPartsReturnsTheParsedPathSegmentsVerbatimByDefault() : void
Return values
void —

testGetUrlPartsSkipsADoubledSlashAfterTheRootDirectory()

public testGetUrlPartsSkipsADoubledSlashAfterTheRootDirectory() : void
Return values
void —

testGetUrlPartsStripsOneRootDirectorySegment()

public testGetUrlPartsStripsOneRootDirectorySegment() : void
Return values
void —

testGetUrlPartsStripsTheRootDirectoryOfAPathBelowIt()

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

pathsBelowTheRootDirectory

Return values
void —

testGetUrlPartsStripsTwoRootDirectorySegmentsMultiFolder()

public testGetUrlPartsStripsTwoRootDirectorySegmentsMultiFolder() : void
Return values
void —

testHttpDispatchWithBoolResultTrueDeniesTheSuperUserToo()

public testHttpDispatchWithBoolResultTrueDeniesTheSuperUserToo() : void
Return values
void —

testHttpDispatchWithBoolResultTrueReturnsFalseWithoutExiting()

public testHttpDispatchWithBoolResultTrueReturnsFalseWithoutExiting() : void
Return values
void —

testIpIsAnEmptyStringWithoutAnyAddress()

public testIpIsAnEmptyStringWithoutAnyAddress() : void
Return values
void —

testIpResolvesFromHeaderPriorityChain()

public testIpResolvesFromHeaderPriorityChain(array<string|int, mixed> $server, string $expected) : void
Parameters
$server : array<string|int, mixed>
$expected : string
Tags
dataProvider

ipHeaders

Return values
void —

testIpReturnsAForwardedChainUnsplit()

public testIpReturnsAForwardedChainUnsplit() : void
Return values
void —

testIsActionComparesThePostedActionAsText()

public testIsActionComparesThePostedActionAsText(array<string|int, mixed> $post, string $type, bool $expected) : void
Parameters
$post : array<string|int, mixed>
$type : string
$expected : bool
Tags
dataProvider

actions

Return values
void —

testIsNoFormDataWithoutTheIsFormDataFlagEvenWithAFormAction()

public testIsNoFormDataWithoutTheIsFormDataFlagEvenWithAFormAction() : void
Return values
void —

testKeepsIntegersBeyondPhpIntMaxAsStrings()

public testKeepsIntegersBeyondPhpIntMaxAsStrings() : void
Return values
void —

testMatchesAFormActionThatLooksEmpty()

public testMatchesAFormActionThatLooksEmpty(string $action) : void
Parameters
$action : string
Tags
dataProvider

formActionsThatLookEmpty

Return values
void —

testMatchesANamedActionOnlyOnTheExactFormAction()

public testMatchesANamedActionOnlyOnTheExactFormAction() : void
Return values
void —

testMatchesAnyFormSubmissionWhenCalledWithoutAnAction()

public testMatchesAnyFormSubmissionWhenCalledWithoutAnAction() : void
Return values
void —

testRefererReflectsTheRefererHeaderAndIsNullWhenAbsent()

public testRefererReflectsTheRefererHeaderAndIsNullWhenAbsent() : void
Return values
void —

testRejectsABodyBeyondMaxBytesWith413()

public testRejectsABodyBeyondMaxBytesWith413() : void
Return values
void —

testRejectsABodyOneByteBeyondMaxBytes()

public testRejectsABodyOneByteBeyondMaxBytes() : void
Return values
void —

testRejectsALeadingBomWith400()

public testRejectsALeadingBomWith400() : void
Return values
void —

testRejectsAnUnescapedControlCharacterWith400()

public testRejectsAnUnescapedControlCharacterWith400() : void
Return values
void —

testRejectsInvalidUtf8With400()

public testRejectsInvalidUtf8With400() : void
Return values
void —

testRejectsMalformedJsonWith400()

public testRejectsMalformedJsonWith400() : void
Return values
void —

testRejectsNestingBeyondMaxDepthWith400()

public testRejectsNestingBeyondMaxDepthWith400() : void
Return values
void —

testRejectsNestingBeyondTheLimitOfPhp()

public testRejectsNestingBeyondTheLimitOfPhp() : void
Return values
void —

testReturnsATopLevelListAsArray()

public testReturnsATopLevelListAsArray() : void
Return values
void —

testReturnsJsonThatIsNoObjectAndNoListAsItsValue()

public testReturnsJsonThatIsNoObjectAndNoListAsItsValue(string $body, mixed $expected) : void
Parameters
$body : string
$expected : mixed
Tags
dataProvider

scalarBodies

Return values
void —

testReturnsNullForAFormPostSoTheActionCanReadThePostedFields()

public testReturnsNullForAFormPostSoTheActionCanReadThePostedFields() : void
Return values
void —

testReturnsNullWithoutABody()

public testReturnsNullWithoutABody() : void
Return values
void —

testRoundTripsAJsonObjectNextToTheRawBody()

public testRoundTripsAJsonObjectNextToTheRawBody() : void
Return values
void —

testUrlPartsKeepASegmentThatEndsInAColonAndDigits()

public testUrlPartsKeepASegmentThatEndsInAColonAndDigits() : void
Return values
void —

testUserAgentIsNullWhenAbsent()

public testUserAgentIsNullWhenAbsent() : void
Return values
void —

testUserAgentReturnsTheUserAgentHeaderVerbatim()

public testUserAgentReturnsTheUserAgentHeaderVerbatim() : void
Return values
void —

urisWithAZero()

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

urisWithoutSegments()

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

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 —

assertMalformed()

private assertMalformed(int $jsonError, Request $request[, int $maxDepth = 32 ]) : void
Parameters
$jsonError : int
$request : Request
$maxDepth : int = 32
Return values
void —

assertRejected()

private assertRejected(int $status, string $message, Request $request[, int $maxBytes = 1048576 ]) : void
Parameters
$status : int
$message : string
$request : Request
$maxBytes : int = 1048576
Return values
void —

clearEndpoint()

private clearEndpoint() : void
Return values
void —

clearRuntimeCaches()

private clearRuntimeCaches() : void
Return values
void —

formDataMatches()

private formDataMatches(array<string, mixed> $post) : array<string|int, mixed>
Parameters
$post : array<string, mixed>
Return values
array<string|int, mixed> —

jsonRequest()

private jsonRequest(string|null $body[, string $method = "POST" ][, string $contentType = "application/json" ]) : Request
Parameters
$body : string|null
$method : string = "POST"
$contentType : string = "application/json"
Return values
Request —

requestStartedAgo()

private requestStartedAgo(float $seconds) : Request
Parameters
$seconds : float
Return values
Request —

Search results