2017 © Pedro Peláez
 

behat-extension behat-guzzle-extension

Behat API extension using Guzzle Service Descriptions to functionally test API endpoints

image

teaandcode/behat-guzzle-extension

Behat API extension using Guzzle Service Descriptions to functionally test API endpoints

  • Thursday, June 22, 2017
  • by teaandcode
  • Repository
  • 2 Watchers
  • 11 Stars
  • 7,588 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 9 Forks
  • 5 Open issues
  • 13 Versions
  • 9 % Grown

The README.md

Behat Guzzle Extension

Build Status, (*1)

Scrutinizer Code Quality Code Coverage Build Status, (*2)

Join the chat at https://gitter.im/teaandcode/behat-guzzle-extension, (*3)

Guzzle extension for Behat is an integration layer between Behat 3.0+ and Guzzle 3.5+ and it provides:, (*4)

  • Additional services for Behat (Guzzle).
  • Behat\GuzzleExtension\Context\GuzzleAwareContext which provides Guzzle instance for your contexts.
  • Base Behat\GuzzleExtension\Context\GuzzleContext context which provides base step definitions and hooks for your contexts or subcontexts. Or it could be even used as context on its own.

Installation

Add to your project with Composer (dev), (*5)

php composer.phar require --dev teaandcode/behat-guzzle-extension

Configuration

The extension is designed to require very little configuration, the only two fields it requires is a base_url and a service_descriptions file location., (*6)

The base_url is the root url containing either a host name or IP address of the API you're writing tests for, just make sure it's a fully qualified URL (the trailing slash is not required) e.g. http://127.0.0.1, (*7)

The service_descriptions file location is required as the extension is designed to make use of a Guzzle service descriptions file, this means that all the endpoints and associated fields you want to test should be listed as JSON in the file for the extension to work., (*8)

Follow the link provided here if you want to know more about how to use the Guzzle service descriptions file or take a look at the example Guzzle service descriptions file excerpt below., (*9)

Example configuration in behat.yml

default:
    extensions:
        Behat\GuzzleExtension:
            base_url: http://127.0.0.1
            service_descriptions: %paths.base%/app/config/service.json
    suites:
        default:
            contexts:
                - Behat\GuzzleExtension\Context\GuzzleContext:
                    users:
                        test.user.1: B8E...1AF
                        test.user.2: A6B...8E6

Example Guzzle service descriptions file

{
    "name": "Travis API",
    "operations": {
        "GetReposBuilds": {
            "httpMethod": "GET",
            "uri": "repos/{slug}/builds",
            "summary": "Gets the last build for repo",
            "parameters": {
                "slug": {
                    "location": "uri",
                    "description": "Repo slug from GitHub",
                    "required": true
                },
                "number": {
                    "location": "query"
                }
            }
        }
    }
}

Further configuration

As you might have seen in the example configuration above, it is possible to pass a list of usernames or e-mail addresses that can be associated with an HTTP header Authorization Bearer token, which means that you're able to test secure parts of your API. Just specify the GuzzleContext as shown above in the behat.yml file and provide and array of users utilising the username/e-mail address ad the key with the bearer token as the value., (*10)

Predefined steps

TO DO: In the meantime checkout the repo.feature file in the features directory and the docblocks above each of the methods in the GuzzleContext.php file in the src/Behat/GuzzleExtension/Context directory., (*11)

To do

  • Add documentation
  • Add language support

Copyright (c) 2015 Dave Nash (knasher). See LICENSE for details., (*12)

Contributors

  • Dave Nash knasher [lead developer]
  • Other [awesome developers] (https://github.com/teaandcode/behat-guzzle-extension/graphs/contributors)

The Versions

22/06 2017

dev-master

9999999-dev https://github.com/teaandcode/behat-guzzle-extension

Behat API extension using Guzzle Service Descriptions to functionally test API endpoints

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dave Nash

api test curl behat guzzle web end-to-end

22/06 2017

v0.4.2

0.4.2.0 https://github.com/teaandcode/behat-guzzle-extension

Behat API extension using Guzzle Service Descriptions to functionally test API endpoints

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dave Nash

api test curl behat guzzle web end-to-end

22/06 2017

dev-develop

dev-develop https://github.com/teaandcode/behat-guzzle-extension

Behat API extension using Guzzle Service Descriptions to functionally test API endpoints

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dave Nash

api test curl behat guzzle web end-to-end

14/06 2017

v0.4.1

0.4.1.0 https://github.com/teaandcode/behat-guzzle-extension

Behat API extension using Guzzle Service Descriptions to functionally test API endpoints

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dave Nash

api test curl behat guzzle web end-to-end

11/11 2015

v0.3.9

0.3.9.0 https://github.com/teaandcode/behat-guzzle-extension

Behat API extension using Guzzle Service Descriptions to functionally test API endpoints

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dave Nash

api test curl behat guzzle web end-to-end

23/10 2015

v0.3.8

0.3.8.0 https://github.com/teaandcode/behat-guzzle-extension

Behat API extension using Guzzle Service Descriptions to functionally test API endpoints

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dave Nash

api test curl behat guzzle web end-to-end

22/06 2015

v0.3.7

0.3.7.0 https://github.com/teaandcode/behat-guzzle-extension

Behat API extension using Guzzle Service Descriptions to functionally test API endpoints

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dave Nash

api test curl behat guzzle web end-to-end

22/06 2015

v0.3.6

0.3.6.0 https://github.com/teaandcode/behat-guzzle-extension

Behat API extension using Guzzle Service Descriptions to functionally test API endpoints

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dave Nash

api test curl behat guzzle web end-to-end

14/05 2015
21/04 2015
13/04 2015
08/04 2015
18/03 2015