PHPackages                             teaandcode/behat-guzzle-extension - 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. teaandcode/behat-guzzle-extension

ActiveBehat-extension[Testing &amp; Quality](/categories/testing)

teaandcode/behat-guzzle-extension
=================================

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

v0.4.2(8y ago)1017.7k9[5 issues](https://github.com/teaandcode/behat-guzzle-extension/issues)MITPHPPHP &gt;=5.3.3

Since Mar 18Pushed 6y ago2 watchersCompare

[ Source](https://github.com/teaandcode/behat-guzzle-extension)[ Packagist](https://packagist.org/packages/teaandcode/behat-guzzle-extension)[ Docs](https://github.com/teaandcode/behat-guzzle-extension)[ RSS](/packages/teaandcode-behat-guzzle-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (13)Used By (0)

Behat Guzzle Extension
======================

[](#behat-guzzle-extension)

[![Build Status](https://camo.githubusercontent.com/c22181057e6ac26ab7e9d892e2ba0bf2121a4f287c519b01fecbcd4ee275b891/68747470733a2f2f7472617669732d63692e6f72672f746561616e64636f64652f62656861742d67757a7a6c652d657874656e73696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/teaandcode/behat-guzzle-extension)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/211cf6a79892e343a3a274e4e1bb23da422b816de6620ed3082fb761f0a4a861/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746561616e64636f64652f62656861742d67757a7a6c652d657874656e73696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/teaandcode/behat-guzzle-extension/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/f96d91055c0b15c4210acf534cf88527b6857700c12b8a384c7234ad916fe0b2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746561616e64636f64652f62656861742d67757a7a6c652d657874656e73696f6e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/teaandcode/behat-guzzle-extension/?branch=master)[![Build Status](https://camo.githubusercontent.com/6ae0ebfc43c84210c4fe3051b84becfe9969b9c58ee4b8d38ceddf3b800c7a74/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746561616e64636f64652f62656861742d67757a7a6c652d657874656e73696f6e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/teaandcode/behat-guzzle-extension/build-status/master)

[![Join the chat at https://gitter.im/teaandcode/behat-guzzle-extension](https://camo.githubusercontent.com/abe08b740a4156153736f791393ec4da6619c4be73212e75769f52edacc0e2b5/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/teaandcode/behat-guzzle-extension?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Guzzle extension for Behat is an integration layer between Behat 3.0+ and Guzzle 3.5+ and it provides:

- 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
------------

[](#installation)

Add to your project with Composer (*dev*)

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

```

Configuration
-------------

[](#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.

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.

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.

Follow the link provided here if you want to know more about how to use the [Guzzle service descriptions](http://guzzle3.readthedocs.org/webservice-client/guzzle-service-descriptions.html)file or take a look at the example Guzzle service descriptions file excerpt below.

### Example configuration in behat.yml

[](#example-configuration-in-behatyml)

```
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

[](#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
---------------------

[](#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.

Predefined steps
----------------

[](#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.

To do
-----

[](#to-do)

- Add documentation
- Add language support

Copyright
---------

[](#copyright)

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

Contributors
------------

[](#contributors)

- Dave Nash [knasher](http://github.com/knasher) \[lead developer\]
- Other \[awesome developers\] ()

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~82 days

Recently: every ~182 days

Total

11

Last Release

3252d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/19da6ecb25c1ff6773b8a64a4c2219034999e811d7e98fa13ec39036d2518a04?d=identicon)[knasher](/maintainers/knasher)

![](https://www.gravatar.com/avatar/d55e7efea87cc601e1e1d55170d51645bb094f0fbd9bd2d0c374615f73ade72c?d=identicon)[teaandcode](/maintainers/teaandcode)

---

Top Contributors

[![knasher](https://avatars.githubusercontent.com/u/1300648?v=4)](https://github.com/knasher "knasher (81 commits)")[![eddiejaoude](https://avatars.githubusercontent.com/u/624760?v=4)](https://github.com/eddiejaoude "eddiejaoude (4 commits)")[![crudecki](https://avatars.githubusercontent.com/u/4571301?v=4)](https://github.com/crudecki "crudecki (2 commits)")[![rs-saunders](https://avatars.githubusercontent.com/u/4743056?v=4)](https://github.com/rs-saunders "rs-saunders (2 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")

---

Tags

apitestwebcurlGuzzleBehatend-to-end

### Embed Badge

![Health badge](/badges/teaandcode-behat-guzzle-extension/health.svg)

```
[![Health](https://phpackages.com/badges/teaandcode-behat-guzzle-extension/health.svg)](https://phpackages.com/packages/teaandcode-behat-guzzle-extension)
```

###  Alternatives

[drupal/drupal-extension

Drupal extension for Behat

22215.1M147](/packages/drupal-drupal-extension)[friends-of-behat/mink-extension

Mink extension for Behat

14034.2M467](/packages/friends-of-behat-mink-extension)[robertfausk/behat-panther-extension

Symfony Panther extension for Behat

341.7M87](/packages/robertfausk-behat-panther-extension)[dvdoug/behat-code-coverage

Generate Code Coverage reports for Behat tests

593.6M37](/packages/dvdoug-behat-code-coverage)[nuvoleweb/drupal-behat

Drupal Behat extension.

33787.7k3](/packages/nuvoleweb-drupal-behat)[leanphp/behat-code-coverage

Generate Code Coverage reports for Behat tests

50359.8k2](/packages/leanphp-behat-code-coverage)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
