2017 © Pedro Peláez
 

library test-server

Create a simple HTTP server on your local environment capable of handling responses for test purposes

image

makeweb/test-server

Create a simple HTTP server on your local environment capable of handling responses for test purposes

  • Tuesday, April 24, 2018
  • by MakeWeb
  • Repository
  • 2 Watchers
  • 22 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 3 Versions
  • 8 % Grown

The README.md

MakeWeb Test Server

Test code which sends HTTP requests by spinning up an actual HTTP server on your local environment., (*1)

The server serves a basic Lumen app served with PHP's built in development web server. You can then define the behaviour of the test server by adding routes with closures right in your test code. This way we can keep the test code which relies on specific server behaviour tightly coupled with the code which defines the behaviour., (*2)

The idea and original code was forked from the implementation of a web server for testing KiteTail's Zttp library by Adam Wathan. Do check out Zttp, and KiteTail., (*3)

Installation

Install with Composer

composer require makeweb/test-server

Basic usage


<?php use PHPUnit\Framework\TestCase; use MakeWeb\TestServer\TestServer; use Zttp\Zttp; class MyExampleTest extends TestCase { /** @test */ public function a_get_request_to_add_route_returns_sum_of_a_and_b_parameters_as_result() { // Set up how we want the test server to respond (new TestServer)->withRoute('get', 'add', function ($request) { return response()->json(['result' => (int) $request->a + (int) $request->b]); })->start(); $response = Zttp::get('add', ['a' => 1, 'b' => 2]); $this->assertEquals(3, $response->result); } }

The Versions

24/04 2018

dev-master

9999999-dev

Create a simple HTTP server on your local environment capable of handling responses for test purposes

  Sources   Download

MIT

The Requires

 

by Andrew Feeney

24/04 2018

dev-WebSpanner-add-code-highlighting

dev-WebSpanner-add-code-highlighting

Create a simple HTTP server on your local environment capable of handling responses for test purposes

  Sources   Download

MIT

The Requires

 

by Andrew Feeney

23/04 2018

1.0.0

1.0.0.0

Create a simple HTTP server on your local environment capable of handling responses for test purposes

  Sources   Download

MIT

The Requires

 

by Andrew Feeney