PHP code example of lequipefr / mockserver-behat-context

1. Go to this page and download the library: Download lequipefr/mockserver-behat-context library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lequipefr / mockserver-behat-context example snippets

 php


use Lequipe\MockServer\Client\MockServerClient;

$client = new MockServerClient('http://127.0.0.1:1080');

$client->expectation([
    'httpRequest' => [
        'method' => 'GET',
        'path' => '/users/1',
    ],
    'httpResponse' => [
        'body' => [
            [
                'id' => 1,
                'name' => 'Zidane',
            ],
        ],
    ],
]);
 php


use Lequipe\MockServer\MockServerClient;
use Lequipe\MockServer\Builder\Expectation;

$client = new MockServerClient('http://127.0.0.1:1080');

$expectation = new Expectation();

$expectation->httpRequest()
    ->method('GET')
    ->path('/users/1')
;

$expectation->httpResponse()
    ->bodyJson([
        [
            'id' => 1,
            'name' => 'Zidane',
        ],
    ])
;

$client->expectation($expectation);