PHP Classes

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    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 69 This week: 1All time: 10,266 This week: 560Up
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.

Picture of nvb
  Performance   Level  
Name: nvb <contact>
Classes: 20 packages by
Country: Germany Germany
Age: ???
All time rank: 150195 in Germany Germany
Week rank: 106 Up5 in Germany Germany Up
Innovation award
Innovation award
Nominee: 12x

Winner: 1x

Example

<?php
/**
 * @author stev leibelt <artodeto@bazzline.net>
 * @since 2015-12-14
 */

use Net\Bazzline\HttpRequestMockServer\HttpRequestMockServerFactory;

require_once
__DIR__ . '/../vendor/autoload.php';

$factory = new HttpRequestMockServerFactory();

$factory->create()->execute();


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:69
This week:1
All time:10,266
This week:560Up