2017 © Pedro Peláez
 

library codeception-mountebank

mountebank integration with Codeception

image

meare/codeception-mountebank

mountebank integration with Codeception

  • Thursday, March 2, 2017
  • by meare
  • Repository
  • 2 Watchers
  • 5 Stars
  • 1,211 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 4 % Grown

The README.md

codeception-mountebank

Latest Version on Packagist ![Software License][ico-license] Quality Score ![Total Downloads][ico-downloads], (*1)

codeception-mountebank provides mountebank integration with Codeception. Module allows to:, (*2)

  • Configure imposters required for tests run;
  • Use imposters as mocks and verify specific requests were made;
  • Save imposters after run for debugging purposes;

Module uses Juggler to interact with mountebank and it's possible to take complete control on mountebank in your custom helper classes or modules., (*3)

Note that only HTTP imposters are currently supported., (*4)

Install

Require module via Composer:, (*5)

``` bash $ composer require meare/codeception-mountebank, (*6)


## Configuration Module should be enabled and configured in suite configuration file ``` yaml class_name: AcceptanceTester modules: enabled: - Mountebank config: Mountebank: # mountebank host # Required host: 'localhost' # Port mountebank listens on # 2525 by default port: 2525 # Imposters configuration # All previous imposters are deleted before the run imposters: # Imposter alias xyz: # Path to imposter contract # Required contract: '_data/mountebank/xyz/stub.json' # Set this property to save imposter contract after tests run # Property value is path to save contract to save: '_output/mountebank/xyz/stub.json' # Set to true if imposter is used as mock # Mock imposters are restored from original contract after each test # Default: false mock: true

Usage

Mock verification

mountebank should be started with --mock flag to use mocking, (*7)

» mountebank docs on mocking, (*8)

Imposters mock property should be set to true in suite configuration. It guarantees that imposter will be restored before each test. Restoring means deleting existing imposter from mountebank and posting contract from configuration. This is done to clean requests imposter recorded., (*9)

Module provides 3 methods to verify mock imposter:, (*10)

seeImposterHasRequests($alias)

Asserts that there was at least 1 request recorded on imposter, (*11)

seeImposterHasRequestsByCriteria($alias, $criteria)

Asserts that there was at least 1 request that satisfies criteria recorded on imposter., (*12)

If $criteria is array then request is considered matching if $criteria is subarray of request, e.g.:, (*13)

``` php $I->seeImposterHasRequestsByCriteria('xyz', [ 'method' => 'GET', 'query' => [ 'account_id' => '7' ] ]), (*14)


``` yaml { "protocol": "http", "port": 4646, "numberOfRequests": 1, "name": "xyz", "requests": [ { "requestFrom": "::ffff:127.0.0.1:57484", "method": "GET", "path": "/balance", "query": { "account_id": "7", "currency": "USD", }, "headers": { "Host": "localhost", "Connection": "close" }, "body": "", "timestamp": "2017-01-12T16:03:07.632Z" } ] }

More complex criteria could be expressed as callback. Callback signature is:, (*15)

/**
 * @var string $request decoded request object from contract JSON.
 *
 * @return bool Whether requests matches
 */
function(array $request) {}

Callback will be called for each request imposter has until true is returned., (*16)

seeImposterHasNoRequests($alias)

Asserts that there is no requests recorded on imposter., (*17)

Change log

Please see CHANGELOG for more information on what has changed recently., (*18)

Testing

bash $ composer test, (*19)

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*20)

Credits

License

The MIT License (MIT). Please see License File for more information., (*21)

The Versions

02/03 2017

dev-master

9999999-dev https://github.com/meare/mountebank-codeception

mountebank integration with Codeception

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrejs Mironovs

testing codeception mountebank codecept juggler

29/01 2017

v1.0

1.0.0.0 https://github.com/meare/mountebank-codeception

mountebank integration with Codeception

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrejs Mironovs

testing codeception mountebank codecept juggler