https://github.com/peridot-php/leo-http-foundation
A leo extension for writing assertions against HttpFoundation
https://github.com/peridot-php/leo-http-foundation
Last synced: 12 months ago
JSON representation
A leo extension for writing assertions against HttpFoundation
- Host: GitHub
- URL: https://github.com/peridot-php/leo-http-foundation
- Owner: peridot-php
- Created: 2014-12-21T20:58:25.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2019-10-30T15:59:14.000Z (over 6 years ago)
- Last Synced: 2025-06-03T21:34:44.830Z (about 1 year ago)
- Language: PHP
- Homepage: http://peridot-php.github.io/leo/
- Size: 171 KB
- Stars: 4
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#Leo Http Foundation
[Leo](http://peridot-php.github.io/leo/) assertions for use with [HttpFoundation](http://symfony.com/doc/current/components/http_foundation/introduction.html)
[](https://travis-ci.org/peridot-php/leo-http-foundation)
[](https://scrutinizer-ci.com/g/peridot-php/leo-http-foundation/?branch=master)
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.
```php
$assertion = Leo::assertion();
$assertion->extend(new LeoHttpFoundation());
```
##Assertions
###->allow(methods, [message])
* @param `array` $methods
* @param `string` $message [optional]
Checks that the Allowed header is present on the response and that it
contains **all** values passed in the `methods` array.
```php
expect($response)->to->allow(['POST', 'GET']);
expect($response)->to->not->allow(['GET']);
```
###->status(status, [message])
* @param `int` $status
* @param `string` $message [optional]
Asserts that the response status is equal to `status`.
```php
expect($response)->to->have->status(200);
expect($response)->to->not->have->status(400);
```
###->json
* @param `bool` $assoc [optional]
* @param `int` $depth [optional]
* @param `int` $options [optional]
A language chain that parses the response body as json and sets it as the subject
of the assertion chain. The options parameters for json_decode() may
also be included.
```php
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);
```