PHPackages                             martinsr/phiremock-codeception-extension-laravel-11 - 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. martinsr/phiremock-codeception-extension-laravel-11

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

martinsr/phiremock-codeception-extension-laravel-11
===================================================

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

1.1(2y ago)03.1kGPL-3.0-or-laterPHPPHP ^8.2

Since Mar 16Pushed 2y agoCompare

[ Source](https://github.com/MartinsRucevskis/phiremock-codeception-extension)[ Packagist](https://packagist.org/packages/martinsr/phiremock-codeception-extension-laravel-11)[ RSS](/packages/martinsr-phiremock-codeception-extension-laravel-11/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (7)Used By (0)

phiremock-codeception-extension
===============================

[](#phiremock-codeception-extension)

Codeception extension to make working with [Phiremock Server](https://github.com/mcustiel/phiremock-server) even easier. It allows to start a Phiremock Server before a suite is executed and stop it when the suite ends.

[![Latest Stable Version](https://camo.githubusercontent.com/f83e6ba75cb76123715019009d5e65b0a493e961a25cc9f8cb33fcc033417360/68747470733a2f2f706f7365722e707567782e6f72672f6d6375737469656c2f70686972656d6f636b2d636f646563657074696f6e2d657874656e73696f6e2f762f737461626c65)](https://packagist.org/packages/mcustiel/phiremock-codeception-extension)[![Build Status](https://camo.githubusercontent.com/9734b90f40d44e35fcbe565bca2995c7abe396b5f382689bcad3a383c5a34e09/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6375737469656c2f70686972656d6f636b2d636f646563657074696f6e2d657874656e73696f6e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mcustiel/phiremock-codeception-extension/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/63399d35bb54ab00bf989d9dcac4e91bcb44476cca8751c847597f1ada2a5090/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6375737469656c2f70686972656d6f636b2d636f646563657074696f6e2d657874656e73696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mcustiel/phiremock-codeception-extension/?branch=master)[![Monthly Downloads](https://camo.githubusercontent.com/5b93654ff5e93096edf3e5f6634c523c31a1a7605d7cf2291413493ffe973c26/68747470733a2f2f706f7365722e707567782e6f72672f6d6375737469656c2f70686972656d6f636b2d636f646563657074696f6e2d657874656e73696f6e2f642f6d6f6e74686c79)](https://packagist.org/packages/mcustiel/phiremock-codeception-extension)

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

[](#installation)

### Composer:

[](#composer)

```
    "require-dev": {
        "mcustiel/phiremock-codeception-extension": "^2.0"
    }
```

Optionally, you can install Phiremock Server in case you want to have it between your dependencies. If not, you need to specify the path to phiremock in the configuration.

```
"require-dev": {
    "mcustiel/phiremock-codeception-extension": "^2.0",
    "mcustiel/phiremock-server": "^1.0",
    "guzzlehttp/guzzle": "^6.0"
}
```

Phiremock server has been made an optional dependency in case you want to run it from a phar file, a global composer dependency or in a docker container, and not have it as a project dependency.

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

[](#configuration)

```
extensions:
    enabled:
        - \Codeception\Extension\Phiremock
    config:
        \Codeception\Extension\Phiremock:
            listen: 127.0.0.1:18080 # defaults to 0.0.0.0:8086
            bin_path: ../vendor/bin # defaults to codeception_dir/../vendor/bin
            logs_path: /var/log/my_app/tests/logs # defaults to codeception's tests output dir
            debug: true # defaults to false
            wait_until_ready: true # defaults to false
            wait_until_ready_timeout: 15 # (seconds) defaults to 30
            wait_until_ready_interval: 100 # (microseconds) defaults to 50000
            expectations_path: /my/expectations/path # defaults to tests/_expectations
            server_factory: \My\FactoryClass # defaults to 'default'
            extra_instances: [] # deaults to an empty array
            suites: [] # defaults to an empty array
            certificate: /path/to/cert # defaults to null
            certificate_key: /path/to/cert-key # defaults to null
            cert_passphrase: 'my-pass' # defaults to null
```

Note: Since Codeception version 2.2.7, extensions configuration can be added directly in the suite configuration file. That will avoid phiremock to be started for every suite.

### Parameters

[](#parameters)

#### listen

[](#listen)

Specifies the interface and port where phiremock must listen for requests.

**Default:** 0.0.0.0:8086

#### bin\_path

[](#bin_path)

Path where Phiremock Server's "binary" is located. You can, for instance, point to the location of the phar in your file system.

**Default:** codeception\_dir/../vendor/bin/phiremock

#### logs\_path

[](#logs_path)

Path where to write the output.

**Default:** codeception's tests output dir

#### debug

[](#debug)

Whether to write debug data to log file.

**Default:** false

#### start\_delay

[](#start_delay)

Time to wait after Phiremock Server is started before running the tests (used to give time to Phiremock Server to boot)

**Default:** 0

#### wait\_until\_ready

[](#wait_until_ready)

This is more robust alternative to start\_delay. It will check if Phiremock Server is actually running before running the tests. Note: it depends on Phiremeock Client to be installed via composer (it is used to check the status of Phiremock Server).

**Default:** false

#### wait\_until\_ready\_timeout

[](#wait_until_ready_timeout)

This will be used only if wait\_until\_ready is set to true. You can specify after how many seconds it will stop checking if Phiremock Server is running.

**Default:** 30

#### expectations\_path

[](#expectations_path)

Specifies a directory to search for json files defining expectations to load by default.

**Default:** codecption\_dir/\_expectations

#### certificate

[](#certificate)

Path to a certificate file to allow phiremock-server to listen for secure https connections.

**Default:** null. Meaning phiremock will only listen on unsecured http connections.

#### certificate-key

[](#certificate-key)

Path to the certificate key file.

**Default:** null.

#### cert-passphrase

[](#cert-passphrase)

Path to the certificate passphrase used to encrypt the certificate (only needed if encrypted).

**Default:** null. Meaning no decryption based in passphrase will be performed.

#### suites

[](#suites)

Specifies a list of suites for which the phiremock-server must be executed.

**Default:** \[\] Empty array, meaning that phiremock will be executed for each suite.

#### extra\_instances

[](#extra_instances)

Allows to specify more instances of phiremock-server to run. This is useful if you want, for instance, run one instance listening for http and one listening for https connections. Each instance has its own configuration, and can separately run for different suites.

**Default:** \[\] Empty array, meaning that no extra phiremock-server instances are configured.

**Example:**

```
extensions:
    enabled:
        - \Codeception\Extension\Phiremock
    config:
        \Codeception\Extension\Phiremock:
            listen: 127.0.0.1:18080
            debug: true
            expectations_path: /my/expectations/path-1
            suites:
                - acceptance
            extra_instances:
                -
                    listen: 127.0.0.1:18081
                    debug: true
                    start_delay: 1
                    expectations_path: /my/expectations/path-2
                    suites:
                        - acceptance
                        - api
                    certificate: /path/to/cert
                    certificate_key: /path/to/cert-key
                    cert_passphrase: 'my-pass'
```

#### server\_factory

[](#server_factory)

Specifies a Factory class extending `\Mcustiel\Phiremock\Server\Factory\Factory`. Useful if you want to provide your own PSR. This works only if you install phiremock as a local dependency required in your composer file.

**Default:** default

**Example:**If this is in your composer.json:

```
"require-dev": {
    "mcustiel/phiremock-codeception-extension": "v2.0",
    "mcustiel/phiremock-server": "^1.0",
    "guzzlehttp/guzzle": "^7.0"
```

The you can create a factory as follows:

```
