Documentation

StateTest 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

DECODE_PREFIX  = "<#decURI#>"
ERROR_NO_HOST  = "Cannot set previous input as referer when previous input does not have HTTP_HOST set."
ERROR_NO_PREVIOUS  = "Cannot set previous input as referer when there is no previous input."
ERROR_NO_SCHEME  = "Cannot set previous input as referer when previous input does not have REQUEST_SCHEME set."
ERROR_UNKNOWN_TYPE  = "OverwriteData includes unknown type: 'NOT_A_FIELD'."
$temporaryDirectories  : array<string|int, mixed>
overwritableTypes()  : array<string|int, mixed>
overwritesThatAreNoArrays()  : array<string|int, mixed>
pathsThatParseUrlRejects()  : array<string|int, mixed>
propertiesThatAreNoArrays()  : array<string|int, mixed>
rawQueries()  : array<string|int, mixed>
requestOrders()  : array<string|int, mixed>
rfc3986References()  : array<string|int, mixed>
testAChangeToTheChildNeverReachesTheParent()  : void
testAChangeToTheStateDoesNotReachTheSuperglobals()  : void
testACloneOfAForkHasItsOwnPreviousPointer()  : void
testAForkKeepsTheBodyOfItsParent()  : void
testAForkKeepsTheRequestOrderOfItsParent()  : void
testAForkOfAForkPointsToTheStateItWasForkedFrom()  : void
testAnEmptyArgumentListLeavesOnlyScriptAndCommand()  : void
testAnEmptyStringAsPreviousHttpHostIsRejectedLikeAMissingOne()  : void
testAnEmptyStringAsPreviousRequestSchemeIsRejectedLikeAMissingOne()  : void
testAnOverwriteOfANestedValueReplacesItAsAWhole()  : void
testAPrefixWithoutAValueDecodesToAnEmptyString()  : void
testARelativePathIsResolvedNextToTheCurrentPathNotItsQuery()  : void
testARelativePathOnAStateWithoutAUriStartsAtTheRoot()  : void
testAUrlWithAPathAndNoQueryDropsThePriorQuery()  : void
testAUrlWithAQueryWorksOnAnInputWithoutRequestUri()  : void
testBuildsSchemeHostPathFromThePreviousState()  : void
testChildPreviousTracksTheParentByReference()  : void
testDecodesOnlyOnceAndKeepsAPlusSign()  : void
testDecodesPrefixedValuesInNestedArraysAndKeepsTheKeys()  : void
testEmptyArrayClearsBothQueryStringAndRequestUriQuery()  : void
testEncodesTheQueryStringAndKeepsGetAsGiven()  : void
testEveryWitherReturnsTheStateItWasCalledOn()  : void
testFromOverwriteAppliesAnExplicitRequestLast()  : void
testFromOverwriteRefreshesTheRequestOfTheChild()  : void
testFromOverwriteRejectsAPropertyThatHoldsNoArray()  : void
testFromOverwriteRejectsValuesThatAreNoArray()  : void
testFromRequestComparesThePrefixExactly()  : void
testFromRequestDecodesThePostValuesInTheRequestToo()  : void
testFromRequestLeavesARequestValueThatIsNotFromThePostAlone()  : void
testFromRequestLeavesPostValuesThatAreNoTextAsTheyAre()  : void
testHttpSchemeLeavesServerHttpsUnset()  : void
testHttpSchemeRemovesAnHttpsThatWasSetBefore()  : void
testHttpsSchemeSetsServerHttpsOn()  : void
testKeepsArgv01AndReplacesTheRest()  : void
testKeepsThePathWhileSwappingTheQuery()  : void
testLeavesPostValuesWithoutThePrefixUndecoded()  : void
testMergesPerKeyIntoTheExistingArrays()  : void
testMergesSeveralTypesAtOnceAndLeavesTheOthersAlone()  : void
testOmitsTheQuerySeparatorForAnEmptyQueryString()  : void
testOmitsTheQuerySeparatorWhenNoQueryStringIsSet()  : void
testParentIsUnaffectedByCloneMutations()  : void
testPathOnlyUrlLeavesPriorSchemeHostIntact()  : void
testPreservesAnyPriorQueryStringOnRequestUri()  : void
testQueryOnlyUrlReplacesQueryWhilePreservingPath()  : void
testRawurldecodesDecURIPrefixedPostValues()  : void
testRejectsUnknownOverwriteKeysWithInvalidArgumentException()  : void
testReplacesAnExistingReferer()  : void
testReplacesGetWholesale()  : void
testRequestEqualsArrayMergeGetPostCookieCookieBeatsPostBeatsGet()  : void
testRequestFollowsTheRequestOrder()  : void
testRequestKeepsNumericKeysAndLetsThePostWin()  : void
testRewritesRequestUriAndRedirectUrl()  : void
testStripsLeadingSlashesBeforeReformatting()  : void
testSurvivesAMissingServerArgvTreatsItAsEmpty()  : void
testSurvivesAStateWithoutPriorServerRequestUri()  : void
testTakesTheOtherRequestDataFromTheGlobals()  : void
testTheHostIsCheckedBeforeTheScheme()  : void
testThePreviousRootPathKeepsItsSlash()  : void
testTheQueryOfAUrlIsDecodedIntoGet()  : void
testTheRefererComesFromThePreviousStateAndNotFromTheCurrentOne()  : void
testTheRefererHasNoPathWithoutAPreviousRequestUri()  : void
testThrowsLogicExceptionWhenThePreviousHttpHostIsEmpty()  : void
testThrowsLogicExceptionWhenThePreviousRequestSchemeIsEmpty()  : void
testThrowsLogicExceptionWhenThereIsNoPreviousState()  : void
testWiresSchemeHostPathQueryGetInOneCall()  : void
testWithBodyOverwritesTheRawBodyString()  : void
testWithCookiesReplacesCookieAndRefreshesRequest()  : void
testWithFilesReplacesFilesWholesale()  : void
testWithGetKeepsEverythingBeforeTheFirstQuestionMark()  : void
testWithGetLeavesATokenizationOfTheCallerAlone()  : void
testWithGetReplacesTheQueryOfAUriThatHasNoPath()  : void
testWithGetWritesNoQuestionMarkWhenTheQueryStringIsEmpty()  : void
testWithMethodOverwritesServerRequestMethod()  : void
testWithPathKeepsAQueryStringOfZero()  : void
testWithPathKeepsThePriorQueryThatWithUrlDrops()  : void
testWithPostReplacesPostAndRefreshesRequest()  : void
testWithRefererOverwritesHttpRefererVerbatim()  : void
testWithSessionReplacesSessionWholesale()  : void
testWithUrlAcceptsAPathThatParseUrlRejects()  : void
testWithUrlClearsTheQueryForAUrlThatEndsInAQuestionMark()  : void
testWithUrlFillsGetLikePhpFillsItsOwn()  : void
testWithUrlKeepsAnEncodedPathEncoded()  : void
testWithUrlKeepsTheBracketsAndThePortOfAnIpv6Host()  : void
testWithUrlKeepsThePortInTheHost()  : void
testWithUrlKeepsTheQueryStringAsItWasGiven()  : void
testWithUrlLeavesTheFragmentOut()  : void
testWithUrlLeavesTheLoginOfAUrlOutOfTheHost()  : void
testWithUrlOfAHostWithoutAPathPointsToTheStartPage()  : void
testWithUrlReadsTheSchemeRegardlessOfCase()  : void
testWithUrlRejectsAUrlThatCannotBeRead()  : void
testWithUrlResolvesAReferenceLikeRfc3986()  : void
The reference resolution examples of RFC 3986, sections 5.4.1 and 5.4.2, against the base "http://a/b/c/d;p?q". A fragment never reaches a server and an empty path is the start page, otherwise the targets are the ones of the RFC.
withers()  : 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.
tearDown()  : void
temporaryDirectory()  : string
An empty directory with a trailing slash, removed after the test.
childOf()  : State
clearEndpoint()  : void
clearRuntimeCaches()  : void
fromRequestWith()  : State

