ResponseTest
extends GuzzleTestCase
in package
Base testcase class for all Guzzle testcases.
Tags
Table of Contents
- $mockObserver : mixed
- $server : mixed
- $serviceBuilder : mixed
- $mockBasePath : mixed
- $response : Response
- $requests : mixed
- addMockedRequest() : self
- Mark a request as being mocked
- assertContainsIns() : mixed
- Case insensitive assertContains
- compareHeaders() : array<string|int, mixed>|bool
- Compare HTTP headers and use special markup to filter values A header prefixed with '!' means it must not exist A header prefixed with '_' means it must be ignored A header value of '*' means anything after the * will be ignored
- getMockedRequests() : array<string|int, mixed>
- Get all of the mocked requests
- getMockResponse() : Response
- Get a mock response for a client by mock file name
- getServer() : Server
- Get the global server object used throughout the unit tests of Guzzle
- getServiceBuilder() : ServiceBuilder
- Get a service builder object that can be used throughout the service tests
- getWildcardObserver() : MockObserver
- Get a wildcard observer for an event dispatcher
- setMockBasePath() : GuzzleTestCase
- Set the mock response base path
- setMockResponse() : MockPlugin
- Set a mock response from a mock file on the next client request.
- setServiceBuilder() : mixed
- Set the service builder to use for tests
- setup() : mixed
- tearDown() : mixed
- test__toString() : mixed
- testCalculatesAge() : mixed
- testCalculatesFreshness() : mixed
- testComparesContentType() : mixed
- testConstructor() : mixed
- testDeterminesIfItCanBeCached() : mixed
- testDeterminesIfItCanValidate() : mixed
- testDeterminesResponseMaxAge() : mixed
- testFactory() : mixed
- testFactoryCanCreateHeadResponses() : mixed
- testFactoryRequiresMessage() : mixed
- testGetAcceptRanges() : mixed
- testGetAllow() : mixed
- testGetBody() : mixed
- testGetCacheControl() : mixed
- testGetContentDisposition() : mixed
- testGetContentEncoding() : mixed
- testGetContentLanguage() : mixed
- testGetContentLength() : mixed
- testGetContentLocation() : mixed
- testGetContentMd5() : mixed
- testGetContentRange() : mixed
- testGetContentType() : mixed
- testGetDate() : mixed
- testGetEtag() : mixed
- testGetExpires() : mixed
- testGetLastModified() : mixed
- testGetLocation() : mixed
- testGetMessage() : mixed
- testGetMultipleSetCookie() : mixed
- testGetPragma() : mixed
- testGetProxyAuthenticate() : mixed
- testGetRawHeaders() : mixed
- testGetServer() : mixed
- testGetSetCookie() : mixed
- testGetSetCookieNormalizesHeaders() : mixed
- testGetTrailer() : mixed
- testGetTransferEncoding() : mixed
- testGetVary() : mixed
- testGetWarning() : mixed
- testHandlesProtocols() : mixed
- testHandlesStatusAndStatusCodes() : mixed
- testHasTransferInfo() : mixed
- testIsClientError() : mixed
- testIsError() : mixed
- testIsInformational() : mixed
- testIsRedirect() : mixed
- testIsServerError() : mixed
- testIsSuccessful() : mixed
- testManagesStatusCode() : mixed
- testParsesJsonResponses() : mixed
- testParsesXmlResponses() : mixed
- testPreventsComplexExternalEntities() : mixed
- testResponseDeterminesIfMethodIsAllowedBaseOnAllowHeader() : mixed
- testResponseIsSerializable() : mixed
- testReturnsConnectionHeader() : mixed
- testReturnsHeaders() : mixed
- testReturnsViaHeader() : mixed
- testReturnsWwwAuthenticateHeader() : mixed
- testThrowsExceptionWhenFailsToParseJsonResponse() : mixed
- testThrowsExceptionWhenFailsToParseXmlResponse() : mixed
- hasSubscriber() : bool
- Check if an event dispatcher has a subscriber
- getResponse() : Response
Properties
$mockObserver
public
mixed
$mockObserver
$server
public
static mixed
$server
$serviceBuilder
public
static mixed
$serviceBuilder
$mockBasePath
protected
static mixed
$mockBasePath
$response
protected
Response
$response
The response object to test
$requests
private
mixed
$requests
= array()
Methods
addMockedRequest()
Mark a request as being mocked
public
addMockedRequest(RequestInterface $request) : self
Parameters
- $request : RequestInterface
Return values
self —assertContainsIns()
Case insensitive assertContains
public
assertContainsIns(string $needle, string $haystack[, string $message = null ]) : mixed
Parameters
- $needle : string
-
Search string
- $haystack : string
-
Search this
- $message : string = null
-
Optional failure message
Return values
mixed —compareHeaders()
Compare HTTP headers and use special markup to filter values A header prefixed with '!' means it must not exist A header prefixed with '_' means it must be ignored A header value of '*' means anything after the * will be ignored
public
compareHeaders(array<string|int, mixed> $filteredHeaders, array<string|int, mixed> $actualHeaders) : array<string|int, mixed>|bool
Parameters
- $filteredHeaders : array<string|int, mixed>
-
Array of special headers
- $actualHeaders : array<string|int, mixed>
-
Array of headers to check against
Return values
array<string|int, mixed>|bool —Returns an array of the differences or FALSE if none
getMockedRequests()
Get all of the mocked requests
public
getMockedRequests() : array<string|int, mixed>
Return values
array<string|int, mixed> —getMockResponse()
Get a mock response for a client by mock file name
public
getMockResponse(string $path) : Response
Parameters
- $path : string
-
Relative path to the mock response file
Return values
Response —getServer()
Get the global server object used throughout the unit tests of Guzzle
public
static getServer() : Server
Return values
Server —getServiceBuilder()
Get a service builder object that can be used throughout the service tests
public
static getServiceBuilder() : ServiceBuilder
Return values
ServiceBuilder —getWildcardObserver()
Get a wildcard observer for an event dispatcher
public
getWildcardObserver(HasDispatcherInterface $hasDispatcher) : MockObserver
Parameters
- $hasDispatcher : HasDispatcherInterface
Return values
MockObserver —setMockBasePath()
Set the mock response base path
public
static setMockBasePath(string $path) : GuzzleTestCase
Parameters
- $path : string
-
Path to mock response folder
Return values
GuzzleTestCase —setMockResponse()
Set a mock response from a mock file on the next client request.
public
setMockResponse(Client $client, string $paths) : MockPlugin
This method assumes that mock response files are located under the Command/Mock/ directory of the Service being tested (e.g. Unfuddle/Command/Mock/). A mock response is added to the next request sent by the client.
Parameters
- $client : Client
-
Client object to modify
- $paths : string
-
Path to files within the Mock folder of the service
Return values
MockPlugin —returns the created mock plugin
setServiceBuilder()
Set the service builder to use for tests
public
static setServiceBuilder(ServiceBuilderInterface $builder) : mixed
Parameters
- $builder : ServiceBuilderInterface
-
Service builder
Return values
mixed —setup()
public
setup() : mixed
Return values
mixed —tearDown()
public
tearDown() : mixed
Return values
mixed —test__toString()
public
test__toString() : mixed
Return values
mixed —testCalculatesAge()
public
testCalculatesAge() : mixed
Return values
mixed —testCalculatesFreshness()
public
testCalculatesFreshness() : mixed
Return values
mixed —testComparesContentType()
public
testComparesContentType() : mixed
Return values
mixed —testConstructor()
public
testConstructor() : mixed
Return values
mixed —testDeterminesIfItCanBeCached()
public
testDeterminesIfItCanBeCached() : mixed
Return values
mixed —testDeterminesIfItCanValidate()
public
testDeterminesIfItCanValidate() : mixed
Return values
mixed —testDeterminesResponseMaxAge()
public
testDeterminesResponseMaxAge() : mixed
Return values
mixed —testFactory()
public
testFactory() : mixed
Return values
mixed —testFactoryCanCreateHeadResponses()
public
testFactoryCanCreateHeadResponses() : mixed
Return values
mixed —testFactoryRequiresMessage()
public
testFactoryRequiresMessage() : mixed
Return values
mixed —testGetAcceptRanges()
public
testGetAcceptRanges() : mixed
Return values
mixed —testGetAllow()
public
testGetAllow() : mixed
Return values
mixed —testGetBody()
public
testGetBody() : mixed
Return values
mixed —testGetCacheControl()
public
testGetCacheControl() : mixed
Return values
mixed —testGetContentDisposition()
public
testGetContentDisposition() : mixed
Return values
mixed —testGetContentEncoding()
public
testGetContentEncoding() : mixed
Return values
mixed —testGetContentLanguage()
public
testGetContentLanguage() : mixed
Return values
mixed —testGetContentLength()
public
testGetContentLength() : mixed
Return values
mixed —testGetContentLocation()
public
testGetContentLocation() : mixed
Return values
mixed —testGetContentMd5()
public
testGetContentMd5() : mixed
Return values
mixed —testGetContentRange()
public
testGetContentRange() : mixed
Return values
mixed —testGetContentType()
public
testGetContentType() : mixed
Return values
mixed —testGetDate()
public
testGetDate() : mixed
Return values
mixed —testGetEtag()
public
testGetEtag() : mixed
Return values
mixed —testGetExpires()
public
testGetExpires() : mixed
Return values
mixed —testGetLastModified()
public
testGetLastModified() : mixed
Return values
mixed —testGetLocation()
public
testGetLocation() : mixed
Return values
mixed —testGetMessage()
public
testGetMessage() : mixed
Return values
mixed —testGetMultipleSetCookie()
public
testGetMultipleSetCookie() : mixed
Return values
mixed —testGetPragma()
public
testGetPragma() : mixed
Return values
mixed —testGetProxyAuthenticate()
public
testGetProxyAuthenticate() : mixed
Return values
mixed —testGetRawHeaders()
public
testGetRawHeaders() : mixed
Return values
mixed —testGetServer()
public
testGetServer() : mixed
Return values
mixed —testGetSetCookie()
public
testGetSetCookie() : mixed
Return values
mixed —testGetSetCookieNormalizesHeaders()
public
testGetSetCookieNormalizesHeaders() : mixed
Return values
mixed —testGetTrailer()
public
testGetTrailer() : mixed
Return values
mixed —testGetTransferEncoding()
public
testGetTransferEncoding() : mixed
Return values
mixed —testGetVary()
public
testGetVary() : mixed
Return values
mixed —testGetWarning()
public
testGetWarning() : mixed
Return values
mixed —testHandlesProtocols()
public
testHandlesProtocols() : mixed
Return values
mixed —testHandlesStatusAndStatusCodes()
public
testHandlesStatusAndStatusCodes() : mixed
Return values
mixed —testHasTransferInfo()
public
testHasTransferInfo() : mixed
Return values
mixed —testIsClientError()
public
testIsClientError() : mixed
Return values
mixed —testIsError()
public
testIsError() : mixed
Return values
mixed —testIsInformational()
public
testIsInformational() : mixed
Return values
mixed —testIsRedirect()
public
testIsRedirect() : mixed
Return values
mixed —testIsServerError()
public
testIsServerError() : mixed
Return values
mixed —testIsSuccessful()
public
testIsSuccessful() : mixed
Return values
mixed —testManagesStatusCode()
public
testManagesStatusCode() : mixed
Return values
mixed —testParsesJsonResponses()
public
testParsesJsonResponses() : mixed
Return values
mixed —testParsesXmlResponses()
public
testParsesXmlResponses() : mixed
Return values
mixed —testPreventsComplexExternalEntities()
public
testPreventsComplexExternalEntities() : mixed
Return values
mixed —testResponseDeterminesIfMethodIsAllowedBaseOnAllowHeader()
public
testResponseDeterminesIfMethodIsAllowedBaseOnAllowHeader() : mixed
Return values
mixed —testResponseIsSerializable()
public
testResponseIsSerializable() : mixed
Return values
mixed —testReturnsConnectionHeader()
public
testReturnsConnectionHeader() : mixed
Return values
mixed —testReturnsHeaders()
public
testReturnsHeaders() : mixed
Return values
mixed —testReturnsViaHeader()
public
testReturnsViaHeader() : mixed
Return values
mixed —testReturnsWwwAuthenticateHeader()
public
testReturnsWwwAuthenticateHeader() : mixed
Return values
mixed —testThrowsExceptionWhenFailsToParseJsonResponse()
public
testThrowsExceptionWhenFailsToParseJsonResponse() : mixed
Tags
Return values
mixed —testThrowsExceptionWhenFailsToParseXmlResponse()
public
testThrowsExceptionWhenFailsToParseXmlResponse() : mixed
Tags
Return values
mixed —hasSubscriber()
Check if an event dispatcher has a subscriber
protected
hasSubscriber(HasDispatcherInterface $dispatcher, EventSubscriberInterface $subscriber) : bool
Parameters
- $dispatcher : HasDispatcherInterface
- $subscriber : EventSubscriberInterface
Return values
bool —getResponse()
private
getResponse(mixed $code[, array<string|int, mixed> $headers = null ][, EntityBody $body = null ]) : Response
Parameters
- $code : mixed
- $headers : array<string|int, mixed> = null
- $body : EntityBody = null