Home

Awesome

#Leo Http Foundation

Leo assertions for use with HttpFoundation

Build Status Scrutinizer Code Quality

This set of assertions is evolving as needed. Please feel free to submit pull requests and make feature requests.

##Usage

You can add HttpFoundation behavior to Leo by extending the Leo assertion property.

$assertion = Leo::assertion();
$assertion->extend(new LeoHttpFoundation());

##Assertions

###->allow(methods, [message])

Checks that the Allowed header is present on the response and that it contains all values passed in the methods array.

expect($response)->to->allow(['POST', 'GET']);
expect($response)->to->not->allow(['GET']);

###->status(status, [message])

Asserts that the response status is equal to status.

expect($response)->to->have->status(200);
expect($response)->to->not->have->status(400);

###->json

A language chain that parses the response body as json and sets it as the subject of the assertion chain. The options parameters for <code>json_decode()</code> may also be included.

expect($response)->json->to->have->property('name');
expect($response)->json->to->loosely->equal($expected);
expect($response)->json(true, 999, JSON_BIGINT_AS_STRING)->to->equal($expected);