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 {
    const GET = "GET";
    const POST = "POST";
    const PUT = "PUT";
    const PATCH = "PATCH";
    const DELETE = "DELETE";
    const TRACE = "TRACE";
    const OPTIONS = "OPTIONS";
}

Method: HttpRequest->__construct

function __construct($endpoint [, $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($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($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($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 expecations 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:

Method: JSONValidator->expectStructure

function expectStructure($structure)

Verify that the data matches the passed expected structure definition.

Parameters: