2017 © Pedro Peláez
 

project phiremock-codeception-extension

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

image

mcustiel/phiremock-codeception-extension

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

  • Sunday, June 3, 2018
  • by mcustiel
  • Repository
  • 2 Watchers
  • 11 Stars
  • 22,447 Installations
  • PHP
  • 3 Dependents
  • 1 Suggesters
  • 6 Forks
  • 0 Open issues
  • 21 Versions
  • 90 % Grown

The README.md

phiremock-codeception-extension

Codeception extension to make working with Phiremock Server even easier. It allows to start a Phiremock Server before a suite is executed and stop it when the suite ends., (*1)

Latest Stable Version Build Status Scrutinizer Code Quality Monthly Downloads, (*2)

Installation

Composer:

    "require-dev": {
        "mcustiel/phiremock-codeception-extension": "^3.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., (*3)

"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., (*4)

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., (*5)

Parameters

listen

Specifies the interface and port where phiremock must listen for requests., (*6)

Default: 0.0.0.0:8086, (*7)

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., (*8)

Default: codeception_dir/../vendor/bin/phiremock, (*9)

logs_path

Path where to write the output., (*10)

Default: codeception's tests output dir, (*11)

debug

Whether to write debug data to log file., (*12)

Default: false, (*13)

start_delay

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

Default: 0, (*15)

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)., (*16)

Default: false, (*17)

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., (*18)

Default: 30, (*19)

expectations_path

Specifies a directory to search for json files defining expectations to load by default., (*20)

Default: codecption_dir/_expectations, (*21)

certificate

Path to a certificate file to allow phiremock-server to listen for secure https connections., (*22)

Default: null. Meaning phiremock will only listen on unsecured http connections., (*23)

certificate-key

Path to the certificate key file., (*24)

Default: null., (*25)

cert-passphrase

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

Default: null. Meaning no decryption based in passphrase will be performed., (*27)

suites

Specifies a list of suites for which the phiremock-server must be executed., (*28)

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

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., (*30)

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

Example:, (*32)

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

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., (*33)

Default: default, (*34)

Example: If this is in your composer.json:, (*35)

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

Then you can create a factory as follows:, (*36)

<?php
namespace My\Namespace;

use GuzzleHttp;
use Mcustiel\Phiremock\Server\Factory\Factory;
use Psr\Http\Client\ClientInterface;

class FactoryWithGuzzle7 extends Factory
{
    public function createHttpClient(): ClientInterface
    {
        return new GuzzleHttp\Client();
    }
}

and in the extension config provide the fully qualified namespace to that class:, (*37)

 enabled:
   - \Codeception\Extension\Phiremock
 config:
   \Codeception\Extension\Phiremock:
     server_factory: \My\Namespace\FactoryWithGuzzle7

See also:

  • Phiremock Server: https://github.com/mcustiel/phiremock-server
  • Phiremock Codeception Module: https://github.com/mcustiel/phiremock-codeception-module

The Versions

03/06 2018

dev-master

9999999-dev

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

  Sources   Download

GPL-3.0+ GPL-3.0-or-later

The Requires

 

mock extension server http tests external codeception acceptance phiremock

03/06 2018

v1.5.4

1.5.4.0

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

  Sources   Download

GPL-3.0-or-later

The Requires

 

mock extension server http tests external codeception acceptance phiremock

24/01 2018

v1.5.3

1.5.3.0

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

  Sources   Download

GPL-3.0+

The Requires

 

mock extension server http tests external codeception acceptance phiremock

22/01 2018

v1.5.2

1.5.2.0

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

  Sources   Download

GPL-3.0+

The Requires

 

mock extension server http tests external codeception acceptance phiremock

26/12 2017

v1.5.1

1.5.1.0

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

  Sources   Download

GPL-3.0+

The Requires

 

mock extension server http tests external codeception acceptance phiremock

26/12 2017

dev-issue/21

dev-issue/21

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

  Sources   Download

GPL-3.0+

The Requires

 

mock extension server http tests external codeception acceptance phiremock

12/10 2017

v1.5.0

1.5.0.0

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

  Sources   Download

GPL-3.0+

The Requires

 

mock extension server http tests external codeception acceptance phiremock

24/09 2017

v1.4.1

1.4.1.0

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

  Sources   Download

GPL-3.0+

The Requires

 

mock extension server http tests external codeception acceptance phiremock

19/09 2017

v1.4.0

1.4.0.0

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

  Sources   Download

GPL-3.0+

The Requires

 

mock extension server http tests external codeception acceptance phiremock

15/09 2017

v1.3.2

1.3.2.0

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

  Sources   Download

GPL-3.0+

The Requires

 

mock extension server http tests external codeception acceptance phiremock

20/07 2017

v1.3.1

1.3.1.0

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

  Sources   Download

GPL-3.0+

The Requires

 

mock extension server http tests external codeception acceptance phiremock

13/06 2017

v1.3.0

1.3.0.0

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

  Sources   Download

GPL-3.0+

The Requires

 

mock extension server http tests external codeception acceptance phiremock

07/06 2017

dev-develop

dev-develop

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

  Sources   Download

GPL-3.0+

The Requires

 

mock extension server http tests external codeception acceptance phiremock

09/03 2017

v1.2.4

1.2.4.0

  Sources   Download

The Requires

 

mock extension server http tests external codeception acceptance phiremock

04/03 2017

v1.2.3

1.2.3.0

  Sources   Download

The Requires

 

mock extension server http tests external codeception acceptance phiremock

15/12 2016

v1.2.2

1.2.2.0

  Sources   Download

The Requires

 

mock extension server http tests external codeception acceptance phiremock

04/07 2016

v1.2.1

1.2.1.0

  Sources   Download

The Requires

 

mock extension server http tests external codeception acceptance phiremock

04/07 2016

v1.2.0

1.2.0.0

  Sources   Download

The Requires

 

mock extension server http tests external codeception acceptance phiremock

07/04 2016

v1.1.0

1.1.0.0

  Sources   Download

The Requires

 

mock extension server http tests external codeception acceptance phiremock

05/04 2016

v1.0.1

1.0.1.0

  Sources   Download

The Requires

 

mock extension server http tests external codeception acceptance phiremock

16/03 2016

v1.0.0

1.0.0.0

  Sources   Download

The Requires

 

mock extension server http tests external codeception acceptance phiremock