2017 © Pedro PelĂĄez
 

project phpacto

Contract testing tool integrated with Guzzle and Phpunit

image

bigfoot90/phpacto

Contract testing tool integrated with Guzzle and Phpunit

  • Monday, April 30, 2018
  • by bigfoot
  • Repository
  • 1 Watchers
  • 1 Stars
  • 48 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 8 Open issues
  • 10 Versions
  • 17 % Grown

The README.md

PHPacto

Contract testing solution for your API's and microservices, (*1)

If you want to know more about Contract Testing please read more here and here., (*2)

License Build Status CodeCov Scrutinizer Quality Score Codacy Quality Grade Latest Stable Version Total Downloads, (*3)

Docker Build Status Docker Image Size Docker Pulls Docker Stars, (*4)

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., (*5)

You can find some contract examples in examples directory., (*6)

Usage standalone CLI

First of all clone this repository git clone git@github.com:PHPacto/PHPacto.git and install vendors with composer composer install., (*7)

Validate

Validate your contracts with, (*8)

bin/phpacto validate path-to/directory-or-single-file

cURL command generator

Generate cURL commands from contracts with, (*9)

bin/phpacto curl path-to/directory-or-single-file

SUGGESTION: Can use phpdotenv to load environment variables from file., (*10)

Usage with Docker

Validate

Validate your contracts with, (*11)

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, (*12)

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, (*13)

Mock Proxy Recorder

See https://github.com/PHPacto/recorder, (*14)

Testing your application

Compatibility table , (*15)

PHPacto PHP PHPUnit Guzzle Symfony Serializer
0.5.4 >=7.2 `^7.0 ^8.0||^9.0|>=5.3.1|>=3.3`
1.0.0 >=8.2 `^7.0 ^8.0||^9.0|>=6.0|>=7.0`

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., (*16)

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:, (*17)

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, (*18)

Mastering with PHPacto contract Rules

Read the dedicated page here, (*19)

Contributing

Feel free to contribute by opening a pull request. Bug fixes or feature suggestions are always welcome., (*20)

The Versions

30/04 2018