Skip to content

ubirak/rest-api-behat-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7d9f781 Â· Nov 27, 2024
Mar 4, 2021
Nov 26, 2024
Dec 6, 2017
Jan 27, 2018
Feb 13, 2015
Mar 4, 2021
Feb 13, 2015
Jan 26, 2022
Feb 12, 2015
Dec 7, 2017
Dec 6, 2017
Nov 26, 2024

Repository files navigation

RestApiExtension for Behat

Build Status

Scrutinizer Code Quality

For now only JSON api is supported to analyze response, but you could use REST part to perform request on any type of api.

Warning

From version 7.0, namespace vendor changed from Rezzza to Ubirak.

Install

Require the package as a development dependency :

composer require --dev ubirak/rest-api-behat-extension

Don't forget to load the extension and the context if needed in your behat.yml :

default:
    extensions:
        Ubirak\RestApiBehatExtension\Extension:
            rest:
                base_url: http://localhost:8888
                store_response: true
    suites:
        default:
            contexts:
                - Ubirak\RestApiBehatExtension\RestApiContext
                - Ubirak\RestApiBehatExtension\Json\JsonContext

Then you will need to require in your composer the http client you want to use, and the message factory.

Example:

composer require --dev guzzlehttp/psr7 php-http/curl-client

Usage

You can use directly the JsonContext or RestApiContext by loading them in your behat.yml or use the RestApiBrowser and JsonInspector by adding them in the construct of your own context.

<?php
/**/

use Ubirak\RestApiBehatExtension\Rest\RestApiBrowser;
use Ubirak\RestApiBehatExtension\Json\JsonInspector;

class FeatureContext implements Context
{
    private $restApiBrowser;

    private $jsonInspector;

    public function __construct(RestApiBrowser $restApiBrowser, JsonInspector $jsonInspector)
    {
        $this->restApiBrowser = $restApiBrowser;
        $this->jsonInspector = $jsonInspector;
    }
}

About

Stuff to easily test your rest api with Behat

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 14