Constants

DECODE_PREFIX

private mixed DECODE_PREFIX = "<#decURI#>"

ERROR_NO_HOST

private mixed ERROR_NO_HOST = "Cannot set previous input as referer when previous input does not have HTTP_HOST set."

ERROR_NO_PREVIOUS

private mixed ERROR_NO_PREVIOUS = "Cannot set previous input as referer when there is no previous input."

ERROR_NO_SCHEME

private mixed ERROR_NO_SCHEME = "Cannot set previous input as referer when previous input does not have REQUEST_SCHEME set."

ERROR_UNKNOWN_TYPE

private mixed ERROR_UNKNOWN_TYPE = "OverwriteData includes unknown type: 'NOT_A_FIELD'."

Properties

$temporaryDirectories

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

Methods

overwritableTypes()

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

overwritesThatAreNoArrays()

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

pathsThatParseUrlRejects()

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

propertiesThatAreNoArrays()

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

rawQueries()

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

requestOrders()

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

rfc3986References()

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

testAChangeToTheChildNeverReachesTheParent()

public testAChangeToTheChildNeverReachesTheParent(string $type) : void
Parameters
$type : string
Tags
dataProvider

overwritableTypes

Return values
void —

testAChangeToTheStateDoesNotReachTheSuperglobals()

