PHPackages                             meare/codeception-mountebank - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. meare/codeception-mountebank

AbandonedLibrary[Testing &amp; Quality](/categories/testing)

meare/codeception-mountebank
============================

mountebank integration with Codeception

v1.0(9y ago)82.0k[1 issues](https://github.com/meare/codeception-mountebank/issues)MITPHPPHP &gt;=5.5

Since Jan 29Pushed 9y ago3 watchersCompare

[ Source](https://github.com/meare/codeception-mountebank)[ Packagist](https://packagist.org/packages/meare/codeception-mountebank)[ Docs](https://github.com/meare/mountebank-codeception)[ RSS](/packages/meare-codeception-mountebank/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

codeception-mountebank
======================

[](#codeception-mountebank)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a28662b52e3887985839adf19a13acb30694d20ea531c6fbace153ddfcb268e0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d656172652f636f646563657074696f6e2d6d6f756e746562616e6b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/meare/codeception-mountebank)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Quality Score](https://camo.githubusercontent.com/5c7e71614720ca0b3199ba1ada940f37929e962d266481281cfc88bc8f28f73a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d656172652f636f646563657074696f6e2d6d6f756e746562616e6b2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/meare/codeception-mountebank)[![Total Downloads](https://camo.githubusercontent.com/139b48dd82d82935d9b4501d4bb802c4a9fc2b02ed233c9dac80460965751ad3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d656172652f636f646563657074696f6e2d6d6f756e746562616e6b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/meare/codeception-mountebank)

codeception-mountebank provides [mountebank](http://www.mbtest.org/) integration with [Codeception](http://codeception.com/). Module allows to:

- 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](https://github.com/meare/juggler) to interact with mountebank and it's possible to take complete control on mountebank in your custom helper classes or modules.

Note that only HTTP imposters are currently supported.

Install
-------

[](#install)

Require module via Composer:

```
$ composer require meare/codeception-mountebank
```

Configuration
-------------

[](#configuration)

Module should be enabled and configured in suite configuration file

```
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
-----

[](#usage)

### Mock verification

[](#mock-verification)

**mountebank should be started with `--mock` flag to use mocking**

[» mountebank docs on mocking](http://www.mbtest.org/docs/api/mocks)

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.

Module provides 3 methods to verify mock imposter:

#### `seeImposterHasRequests($alias)`

[](#seeimposterhasrequestsalias)

Asserts that there was at least 1 request recorded on imposter

#### `seeImposterHasRequestsByCriteria($alias, $criteria)`

[](#seeimposterhasrequestsbycriteriaalias-criteria)

Asserts that there was at least 1 request that satisfies criteria recorded on imposter.

If `$criteria` is array then request is considered matching if `$criteria` is subarray of request, e.g.:

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

```
{
  "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:

```
/**
 * @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.

#### `seeImposterHasNoRequests($alias)`

[](#seeimposterhasnorequestsalias)

Asserts that there is no requests recorded on imposter.

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Credits
-------

[](#credits)

- [Andrejs Mironovs](https://github.com/meare)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3439d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3748248?v=4)[Andrejs](/maintainers/meare)[@meare](https://github.com/meare)

---

Top Contributors

[![meare](https://avatars.githubusercontent.com/u/3748248?v=4)](https://github.com/meare "meare (5 commits)")

---

Tags

codeceptionmountebanktestingtestingcodeceptionjugglermountebankcodecept

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/meare-codeception-mountebank/health.svg)

```
[![Health](https://phpackages.com/badges/meare-codeception-mountebank/health.svg)](https://phpackages.com/packages/meare-codeception-mountebank)
```

###  Alternatives

[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15311.8M36](/packages/magento-magento2-functional-testing-framework)[allure-framework/allure-codeception

Allure Codeception integration

5212.5M9](/packages/allure-framework-allure-codeception)[lucatume/wp-browser

A set of Codeception modules to test WordPress projects.

6424.1M173](/packages/lucatume-wp-browser)[contributte/codeception

Integration of Nette framework to Codeception.

27893.6k1](/packages/contributte-codeception)[jayhealey/webception

Web Interface for running Codeception tests.

19010.7k](/packages/jayhealey-webception)[mcustiel/phiremock-codeception-extension

Codeception extension for Phiremock. Allows to stub remote services for HTTP requests.

331.1M6](/packages/mcustiel-phiremock-codeception-extension)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
