PHPackages                             lequipefr/mockserver-behat-context - 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. lequipefr/mockserver-behat-context

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

lequipefr/mockserver-behat-context
==================================

Behat context for MockServer.

1.0.7(2y ago)27.0k↓40%[1 PRs](https://github.com/lequipefr/mockserver-behat-context/pulls)MITPHPPHP &gt;=8.0.2

Since Feb 15Pushed 2y agoCompare

[ Source](https://github.com/lequipefr/mockserver-behat-context)[ Packagist](https://packagist.org/packages/lequipefr/mockserver-behat-context)[ RSS](/packages/lequipefr-mockserver-behat-context/feed)WikiDiscussions 1.x-dev Synced 1mo ago

READMEChangelog (5)Dependencies (9)Versions (23)Used By (0)

MockServer Behat context
========================

[](#mockserver-behat-context)

Php client and behat context for [MockServer](https://www.mock-server.com/).

Install
-------

[](#install)

```
composer require --dev lequipefr/mockserver-behat-context
```

Then add a context in your `behat.yml`, with the url to your local MockServer instance:

```
default:
    suites:
        default:
            contexts:

                # Add this:
                - Lequipe\MockServer\Behat\MockServerContext:
                    mockServer: 'http://127.0.0.1:1080'
```

Now, in your behat tests, you should be able to mock the webservices your project depends to, with:

```
Given the request "GET" "/users/1" will return the json:
    """
    {
        "id": 1,
        "name": "Zidane"
    }
    """

```

Usage
-----

[](#usage)

### Behat context

[](#behat-context)

See [all available behat phrases you can use](docs/behat-phrases.md).

### PHP client

[](#php-client)

You can also use this library as a simple PHP client, and send your expectations as raw arrays, as defined in [mockserver swagger api](https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.12.x#/expectation/put_expectation):

```
