PHPackages                             devizzent/codeception-mockserver-helper - 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. devizzent/codeception-mockserver-helper

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

devizzent/codeception-mockserver-helper
=======================================

Codeception helper to manage and verify MockServer expectations

1.2.0(1y ago)413.9k↑181%1[1 PRs](https://github.com/DEVizzent/codeception-mockserver-helper/pulls)MITPHPPHP 7.4.\*||8.\*

Since Feb 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/DEVizzent/codeception-mockserver-helper)[ Packagist](https://packagist.org/packages/devizzent/codeception-mockserver-helper)[ RSS](/packages/devizzent-codeception-mockserver-helper/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (6)Dependencies (9)Versions (14)Used By (0)

Codecetion-MockServer Helper
============================

[](#codecetion-mockserver-helper)

This library is a Module for [Codeception](https://codeception.com/) which allows your tests interact with [mock-server](https://www.mock-server.com/)(v5) in an easy and intuitive way.

MockServer allows you to simulate http services in your testing/local environment and this helper allows you check all the request you have sent to mock server and manage the expectations of mockserver.

How to use it
-------------

[](#how-to-use-it)

```
//You can create expectations before call your application in a test
$I->createMockRequest('{"id": "elastic-get-entity-1", "httpRequest": {...}, "httpResponse": {...}}')
$I->createMockRequest('{"id": "elastic-get-entity-2", "httpRequest": {...}, "httpResponse": {...}}')
$I->createMockRequestFromJsonFile('/root/path/elastic-get-entity-3.json')
$I->sendGet('/applition/endpoint/1');
//After execute our application we can check our mocked HTTP communication
$I->seeMockRequestWasCalled('elastic-get-entity-1');
$I->seeMockRequestWasNotCalled('elastic-get-entity-2');
$I->seeAllRequestWereMatched();
$I->removeMockRequest("elastic-get-entity-2");
$I->removeAllMockRequest();
```

Installation
------------

[](#installation)

Install the latest version with

```
$ composer require devizzent/codeception-mockserver-helper --dev
```

Codeception Configuration
-------------------------

[](#codeception-configuration)

`This helper isn't a codeception module, it  can't be configured in the global codeception.yml  only in the *.suite.yml configuration.`

Go to your codeception **suite** configuration and add this module

```
modules:
  enabled:
    - DEVizzent\CodeceptionMockServerHelper\MockServerHelper:
        ##Mandatory field, mock server url
        url: 'http://mockserver:1080'
        ## Optional field, [test, suite, never] allowed. Default: test
        cleanupBefore: 'test'
        ## Optional field, [enabled, disabled] allowed. Default: enabled
        notMatchedRequest: 'enabled'
        ## Optional field, path of the expectations folder or file to load before test
        expectationsPath: '/absolute/expectations/path'
```

### cleanupBefore

[](#cleanupbefore)

This variable set the moment when we want to clean the mockserver logs in order to don't affect the other tests or suites. We recomend set this value in the default value.

- 'test' will remove all logs before start any test making sure that you are not affected by request did in the previous test execution.
- 'suite' will remove all logs before start a suite of tests.
- 'never' will not remove your mock-server logs. It can generate confusion and failures in your tests, because if you check something was called X times, the number of times increase every time you run your tests. If you only check that a request was called, it could be called in the previous execution, but by error not in the current one.

### notMatchedRequest

[](#notmatchedrequest)

When this option is enabled, it creates an expectation with lowest priority which match all the request haven't matched our expectations, returning a 500 error with a message `Request not matched by MockServer`.

It allows us to validate all request our application do, are expected and we haven't change our communication with external services.

### expectationsPath

[](#expectationspath)

Get the file or files in the path, and send the content to create expectations on mockserver.

About
-----

[](#about)

### Requirements

[](#requirements)

Codecetion-MockServer Helper needs at least php 7.4 or higher and codeception 4 or higher.

### How to contribute

[](#how-to-contribute)

Create an issue describing the bug or the new feature, create your fork of this project and send your PR.

For using the dev environment you only need Docker, Docker-compose and Makefile.

```
Usage:
  make

Targets:
  help                       Display this help
  install                    Install required software and initialize your local configuration
  up                         Start application containers and required services
  debug                      Start application containers and required services in debug mode
  down                       Stop application containers and required services
  test                       Execute all phpunit test
  composer-update            Run composer update
  composer-install           Run composer update

```

### Author

[](#author)

Vicent Valls -  -
See also the list of [contributors](https://github.com/DEVizzent/codeception-mockserver-helper/graphs/contributors) who participated in this project.

### License

[](#license)

Codecetion-MockServer Helper is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance47

Moderate activity, may be stable

Popularity32

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

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

Every ~166 days

Recently: every ~207 days

Total

6

Last Release

394d ago

Major Versions

0.2.0 → 1.0.02023-02-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f6e5789becbcd34eba76e603d652f4d889970506769776af195a25ef47a3376?d=identicon)[VicentValls](/maintainers/VicentValls)

---

Top Contributors

[![DEVizzent](https://avatars.githubusercontent.com/u/40741634?v=4)](https://github.com/DEVizzent "DEVizzent (60 commits)")

---

Tags

codeceptioncodeception-extensioncodeception-modulecodeception-testsmockserverphpphp-library

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/devizzent-codeception-mockserver-helper/health.svg)

```
[![Health](https://phpackages.com/badges/devizzent-codeception-mockserver-helper/health.svg)](https://phpackages.com/packages/devizzent-codeception-mockserver-helper)
```

###  Alternatives

[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15311.8M36](/packages/magento-magento2-functional-testing-framework)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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