Very simple mock HTTP Server for testing Restful API, running via Docker.

Related tags

Testing httpdock
Overview

httpdock

Very simple mock HTTP Server for testing Restful API, running via Docker.

Start Server

Starting this server via command:

docker run -ti -d -p 8080:80 voduytuan/httpdock

Above command will serve HTTP Restful request at port 8080. You can change port 8080 to another port if this port had already used on your host.

Usage

After starting, this web server will expose url /v1/mocks. Request to http://localhost:8080/v1/mocks will get response. This endpoint accepts HTTP Method GET, POST, PUT, DELETE and OPTIONS.

Query parameters:

This API support following query parameters:

  • status: return HTTP Status code with this value. Eg: /v1/mocks?status=201, /v1/mocks?status=404...
  • format: Support 2 format, json (default) and text. Eg: /v1/mocks?format=text
  • size: payload size (in byte), in case you want to receive long length response. Eg: /v1/mocks?size=1024
  • delay: response delay (in microsecond). Eg: /v1/mocks?delay=2000000 (this response will delay 2 seconds = 2.000.000 microseconds)

You can use one or all parameters in one request. Eg: /v1/mocks?status=422&format=json&size=2048&delay=300000...

Source code

Source code of this project hosted at [https://github.com/voduytuan/httpdock]. This project is developed in Slim Framework v4, and running with Apache & PHP 8. You can customize service behaviors in file ./public/index.php and build your own docker image (eg: docker build . -t your-image).

You might also like...
A video course for laravel artisan to learn creating API using testing

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

The modern, simple and intuitive PHP unit testing framework.

atoum PHP version atoum version 5.3 - 5.6 1.x - 3.x 7.2 - 8.x 4.x (current) A simple, modern and intuitive unit testing framework for PHP! Just lik

Essence is a very flexible BDD style assertion framework for PHP that fits into existing PHPUnit projects nicely

Essence 1.5.1 Essence is a very flexible BDD style assertion framework for PHP that fits into existing PHPUnit projects nicely. Installation composer

Allows the running of PHPUnit within ExpressionEngine

EE Unit Tests EE Unit Tests is an Add-on for ExpressionEngine that allows developers to execute unit tests from the Command Line. EE Unit Tests uses P

A tool to run migrations prior to running tests

cakephp-test-migrator A tool to run migrations prior to running tests The Migrator For CakePHP 3.x composer require --dev vierge-noire/cakephp-test-mi

Satisfy the Type APIs for the WordPress schema when running PHPUnit tests

Satisfy the Type APIs for the WordPress schema when running PHPUnit tests

Full-stack testing PHP framework

Codeception Modern PHP Testing for everyone Codeception is a modern full-stack testing framework for PHP. Inspired by BDD, it provides an absolutely n

AST based PHP Mutation Testing Framework

Infection - Mutation Testing framework Please read documentation here: infection.github.io Twitter: @infection_php Discord: https://discord.gg/ZUmyHTJ

:computer: Parallel testing for PHPUnit

ParaTest The objective of ParaTest is to support parallel testing in PHPUnit. Provided you have well-written PHPUnit tests, you can drop paratest in y

Owner
Vo Duy Tuan
CEO/Founder
Vo Duy Tuan
SimpleTest is a framework for unit testing, web site testing and mock objects for PHP

SimpleTest SimpleTest is a framework for unit testing, web site testing and mock objects for PHP. Installation Downloads All downloads are stored on G

SimpleTest 147 Jun 20, 2022
Mock HTTP requests on the server side in your PHP unit tests

HTTP Mock for PHP Mock HTTP requests on the server side in your PHP unit tests. HTTP Mock for PHP mocks the server side of an HTTP request to allow in

InterNations GmbH 386 Dec 27, 2022
Mock implementation of the Translation package, for testing with PHPUnit

PoP Translation - Mock Mock implementation of the Translation package, for testing with PHPUnit Install Via Composer composer require getpop/translati

PoP 1 Jan 13, 2022
CommandHelper - is a very useful thing for quick code testing and more!

CommandHelper CommandHelper - is a very useful thing for quick code testing and more! Examples: Code: require_once('commandhelper.php');

RuvSleep 1 Feb 11, 2022
A simple way to mock a client

Mocked Client A simple way to mock a client Install Via Composer $ composer require doppiogancio/mocked-client guzzlehttp/guzzle php-http/discovery No

Fabrizio Gargiulo 17 Oct 5, 2022
PHP unit testing framework with built in mocks and stubs. Runs in the browser, or via the command line.

Enhance PHP A unit testing framework with mocks and stubs. Built for PHP, in PHP! Quick Start: Just add EnhanceTestFramework.php and you are ready to

Enhance PHP 67 Sep 12, 2022
Mock built-in PHP functions (e.g. time(), exec() or rand())

PHP-Mock: mocking built-in PHP functions PHP-Mock is a testing library which mocks non deterministic built-in PHP functions like time() or rand(). Thi

null 331 Jan 3, 2023
vfsStream is a stream wrapper for a virtual file system that may be helpful in unit tests to mock the real file system. It can be used with any unit test framework, like PHPUnit or SimpleTest.

vfsStream vfsStream is a stream wrapper for a virtual file system that may be helpful in unit tests to mock the real file system. It can be used with

null 1.4k Dec 23, 2022
Mockery - Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library

Mockery Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its c

Mockery 10.3k Jan 1, 2023
A sample RESTful API in Laravel with PHPunit test.

Laravel PHP Framework URL | URI | Action |

Fasil 9 Jul 11, 2020