krichprollsch / truffade
Programmable API mock server
Installs: 717
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 1
Open Issues: 0
Type:project
Requires
- domraider/rxnet: ^0.6
- symfony/console: ^3.2
- symfony/options-resolver: ^3.2
This package is not auto-updated.
Last update: 2024-09-01 02:31:16 UTC
README
Truffade is an API mock server. It helps you to mock the third party API.
Install
The recommended way to install Truffade is through Composer:
$ composer require krichprollsch/truffade
Usage
Start the server
First you need to start the server
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.
$ 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.
$ 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.
$ 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.
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
License
Truffade is released under the MIT License. See the bundled LICENSE file for details.