public testAChangeToTheStateDoesNotReachTheSuperglobals() : void
Return values
void —

testACloneOfAForkHasItsOwnPreviousPointer()

public testACloneOfAForkHasItsOwnPreviousPointer() : void
Return values
void —

testAForkKeepsTheBodyOfItsParent()

public testAForkKeepsTheBodyOfItsParent() : void
Return values
void —

testAForkKeepsTheRequestOrderOfItsParent()

public testAForkKeepsTheRequestOrderOfItsParent() : void
Return values
void —

testAForkOfAForkPointsToTheStateItWasForkedFrom()

public testAForkOfAForkPointsToTheStateItWasForkedFrom() : void
Return values
void —

testAnEmptyArgumentListLeavesOnlyScriptAndCommand()

public testAnEmptyArgumentListLeavesOnlyScriptAndCommand() : void
Return values
void —

testAnEmptyStringAsPreviousHttpHostIsRejectedLikeAMissingOne()

public testAnEmptyStringAsPreviousHttpHostIsRejectedLikeAMissingOne() : void
Return values
void —

testAnEmptyStringAsPreviousRequestSchemeIsRejectedLikeAMissingOne()

public testAnEmptyStringAsPreviousRequestSchemeIsRejectedLikeAMissingOne() : void
Return values
void —

testAnOverwriteOfANestedValueReplacesItAsAWhole()

public testAnOverwriteOfANestedValueReplacesItAsAWhole() : void
Return values
void —

testAPrefixWithoutAValueDecodesToAnEmptyString()

public testAPrefixWithoutAValueDecodesToAnEmptyString() : void
Return values
void —

testARelativePathIsResolvedNextToTheCurrentPathNotItsQuery()

public testARelativePathIsResolvedNextToTheCurrentPathNotItsQuery() : void
Return values
void —

testARelativePathOnAStateWithoutAUriStartsAtTheRoot()

public testARelativePathOnAStateWithoutAUriStartsAtTheRoot() : void
Return values
void —

testAUrlWithAPathAndNoQueryDropsThePriorQuery()

public testAUrlWithAPathAndNoQueryDropsThePriorQuery() : void
Return values
void —

testAUrlWithAQueryWorksOnAnInputWithoutRequestUri()

public testAUrlWithAQueryWorksOnAnInputWithoutRequestUri() : void
Return values
void —

testBuildsSchemeHostPathFromThePreviousState()

public testBuildsSchemeHostPathFromThePreviousState() : void
Return values
void —

testChildPreviousTracksTheParentByReference()

public testChildPreviousTracksTheParentByReference() : void
Return values
void —

testDecodesOnlyOnceAndKeepsAPlusSign()

public testDecodesOnlyOnceAndKeepsAPlusSign() : void
Return values
void —

testDecodesPrefixedValuesInNestedArraysAndKeepsTheKeys()

public testDecodesPrefixedValuesInNestedArraysAndKeepsTheKeys() : void
Return values
void —

testEmptyArrayClearsBothQueryStringAndRequestUriQuery()

public testEmptyArrayClearsBothQueryStringAndRequestUriQuery() : void
Return values
void —

testEncodesTheQueryStringAndKeepsGetAsGiven()

public testEncodesTheQueryStringAndKeepsGetAsGiven() : void
Return values
void —

