PHPackages                             webproject-xyz/codeception-module-openapi-server-mock - 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. webproject-xyz/codeception-module-openapi-server-mock

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

webproject-xyz/codeception-module-openapi-server-mock
=====================================================

Codeception module for PHP OpenAPI Mock Server

1.0.1(2mo ago)1352[1 issues](https://github.com/WebProject-xyz/codeception-module-openapi-server-mock/issues)[5 PRs](https://github.com/WebProject-xyz/codeception-module-openapi-server-mock/pulls)MITPHPPHP ~8.3.0 || ~8.4.0 || ~8.5.0CI failing

Since Mar 11Pushed 3w agoCompare

[ Source](https://github.com/WebProject-xyz/codeception-module-openapi-server-mock)[ Packagist](https://packagist.org/packages/webproject-xyz/codeception-module-openapi-server-mock)[ Docs](https://www.webproject.xyz)[ RSS](/packages/webproject-xyz-codeception-module-openapi-server-mock/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (20)Versions (10)Used By (0)

Codeception Module for PHP OpenAPI Mock Server
==============================================

[](#codeception-module-for-php-openapi-mock-server)

[![CI](https://github.com/WebProject-xyz/codeception-module-openapi-server-mock/actions/workflows/ci.yml/badge.svg)](https://github.com/WebProject-xyz/codeception-module-openapi-server-mock/actions/workflows/ci.yml)[![Latest Stable Version](https://camo.githubusercontent.com/89984b03ceb784021afa140063f08b3ee55bde0a36df6fd6386ed927e9aa77ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77656270726f6a6563742d78797a2f636f646563657074696f6e2d6d6f64756c652d6f70656e6170692d7365727665722d6d6f636b2e737667)](https://packagist.org/packages/webproject-xyz/codeception-module-openapi-server-mock)[![PHP Version](https://camo.githubusercontent.com/e69fc10ad0d3845d44d08b0eeedd6dd7a5bfa4ab872e68e26b131554122d35d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d626c75652e737667)](https://www.php.net/)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Codeception](https://camo.githubusercontent.com/5091fd490725c0399f9cdecbdfaf2d32b58b9c123f6b5bf0eff25af4e1e3d1ae/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f646563657074696f6e2d253545352e302d7265642e737667)](https://codeception.com/)

> **Orchestrate and control high-performance OpenAPI mocks directly from your PHP testing suite.**

This module provides a seamless integration between [Codeception](https://codeception.com/) and the [PHP OpenAPI Mock Server](https://github.com/WebProject-xyz/php-openapi-mock-server). It eliminates the need for complex Docker setups or manual process management by handling the mock server lifecycle and providing fluent test actions.

---

🚀 Key Features
--------------

[](#-key-features)

- **Zero-Config Lifecycle:** Automatically starts the mock server before your test suite and terminates it after completion.
- **Intelligent Discovery:** Auto-detects the mock server binary within your `vendor` directory or local development path.
- **Dynamic Response Control:** Change expected status codes and named examples per-test using simple PHP actions.
- **Headless &amp; Fast:** Uses the native PHP built-in server for sub-millisecond overhead, perfect for CI/CD pipelines.
- **Seamless Integration:** Designed to work perfectly alongside Codeception's `REST` and `PhpBrowser` modules.

---

📦 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require --dev webproject-xyz/codeception-module-openapi-server-mock
```

### Prerequisites

[](#prerequisites)

- **PHP:** ^8.3
- **Codeception:** ^5.0
- **Mock Server:** [php-openapi-mock-server](https://github.com/WebProject-xyz/php-openapi-mock-server) (installed automatically as a dependency)

---

🖥️ Configuration
----------------

[](#️-configuration)

Enable the module in your `acceptance.suite.yml` or `functional.suite.yml`:

```
actor: AcceptanceTester
modules:
    enabled:
        - REST:
            depends: PhpBrowser
            url: http://localhost:8080/
        - PhpBrowser:
            url: http://localhost:8080/
        - WebProject\Codeception\Module\OpenApiServerMock:
            port: 8080
            spec: tests/Support/Data/openapi.yaml
            waitTimeout: 10
```

### Configuration Options

[](#configuration-options)

OptionDescriptionDefault`path`Path to the `php-openapi-mock-server` directory.*Auto-detected*`port`Port the mock server should listen on.`8080``host`Host address for the server.`localhost``spec`Relative path to your OpenAPI `.yaml` or `.json` file.`data/openapi.yaml``startServer`Automatically start the server process.`true``waitTimeout`Seconds to wait for the server to become ready.`5``stopOnFinish`Terminate the server process after the suite ends.`true`---

🛠️ Usage
--------

[](#️-usage)

Once configured, run `vendor/bin/codecept build` to generate the actions in your `AcceptanceTester`.

### Basic Actions

[](#basic-actions)

```
// Force a specific HTTP status code for the next request
$I->haveOpenApiMockStatusCode(201);

// Force a specific named example from your OpenAPI spec
$I->haveOpenApiMockExample('SuccessResponse');

// Enable/Disable the mock server (useful for fallthrough testing)
$I->setOpenApiMockActive(false);

// Get the mock server URL dynamically
$url = $I->getOpenApiMockServerUrl();
```

---

💡 Advanced Mocking
------------------

[](#-advanced-mocking)

The module allows you to test how your application handles various API scenarios, including error states and edge cases.

### Testing Error Handling

[](#testing-error-handling)

```
public function testInternalServerError(AcceptanceTester $I) {
    // Force a 500 Internal Server Error
    $I->haveOpenApiMockStatusCode(500);
    $I->sendGet('/users');

    $I->seeResponseCodeIs(500);
}

public function testValidationFailure(AcceptanceTester $I) {
    // Force a 400 Bad Request
    $I->haveOpenApiMockStatusCode(400);
    $I->sendPost('/users', []); // Missing required data

    $I->seeResponseCodeIs(400);
}
```

### Using Named Examples

[](#using-named-examples)

If your OpenAPI specification includes `examples` for a response, you can force the server to return a specific one:

```
public function testSpecificMockData(AcceptanceTester $I) {
    $I->haveOpenApiMockExample('AliceUser');
    $I->sendGet('/users/1');

    $I->seeResponseContainsJson(['name' => 'Alice']);
}
```

---

🌐 CI/CD Integration
-------------------

[](#-cicd-integration)

Since the module starts the mock server using the built-in PHP server, it works out-of-the-box in GitHub Actions without requiring Docker.

### GitHub Actions Example

[](#github-actions-example)

```
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.3'
      - name: Install dependencies
        run: composer install
      - name: Build Codeception
        run: vendor/bin/codecept build
      - name: Run Tests
        run: vendor/bin/codecept run Acceptance
```

---

🔍 Troubleshooting
-----------------

[](#-troubleshooting)

### Port already in use

[](#port-already-in-use)

If you see an error about the address being already in use, change the `port` in your suite configuration:

```
WebProject\Codeception\Module\OpenApiServerMock:
    port: 8081 # Change from default 8080
```

### Mock server path not found

[](#mock-server-path-not-found)

The module tries to auto-detect the path. If it fails, provide it explicitly:

```
WebProject\Codeception\Module\OpenApiServerMock:
    path: ./vendor/webproject-xyz/php-openapi-mock-server
```

### Server start timeout

[](#server-start-timeout)

If your specification is very large, the server might take longer to initialize. Increase the `waitTimeout`:

```
WebProject\Codeception\Module\OpenApiServerMock:
    waitTimeout: 15 # Wait up to 15 seconds
```

---

🧪 Development &amp; Testing
---------------------------

[](#-development--testing)

We maintain high standards for this module:

- **Static Analysis:** PHPStan Level 8.
- **Coding Style:** Strict PSR-12/Symfony standards.
- **Automation:** GrumPHP hooks ensure all commits are verified.

### Commands

[](#commands)

```
composer stan      # Run static analysis
composer test      # Run acceptance tests
composer cs:check  # Check coding standards
```

---

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please see our [CONTRIBUTING.md](CONTRIBUTING.md) for details.

1. Fork the Project.
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`).
3. Commit your Changes (`git commit -m 'feat: Add some AmazingFeature'`).
4. Push to the Branch (`git push origin feature/AmazingFeature`).
5. Open a Pull Request.

---

📜 License
---------

[](#-license)

Distributed under the **MIT** License. See `LICENSE` for more information.

---

✉️ Support &amp; Contact
------------------------

[](#️-support--contact)

- **Issues:** Please use the [GitHub Issue Tracker](https://github.com/WebProject-xyz/codeception-module-openapi-server-mock/issues).
- **Website:** [webproject.xyz](https://www.webproject.xyz)

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance72

Regular maintenance activity

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.4% 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 ~44 days

Total

2

Last Release

60d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8126644ebe55d4c9e7d6e496307e6ee2c6232e7af450b1b915de3b282bd44b2d?d=identicon)[Fahl-Design](/maintainers/Fahl-Design)

---

Top Contributors

[![Fahl-Design](https://avatars.githubusercontent.com/u/6690962?v=4)](https://github.com/Fahl-Design "Fahl-Design (13 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (4 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (2 commits)")

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/webproject-xyz-codeception-module-openapi-server-mock/health.svg)

```
[![Health](https://phpackages.com/badges/webproject-xyz-codeception-module-openapi-server-mock/health.svg)](https://phpackages.com/packages/webproject-xyz-codeception-module-openapi-server-mock)
```

###  Alternatives

[brianium/paratest

Parallel testing for PHP

2.5k129.9M910](/packages/brianium-paratest)[phpro/grumphp

A composer plugin that enables source code quality checks.

4.3k16.3M975](/packages/phpro-grumphp)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k41.3M38.7k](/packages/orchestra-testbench)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k27.9M2.2k](/packages/infection-infection)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

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

PHPackages © 2026

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