Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 583 Bytes

stub-server.md

File metadata and controls

22 lines (15 loc) · 583 Bytes

Usage for the optional pact-stub-service

If you would like to test with fixtures, you can use the pact-stub-service like this:

$files    = [__DIR__ . '/someconsumer-someprovider.json'];
$port     = 7201;
$endpoint = 'test';

$config = (new StubServerConfig())
            ->setFiles($files)
            ->setPort($port);

$stubServer = new StubServer($config);
$stubServer->start();

$client = new \GuzzleHttp\Client();

$response = $client->get($this->config->getBaseUri() . '/' . $endpoint);

echo $response->getBody(); // output: {"results":[{"name":"Games"}]}