testEveryWitherReturnsTheStateItWasCalledOn()

public testEveryWitherReturnsTheStateItWasCalledOn(callable $wither) : void
Parameters
$wither : callable
Tags
dataProvider

withers

Return values
void —

testFromOverwriteAppliesAnExplicitRequestLast()

public testFromOverwriteAppliesAnExplicitRequestLast() : void
Return values
void —

testFromOverwriteRefreshesTheRequestOfTheChild()

public testFromOverwriteRefreshesTheRequestOfTheChild() : void
Return values
void —

testFromOverwriteRejectsAPropertyThatHoldsNoArray()

public testFromOverwriteRejectsAPropertyThatHoldsNoArray(string $type) : void
Parameters
$type : string
Tags
dataProvider

propertiesThatAreNoArrays

Return values
void —

testFromOverwriteRejectsValuesThatAreNoArray()

public testFromOverwriteRejectsValuesThatAreNoArray(mixed $values) : void
Parameters
$values : mixed
Tags
dataProvider

overwritesThatAreNoArrays

Return values
void —

testFromRequestComparesThePrefixExactly()

public testFromRequestComparesThePrefixExactly() : void
Return values
void —

testFromRequestDecodesThePostValuesInTheRequestToo()

public testFromRequestDecodesThePostValuesInTheRequestToo() : void
Return values
void —

testFromRequestLeavesARequestValueThatIsNotFromThePostAlone()

public testFromRequestLeavesARequestValueThatIsNotFromThePostAlone() : void
Return values
void —

testFromRequestLeavesPostValuesThatAreNoTextAsTheyAre()

public testFromRequestLeavesPostValuesThatAreNoTextAsTheyAre() : void
Return values
void —

testHttpSchemeLeavesServerHttpsUnset()

public testHttpSchemeLeavesServerHttpsUnset() : void
Return values
void —

testHttpSchemeRemovesAnHttpsThatWasSetBefore()

public testHttpSchemeRemovesAnHttpsThatWasSetBefore() : void
Return values
void —

testHttpsSchemeSetsServerHttpsOn()

public testHttpsSchemeSetsServerHttpsOn() : void
Return values
void —

testKeepsArgv01AndReplacesTheRest()

public testKeepsArgv01AndReplacesTheRest() : void
Return values
void —

testKeepsThePathWhileSwappingTheQuery()

public testKeepsThePathWhileSwappingTheQuery() : void
Return values
void —

testLeavesPostValuesWithoutThePrefixUndecoded()

public testLeavesPostValuesWithoutThePrefixUndecoded() : void
Return values
void —

testMergesPerKeyIntoTheExistingArrays()

public testMergesPerKeyIntoTheExistingArrays() : void
Return values
void —

testMergesSeveralTypesAtOnceAndLeavesTheOthersAlone()

public testMergesSeveralTypesAtOnceAndLeavesTheOthersAlone() : void
Return values
void —

testOmitsTheQuerySeparatorForAnEmptyQueryString()

public testOmitsTheQuerySeparatorForAnEmptyQueryString() : void
Return values
void —

testOmitsTheQuerySeparatorWhenNoQueryStringIsSet()

public testOmitsTheQuerySeparatorWhenNoQueryStringIsSet() : void
Return values
void —

testParentIsUnaffectedByCloneMutations()

public testParentIsUnaffectedByCloneMutations() : void
Return values
void —

testPathOnlyUrlLeavesPriorSchemeHostIntact()

public testPathOnlyUrlLeavesPriorSchemeHostIntact() : void
Return values
void —

testPreservesAnyPriorQueryStringOnRequestUri()

public testPreservesAnyPriorQueryStringOnRequestUri() : void
Return values
void —

testQueryOnlyUrlReplacesQueryWhilePreservingPath()

public testQueryOnlyUrlReplacesQueryWhilePreservingPath() : void
Return values
void —

testRawurldecodesDecURIPrefixedPostValues()

public testRawurldecodesDecURIPrefixedPostValues() : void
Return values
void —

testRejectsUnknownOverwriteKeysWithInvalidArgumentException()

public testRejectsUnknownOverwriteKeysWithInvalidArgumentException() : void
Return values
void —

testReplacesAnExistingReferer()

public testReplacesAnExistingReferer() : void
Return values
void —

