Fork me on Github!
Boomerang!

Documentation Overview

For more information view the full api documentation.

Making a Request

The first step in surface testing your API is making the request. That is done with the HttpRequest object.

<?php
namespace Boomerang;

class HttpRequest {
	public const GET = "GET";
	public const POST = "POST";
	public const PUT = "PUT";
	public const PATCH = "PATCH";
	public const DELETE = "DELETE";
	public const TRACE = "TRACE";
	public const OPTIONS = "OPTIONS";
}

Method: HttpRequest->__construct

function __construct($endpoint [, \Boomerang\Factories\HttpResponseFactory $responseFactory = null])
Parameters:

Method: HttpRequest->setMethod

function setMethod($method)

Set the request method.

Helper constants exist, for example
$req->setMethod(HttpRequest::POST);  
Parameters:

Method: HttpRequest->setUrlParam

function setUrlParam($param, $value)

Set a url param by name.

Parameters:

Method: HttpRequest->setUrlParams

function setUrlParams(array $params)

Set outgoing params as an array of ParamName => Value

Parameters:

Method: HttpRequest->setHeader

function setHeader($key, $value)

Set an outgoing header by name.

Parameters:

Method: HttpRequest->setHeaders

function setHeaders(array $headers)

Set outgoing headers as an array of HeaderName => Value

Parameters:

Method: HttpRequest->setBasicAuth

function setBasicAuth($username [, $password = ''])

Set outgoing basic auth header.

Parameters:

Method: HttpRequest->setFormValue

function setFormValue($key, $value)

Set a named key of the form values

Note that if there is a non-form body set, this will replace it.

Parameters:

Method: HttpRequest->setBody

function setBody($body)

Set the requests body

Parameters:

Method: HttpRequest->setCookiesFollowRedirects

function setCookiesFollowRedirects($bool)

Allows you to enable cookie’s set by server re-posting following a redirect.

Requires file system storage of a “cookie jar” file and is therefore disabled by default.

Parameters:

Method: HttpRequest->setCookies

function setCookies(array $cookies)

Set outgoing cookies as an array of CookieName => Value

Parameters:

Method: HttpRequest->setCookie

function setCookie($key, $value)

Set a named cookies outgoing value

Parameters:

Method: HttpRequest->setEndpoint

function setEndpoint($endpoint)

Sets the request URI

Parameters:

Method: HttpRequest->makeRequest

function makeRequest()

Execute the request


Method: HttpRequest->setMaxRedirects

function setMaxRedirects($maxRedirects)

Set the maximum number of redirects(hops) a request should follow.

Parameters:

Validating API Expectations

Validators are used to define your expectations for the response.


Method: HttpResponseValidator->expectStatus

function expectStatus([ $expected_status = 200 [, $hop = null]])

Verify that the HTTP response code is as expected.

Parameters:

Method: HttpResponseValidator->expectHeader

function expectHeader($key, $value [, $hop = null])

Verify that a header field equals an expected value.

Parameters:

Method: HttpResponseValidator->expectHeaderContains

function expectHeaderContains($key, $value [, $hop = null])

Verify that a header field contains an expected value.

For example, checking the header Content-Type for “json” would match a response of “application/json”

Parameters:

Method: HttpResponseValidator->expectBody

function expectBody($expectedContent)

Verify that the content body equals an expected value.

Parameters:

Method: HttpResponseValidator->expectBodyContains

function expectBodyContains($expectedContent)

Verify that the content body contains an expected value.

Parameters:

Method: HttpResponseValidator->expectHopCount

function expectHopCount($expectedCount)

Verify the number of redirection hops is as expected.

Parameters: