Skip to content

Demo code from the talk on Consumer-Driven Contract testing with Pact and PHP

License

Notifications You must be signed in to change notification settings

andykelk/pact-php-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pact-php-demo

Demo code from the talk on Consumer-Driven Contract testing with Pact and PHP

Dependencies

How to use (consumer)

First, set up the consumer:

  • Install Ruby and RubyGems (and ruby header files)
  • Install Node and npm
  • Make sure you're in the consumer directory
  • Install dependencies: npm install
  • Install karma cli: sudo npm install -g karma-cli
  • Install bower: sudo npm install -g bower
  • Install pact JavaScript component: bower install
  • Install bundler: gem install bundler
  • Install pact ruby component: bundle install
  • Run the pact service: bundle exec pact-mock-service -p 1234 -l log/pact.logs --pact-dir tmp/pacts
  • Run the tests (in another terminal): karma start
  • Your pact file is now in tmp/pacts

How to use (provider)

Then set up the provider:

  • Make sure you're in the provider directory
  • Install composer: curl -sS https://getcomposer.org/installer | php
  • Install PHP dependencies: php composer.phar install
  • Install pact: bundle install
  • Install rake: gem install rake
  • Copy the pact file you just created into place: cp ../consumer/tmp/pacts/alligator_consumer-alligator_provider.json ./spec/pacts/
  • Start up the API provider: php -S localhost:8000
  • Now run pact to verify it works (in another terminal): rake pact:verify:alligator

About

Demo code from the talk on Consumer-Driven Contract testing with Pact and PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published