testReplacesGetWholesale()

public testReplacesGetWholesale() : void
Return values
void —

testRequestEqualsArrayMergeGetPostCookieCookieBeatsPostBeatsGet()

public testRequestEqualsArrayMergeGetPostCookieCookieBeatsPostBeatsGet() : void
Return values
void —

testRequestFollowsTheRequestOrder()

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

requestOrders

Return values
void —

testRequestKeepsNumericKeysAndLetsThePostWin()

public testRequestKeepsNumericKeysAndLetsThePostWin() : void
Return values
void —

testRewritesRequestUriAndRedirectUrl()

public testRewritesRequestUriAndRedirectUrl() : void
Return values
void —

testStripsLeadingSlashesBeforeReformatting()

public testStripsLeadingSlashesBeforeReformatting() : void
Return values
void —

testSurvivesAMissingServerArgvTreatsItAsEmpty()

public testSurvivesAMissingServerArgvTreatsItAsEmpty() : void
Return values
void —

testSurvivesAStateWithoutPriorServerRequestUri()

public testSurvivesAStateWithoutPriorServerRequestUri() : void
Return values
void —

testTakesTheOtherRequestDataFromTheGlobals()

public testTakesTheOtherRequestDataFromTheGlobals() : void
Return values
void —

testTheHostIsCheckedBeforeTheScheme()

public testTheHostIsCheckedBeforeTheScheme() : void
Return values
void —

testThePreviousRootPathKeepsItsSlash()

public testThePreviousRootPathKeepsItsSlash() : void
Return values
void —

testTheQueryOfAUrlIsDecodedIntoGet()

public testTheQueryOfAUrlIsDecodedIntoGet() : void
Return values
void —

testTheRefererComesFromThePreviousStateAndNotFromTheCurrentOne()

public testTheRefererComesFromThePreviousStateAndNotFromTheCurrentOne() : void
Return values
void —

testTheRefererHasNoPathWithoutAPreviousRequestUri()

public testTheRefererHasNoPathWithoutAPreviousRequestUri() : void
Return values
void —

testThrowsLogicExceptionWhenThePreviousHttpHostIsEmpty()

public testThrowsLogicExceptionWhenThePreviousHttpHostIsEmpty() : void
Return values
void —

testThrowsLogicExceptionWhenThePreviousRequestSchemeIsEmpty()

public testThrowsLogicExceptionWhenThePreviousRequestSchemeIsEmpty() : void
Return values
void —

testThrowsLogicExceptionWhenThereIsNoPreviousState()

public testThrowsLogicExceptionWhenThereIsNoPreviousState() : void
Return values
void —

testWiresSchemeHostPathQueryGetInOneCall()

public testWiresSchemeHostPathQueryGetInOneCall() : void
Return values
void —

testWithBodyOverwritesTheRawBodyString()

public testWithBodyOverwritesTheRawBodyString() : void
Return values
void —

testWithCookiesReplacesCookieAndRefreshesRequest()

public testWithCookiesReplacesCookieAndRefreshesRequest() : void
Return values
void —

testWithFilesReplacesFilesWholesale()

public testWithFilesReplacesFilesWholesale() : void
Return values
void —

testWithGetKeepsEverythingBeforeTheFirstQuestionMark()

public testWithGetKeepsEverythingBeforeTheFirstQuestionMark() : void
Return values
void —

testWithGetLeavesATokenizationOfTheCallerAlone()

public testWithGetLeavesATokenizationOfTheCallerAlone() : void
Return values
void —

testWithGetReplacesTheQueryOfAUriThatHasNoPath()

public testWithGetReplacesTheQueryOfAUriThatHasNoPath() : void
Return values
void —

testWithGetWritesNoQuestionMarkWhenTheQueryStringIsEmpty()

public testWithGetWritesNoQuestionMarkWhenTheQueryStringIsEmpty() : void
Return values
void —

testWithMethodOverwritesServerRequestMethod()

public testWithMethodOverwritesServerRequestMethod() : void
Return values
void —

testWithPathKeepsAQueryStringOfZero()

public testWithPathKeepsAQueryStringOfZero() : void
Return values
void —

testWithPathKeepsThePriorQueryThatWithUrlDrops()

