2017 © Pedro Peláez
 

library assert-psr-response

PHP package with class to assert PSR responses

image

fefas/assert-psr-response

PHP package with class to assert PSR responses

  • Sunday, January 14, 2018
  • by fefas
  • Repository
  • 1 Watchers
  • 0 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Build Status Coverage, (*1)

Stable Version Downloads PHP Version License, (*2)

Assert PSR Response

This composer package aims to provide an easy way to assert PSR-7 responses., (*3)

Motivation

I created this package because my constant need of asserting only certain values of PSR responses during acceptance tests., (*4)

Installation

Install it using Composer:, (*5)

$ composer require bauhaus/assert-psr-response

Usage

<?php

use Bauhaus\PsrResponseAssertion\PsrResponseAssertion;
use Bauhaus\PsrResponseAssertion\Matchers\HeaderLine;
use Bauhaus\PsrResponseAssertion\Matchers\StatusCode;

$assertion = PsrResponseAssertion::with(
   StatusCode::equalTo(200),
   HeaderLine::equalTo('Content-Type', 'application/json')
);

$psrResponse = // retrieve it from somewhere ...
$psrResponse = $psrResponse
   ->withStatus(404)
   ->withHeader('Content-Type', 'text/html');

$assertion->assert($psrResponse);
// throw PsrResponseAssertionException with message:
// Actual response status code '404' is not equal to the expected '200'
// Actual response header line 'Content-Type' 'text/html' is not equal to the expected 'application/json'

Available Matchers

  • StatusCode::equalTo(200)
  • HeaderLine::equalTo('Header-Name', 'Header-Value')
  • JsonBody::equalTo('{"field":"value"}')

Contribution

There is two ways to contribute with this project. The first one is by opening an issue here. The second one is by coding:, (*6)

  1. Fork this project and clone it on your local dev environment
  2. Install dependencies throught the command: composer install
  3. Run the locally tests before ubmiting a pull request:
    • To test code standards: composer run test:cs
    • To run unit tests: composer run test:unit
    • To run all tests in a roll: composer run tests

The Versions

14/01 2018

dev-master

9999999-dev

PHP package with class to assert PSR responses

  Sources   Download

MIT

The Requires

 

The Development Requires

14/01 2018

v0.2.0

0.2.0.0

PHP package with class to assert PSR responses

  Sources   Download

MIT

The Requires

 

The Development Requires

07/01 2018

v0.1.0

0.1.0.0

PHP package with class to assert PSR responses

  Sources   Download

MIT

The Requires

 

The Development Requires

07/01 2018

v0.0.0

0.0.0.0

PHP package with class to assert PSR responses

  Sources   Download

MIT

The Requires