PHPackages                             smart-gamma/pact-behat-extension - 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. smart-gamma/pact-behat-extension

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

smart-gamma/pact-behat-extension
================================

Smart Gamma Behat extension for pact.io

v1.0.0(6y ago)0844MITPHPPHP &gt;=7.0CI failing

Since Dec 14Pushed 6y ago4 watchersCompare

[ Source](https://github.com/smart-gamma/pact-behat-extension)[ Packagist](https://packagist.org/packages/smart-gamma/pact-behat-extension)[ RSS](/packages/smart-gamma-pact-behat-extension/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (6)Versions (6)Used By (0)

Smart Gamma Behat Pact Extension
================================

[](#smart-gamma-behat-pact-extension)

[![Build Status](https://camo.githubusercontent.com/aa1204e382404962a7697ae0471e95021d4fa308c000a930ba5a72d07d033237/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736d6172742d67616d6d612f706163742d62656861742d657874656e73696f6e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/smart-gamma/pact-behat-extension/build-status/master) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/8e76ec498d8c82efcd8875a2e2a1b37cde1559e162152d1baf0a4d3ce97e22b5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736d6172742d67616d6d612f706163742d62656861742d657874656e73696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/smart-gamma/pact-behat-extension/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/8978acfcf8f1d832226f8ef6adef0459c17a97ab3c9b0c69bc38de24f9cd1f90/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736d6172742d67616d6d612f706163742d62656861742d657874656e73696f6e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/smart-gamma/pact-behat-extension/?branch=master) [![Mutation Status](https://camo.githubusercontent.com/15ec4d4a6bed911c4bf92dbef7ad70ce0a32746ec871f897eed7f9677d729f35/68747470733a2f2f62616467652e737472796b65722d6d757461746f722e696f2f6769746875622e636f6d2f736d6172742d67616d6d612f706163742d62656861742d657874656e73696f6e2f6d6173746572)](https://infection.github.io/guide/)

The extension allows to use contract test framework pact.io in BDD style with Behat

Install
-------

[](#install)

`composer require --dev smart-gamma/pact-behat-extension`

Configure
---------

[](#configure)

Add to behat.yml / behat.yml.dist

```
default:
    suites:
        default:
            contexts:
                - SmartGamma\Behat\PactExtension\Context\PactContext

extensions:
    SmartGamma\Behat\PactExtension\Extension:
        common:
            PACT_CONSUMER_NAME: consumer_name
            PACT_CORS: false
            PACT_BROKER_URI: https://pact.youdomain.com
            PACT_OUTPUT_DIR: var/pact/
            PACT_BROKER_HTTP_AUTH_USER: user
            PACT_BROKER_HTTP_AUTH_PASS: pass
            PACT_MOCK_SERVER_HEALTH_CHECK_TIMEOUT: 10
        providers:
            - provider1_name: localhost:9090
            # in case of you have to communicate with more providers from the consumer
            #- provider2_name localhost:8889

```

> Remove PACT\_BROKER\_HTTP\_AUTH\_USER, PACT\_BROKER\_HTTP\_AUTH\_PASS if your pact broker is not http auth protected

### Consumer version

[](#consumer-version)

You should define you consumer version as:

```
common:
    PACT_CONSUMER_VERSION: 1.0.0

```

But if you are using Symfony framework you can skip this and define the version at Kernel const

```
App\Kernel::PACT_CONSUMER_VERSION

```

Usage
-----

[](#usage)

- March Scenario with @pact tag

    ```
      @pact
      Scenario: My cool Pact contract test scenario

    ```
- Start Pact Mock Server

    ```
      Background:
      Given "provider1 name" API is available

    ```
- Define Pact Interaction

    ```
      Given "provider1 name" request 'GET' to '/api/some/1' should return response with 200 and body:
        | parameter    | value                     |
        | id           | 5af55347c9764a6a01684228  |
        | field1       | 35373808218O868           |
        | blocked      | false                     |
        | createdAt    | 2018-05-11T11:00:00+00:00 |

    ```
- Define Pact Interaction for complex request(POST body)

    ```
     Given "provider1 name" request 'POST' to '/api/device/5af55347c9764a6a01684228/first-frame' with parameters:
       | parameter    | value                     |
       | id           | 5af55347c9764a6a01684228  |
       | imei         | 35373808218O868           |
     And request above to "provider1 name" should return response with 200 and body:
       | parameter    | value                     |
       | typeName     | SOME                      |
       | activated    | true                      |
       | blocked      | false                     |

    ```
- Define nested structure

    ```
      Given "" object should have follow structure:
        | parameter | value                    |
        | id        | 5af55347c9764a6a01684228 |
        | imei      | 35373808218O868          |
        | iccid     | 89883O3000000277040      |
      Given "device registry" request 'GET' to '/api/devices' should return response with 200 and body:
        | parameter | value    | match    |
        | count     | 2        | integer  |
        | devices   |  | eachLike |

    ```
- Execute your consumer scenario steps

    ```
      When I send a 'GET' request to '/api/entry' with parameters:
        | key      | value           |
        | imei     | 35373808218O868 |
        | aux_data | demo[]          |
      Then the response status code should be 200

    ```

### Matchers

[](#matchers)

You can define you response accoring to Postel law with matchers as:

```
    Given "provider1 name" request 'GET' to '/api/some/1' should return response with 200 and body:
      | parameter    | value                     | match           |
      | id           | 5af55347c9764a6a01684228  | like            |
      | field1       | 35373808218O868           |                 |
      | blocked      | false                     | boolean         |
      | createdAt    | 2018-05-11T11:00:00+00:00 | dateTimeISO8601 |

```

- like - will define type matching
- empty value - will use exact value
- boolean - will check bool type
- dateTimeISO8601 - will match to date format
- eachLike - will match against defined structure

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 92.9% 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

2511d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0dbcbebc9a7f7e97d82e2c6283d888741a2d08983c5bac71bca36ebe677b223c?d=identicon)[EvgeniyKuzmin](/maintainers/EvgeniyKuzmin)

---

Top Contributors

[![Evgenas](https://avatars.githubusercontent.com/u/2884742?v=4)](https://github.com/Evgenas "Evgenas (79 commits)")[![o-borovets](https://avatars.githubusercontent.com/u/7982859?v=4)](https://github.com/o-borovets "o-borovets (3 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (3 commits)")

---

Tags

bddbehatbehat-extensionpactBDDBehatcontractpact

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/smart-gamma-pact-behat-extension/health.svg)

```
[![Health](https://phpackages.com/badges/smart-gamma-pact-behat-extension/health.svg)](https://phpackages.com/packages/smart-gamma-pact-behat-extension)
```

###  Alternatives

[sensiolabs/behat-page-object-extension

Page object extension for Behat

1166.5M27](/packages/sensiolabs-behat-page-object-extension)[laracasts/behat-laravel-extension

Laravel extension for Behat

2611.3M12](/packages/laracasts-behat-laravel-extension)[dvdoug/behat-code-coverage

Generate Code Coverage reports for Behat tests

593.6M37](/packages/dvdoug-behat-code-coverage)[bex/behat-extension-driver-locator

Driver locator tool for behat extensions

385.2M4](/packages/bex-behat-extension-driver-locator)[ciaranmcnulty/behat-stepthroughextension

Extension for behat to help debug failing scenarios

601.6M5](/packages/ciaranmcnulty-behat-stepthroughextension)[soyuka/contexts

Behatch contexts

282.1M11](/packages/soyuka-contexts)

PHPackages © 2026

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