2017 © Pedro Peláez
 

library http-mock

Mocks HTTP calls for tests

image

jfalque/http-mock

Mocks HTTP calls for tests

  • Thursday, March 2, 2017
  • by julienfalque
  • Repository
  • 1 Watchers
  • 1 Stars
  • 12,570 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 60 % Grown

The README.md

HttpMock

Build status Latest Stable Version License, (*1)

A HTTP server mock for automated tests., (*2)

This package is archived and not maintained anymore., (*3)

Testing code that makes HTTP calls is not simple: you either need to setup an actual HTTP server that provides the exact responses your tests require, or create mocks with complex assertions and/or expectations., (*4)

This package provides a server mock that can handle PSR-7 HTTP requests. It also provides a stream wrapper that integrates the server into PHP's filesystem functions like file_get_contents()., (*5)

<?php

use Jfalque\HttpMock\Server;

$server = (new Server())
    ->whenUri('http://foo')
        ->return($foo = new Response())
    ->end()
    ->whenUri('http://bar')
        ->return($bar = new Response())
    ->end()
;

$response = $server->handle(new Request('http://foo')); // $foo
$response = $server->handle(new Request('http://bar')); // $bar
$response = $server->handle(new Request('http://baz')); // null

Installation

Run the following Composer command:, (*6)

$ composer require --dev jfalque/http-mock, (*7)

More information

Read the documentation for more information., (*8)

The Versions

02/03 2017

dev-master

9999999-dev

Mocks HTTP calls for tests

  Sources   Download

MIT

The Requires

 

The Development Requires

test mock http

02/03 2017

dev-test

dev-test

Mocks HTTP calls for tests

  Sources   Download

MIT

The Requires

 

The Development Requires

test mock http

05/02 2017

v1.0.1

1.0.1.0

Mocks HTTP calls for tests

  Sources   Download

MIT

The Requires

 

The Development Requires

test mock http

25/01 2017

v1.0.0

1.0.0.0

Mocks HTTP calls for tests

  Sources   Download

MIT

The Requires

 

The Development Requires

test mock http