bigfoot90 / phpacto
Contract testing tool integrated with Guzzle and Phpunit
Requires
- php: >=7.2
- http-interop/http-factory-discovery: ^1.5
- symfony/console: >=2.5
- symfony/finder: >=2.1
- symfony/routing: >=2.1
- symfony/serializer: >=3.3,<7
- symfony/yaml: >=2.0
Requires (Dev)
- ext-json: *
- guzzlehttp/guzzle: >=5.3.1
- laminas/laminas-diactoros: ^2.0|^3.0
- mikey179/vfsstream: ^1.6.7
- namshi/cuzzle: >=1.0
- nyholm/psr7: ^1.8
- phpunit/phpunit: ^8.0|^9.0
- symfony/polyfill-php72: ^1.22
- symfony/polyfill-php73: ^1.22
- symfony/polyfill-php74: ^1.22
- symfony/polyfill-php80: ^1.22
- symfony/polyfill-php81: ^1.22
- symfony/polyfill-php82: ^1.22
- symfony/polyfill-php83: ^1.22
- symfony/psr-http-message-bridge: ^2.3
- yoast/phpunit-polyfills: ^2.0
Suggests
- namshi/cuzzle: Generates cUrl command out of you PHPacto contracts
- phpunit/phpunit: Integration with PHPUnit testing framework
- dev-master
- 1.0.1
- 1.0.0
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.6
- 0.4.5
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.23
- 0.1.22
- 0.1.21
- 0.1.20
- 0.1.19
- 0.1.18
- 0.1.17
- 0.1.16
- 0.1.15
- 0.1.14
- 0.1.13
- 0.1.12
- 0.1.11
- 0.1.10
- 0.1.9
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-upgrade
- dev-swagger-integration
This package is auto-updated.
Last update: 2024-12-14 07:13:47 UTC
README
Contract testing solution for your API's and microservices
If you want to know more about Contract Testing please read more here and here.
DISCLAIMER: This is a work in progress. The code can be subject to any changes without BC until the release version
1.0.0
. Please use the issue tracker to report any enhancements or issues you encounter.
You can find some contract examples in examples
directory.
Usage standalone CLI
First of all clone this repository git clone git@github.com:PHPacto/PHPacto.git
and install vendors with composer composer install
.
Validate
Validate your contracts with
bin/phpacto validate path-to/directory-or-single-file
cURL command generator
Generate cURL commands from contracts with
bin/phpacto curl path-to/directory-or-single-file
SUGGESTION: Can use phpdotenv to load environment variables from file.
Usage with Docker
Validate
Validate your contracts with
docker run -it --rm \
-v $PWD/contracts:/srv/data \
-e CONTRACTS_DIR=data \
-p 8000:8000 \
phpacto/mock-server \
validate
cURL command generator
Generate cURL commands from contracts with
docker run -it --rm \
-v $PWD/contracts:/srv/data \
-e CONTRACTS_DIR=data \
-p 8000:8000 \
phpacto/mock-server \
curl
Server Mock
See https://github.com/PHPacto/mock-server
Mock Proxy Recorder
See https://github.com/PHPacto/recorder
Testing your application
Compatibility table
If your project satisfies these requirements, you can run composer require --dev bigfoot90/phpacto
and test
your contracts with phpunit, else you need to run contracts testing with PHPacto's CLI wich is slower but works with any kind of application.
Integration with PHPUnit
If your test ends with too much verbose tracelog maybe your TestCase is not extending from Bigfoot\PHPacto\Test\PHPUnit\PHPactoTestCase
, so add this line in your setUp
method:
PHPUnit\Util\Blacklist\Blacklist::$blacklistedClassNames[__CLASS__] = 1;
See this Gist https://gist.github.com/bigfoot90/d4f146bacad359329d219a804f6cd12a
There are two different test files ConsumerTest.php
and ProviderTest.php
Mastering with PHPacto contract Rules
Read the dedicated page here
Contributing
Feel free to contribute by opening a pull request. Bug fixes or feature suggestions are always welcome.