2017 © Pedro Peláez
 

project truffade

Programmable API mock server

image

krichprollsch/truffade

Programmable API mock server

  • Friday, August 11, 2017
  • by krichprollsch
  • Repository
  • 1 Watchers
  • 4 Stars
  • 709 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 1 % Grown

The README.md

Truffade

Truffade is an API mock server. It helps you to mock the third party API., (*1)

Install

The recommended way to install Truffade is through Composer:, (*2)

$ composer require krichprollsch/truffade

Usage

Start the server

First you need to start the server, (*3)

php ./vendor/bin/truffade --admin-port=8081 --mock-port=8080

Configure the mock responses

Now you can configure any mock response you want the server returns using the admin port., (*4)

$ curl -XPOST http://127.0.0.1:8081 --data '{"body":{"foo":"bar"}}'
{"total":1,"next":0}

$ curl -XPOST http://127.0.0.1:8081 --data '{"body":{"foo":"baz"}}'
{"total":2,"next":0}

Request the mock server

Then you can use the mock server through you application. The responses will be return into the order of the configuration time., (*5)

$ curl -XGET http://127.0.0.1:8080/foo/bar
{"foo":"bar"}

$ curl -XPOST http://127.0.0.1:8080/what/you/want --data '{"foo"}'
{"foo":"baz"}

If there is no more responses configures, an error is returned., (*6)

$ curl -XPOST http://127.0.0.1:8080/yoohoo
{"err":"not configured yet"}

Consult the requests

The admin server allow you to check the requests send by you application., (*7)

curl -XGET http://127.0.0.1:8081/0
{
    "request": {
        "body": null,
        "headers": {
            "Accept": [
                "*/*"
            ],
            "Host": [
                "127.0.0.1:8080"
            ],
            "User-Agent": [
                "curl/7.50.1"
            ]
        },
        "json": null,
        "method": "GET",
        "path": "/foo/bar",
        "query": "",
        "request": {}
    },
    "response": {
        "foo": "bar"
    }
}

Run test

// TODO

Truffade?

Truffade is a rural dish traditionally associated with Auvergne in France. see Wikipedia, (*8)

License

Truffade is released under the MIT License. See the bundled LICENSE file for details., (*9)

The Versions

11/08 2017

dev-master

9999999-dev

Programmable API mock server

  Sources   Download

MIT

The Requires

 

by Pierre Tachoire

11/08 2017

0.1.3

0.1.3.0

Programmable API mock server

  Sources   Download

MIT

The Requires

 

by Pierre Tachoire

28/03 2017

0.1.2

0.1.2.0

Programmable API mock server

  Sources   Download

MIT

The Requires

 

by Pierre Tachoire

27/03 2017

0.1.1

0.1.1.0

Programmable API mock server

  Sources   Download

MIT

The Requires

 

by Pierre Tachoire