PHP Classes
elePHPant
Icontem

PHP Mock HTTP Server: Test HTTP requests with configurable responses

Recommend this page to a friend!
  Info   View files Example   View files View files (15)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-05-08 (19 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 56 This week: 2All time: 9,473 This week: 203Up
Version License PHP version Categories
http_request_mock_se 1.0GNU Lesser Genera...5HTTP, PHP 5, Testing
Description Author

This package can test HTTP requests with configurable responses.

There is a factory class that can handle HTTP requests from a real HTTP server that executes a PHP script that class.

The factory class creates the actual mock object that will process the HTTP request and generates the HTTP response.

Separate classes define the strategy to handle the requests generating responses in XML, JSON or some other raw format based on parameters taken from the request URI.

  Performance   Level  
Name: nvb <contact>
Classes: 7 packages by
Country: Germany Germany
Innovation award
Innovation award
Nominee: 3x

Details

Http Test Request Server

This component should easy up your testing. It can also be used as a mocked endpoint.

The current change log can be found here. The latest stable release is Latest stable

Benefits

Supported GET parameters

content

Url encoded string.

format

One of the following three:

  • json
  • raw
  • xml

status_code

Any number is working.

Example

Returning JSON

Url with all available and supported get parameters

?format=json&content=%7B%22foo%22%3A+%22bar%22%7D

will return

{"foo":"bar"}

Returning RAW

Url with all available and supported get parameters

?format=raw&content=There+is+no+foo+without+a+bar

will return

There is no foo without a bar

Returning XML

Url with all available and supported get parameters

?format=xml&content=<foo>bar<%2Ffoo>

will return

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xml>
<foo>bar</foo>
</xml>

Mature Projects

This project has a small number of source lines of code (less than 127 lines of code without the syntactic sugar). It is just a small thing you can use. There are a lot of mature projects out there like http-server-mock to name just one.

Final Words

Star it if you like it :-). Add issues if you need it. Pull patches if you enjoy it. Write a blog entry if you use it. Donate something if you love it :-].

  Files folder image Files  
File Role Description
Files folder imagepublic (1 file)
Files folder imagesource (2 files, 2 directories)
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  public  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  source  
File Role Description
Files folder imageContent (4 files)
Files folder imageOutput (4 files)
  Plain text file HttpRequestMockServer.php Class Class source
  Plain text file HttpRequestMockServerFactory.php Class Class source

  Files folder image Files  /  source  /  Content  
File Role Description
  Plain text file DefaultContentBuilder.php Class Class source
  Plain text file DefaultProvidedCon...HandlerStrategy.php Class Class source
  Plain text file ProvidedContentHan...rategyInterface.php Class Class source
  Plain text file RawProvidedContentHandlerStrategy.php Class Class source

  Files folder image Files  /  source  /  Output  
File Role Description
  Plain text file JsonOutputStrategy.php Class Class source
  Plain text file OutputStrategyInterface.php Class Class source
  Plain text file RawOutputStrategy.php Class Class source
  Plain text file XmlOutputStrategy.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:56
This week:2
All time:9,473
This week:203Up