public testWithPathKeepsThePriorQueryThatWithUrlDrops() : void
Return values
void —

testWithPostReplacesPostAndRefreshesRequest()

public testWithPostReplacesPostAndRefreshesRequest() : void
Return values
void —

testWithRefererOverwritesHttpRefererVerbatim()

public testWithRefererOverwritesHttpRefererVerbatim() : void
Return values
void —

testWithSessionReplacesSessionWholesale()

public testWithSessionReplacesSessionWholesale() : void
Return values
void —

testWithUrlAcceptsAPathThatParseUrlRejects()

public testWithUrlAcceptsAPathThatParseUrlRejects(string $url, string $uri, string $path, array<string|int, mixed> $get) : void
Parameters
$url : string
$uri : string
$path : string
$get : array<string|int, mixed>
Tags
dataProvider

pathsThatParseUrlRejects

Return values
void —

testWithUrlClearsTheQueryForAUrlThatEndsInAQuestionMark()

public testWithUrlClearsTheQueryForAUrlThatEndsInAQuestionMark() : void
Return values
void —

testWithUrlFillsGetLikePhpFillsItsOwn()

public testWithUrlFillsGetLikePhpFillsItsOwn(string $query) : void
Parameters
$query : string
Tags
dataProvider

rawQueries

Return values
void —

testWithUrlKeepsAnEncodedPathEncoded()

public testWithUrlKeepsAnEncodedPathEncoded() : void
Return values
void —

testWithUrlKeepsTheBracketsAndThePortOfAnIpv6Host()

public testWithUrlKeepsTheBracketsAndThePortOfAnIpv6Host() : void
Return values
void —

testWithUrlKeepsThePortInTheHost()

public testWithUrlKeepsThePortInTheHost() : void
Return values
void —

testWithUrlKeepsTheQueryStringAsItWasGiven()

public testWithUrlKeepsTheQueryStringAsItWasGiven(string $query, array<string|int, mixed> $get) : void
Parameters
$query : string
$get : array<string|int, mixed>
Tags
dataProvider

rawQueries

Return values
void —

testWithUrlLeavesTheFragmentOut()

public testWithUrlLeavesTheFragmentOut() : void
Return values
void —

testWithUrlLeavesTheLoginOfAUrlOutOfTheHost()

public testWithUrlLeavesTheLoginOfAUrlOutOfTheHost() : void
Return values
void —

testWithUrlOfAHostWithoutAPathPointsToTheStartPage()

public testWithUrlOfAHostWithoutAPathPointsToTheStartPage() : void
Return values
void —

testWithUrlReadsTheSchemeRegardlessOfCase()

public testWithUrlReadsTheSchemeRegardlessOfCase() : void
Return values
void —

testWithUrlRejectsAUrlThatCannotBeRead()

public testWithUrlRejectsAUrlThatCannotBeRead() : void
Return values
void —

testWithUrlResolvesAReferenceLikeRfc3986()

The reference resolution examples of RFC 3986, sections 5.4.1 and 5.4.2, against the base "http://a/b/c/d;p?q". A fragment never reaches a server and an empty path is the start page, otherwise the targets are the ones of the RFC.

public testWithUrlResolvesAReferenceLikeRfc3986(string $reference, string $target) : void
Parameters
$reference : string
$target : string
Tags
dataProvider

rfc3986References

Return values
void —

withers()

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

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 —

childOf()

private childOf(array<string|int, mixed> $previousServer) : State
Parameters
$previousServer : array<string|int, mixed>
Return values
State —

clearEndpoint()

private clearEndpoint() : void
Return values
void —

clearRuntimeCaches()

private clearRuntimeCaches() : void
Return values
void —

fromRequestWith()

private fromRequestWith([array<string|int, mixed> $post = [] ][, array<string|int, mixed> $get = [] ][, array<string|int, mixed> $cookie = [] ][, array<string|int, mixed> $files = [] ][, array<string|int, mixed> $server = [] ][, array<string|int, mixed> $request = [] ]) : State
Parameters
$post : array<string|int, mixed> = []
$get : array<string|int, mixed> = []
$cookie : array<string|int, mixed> = []
$files : array<string|int, mixed> = []
$server : array<string|int, mixed> = []
$request : array<string|int, mixed> = []
Return values
State —

Search results