PHPackages                             aferalabs/arachne - 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. aferalabs/arachne

ActiveLibrary

aferalabs/arachne
=================

Behat extension for testing and validating XML and JSON based web services

0.5.0(6y ago)420.1k4[2 issues](https://github.com/theDisco/Arachne/issues)[1 PRs](https://github.com/theDisco/Arachne/pulls)MITPHPPHP &gt;=5.4.0CI failing

Since May 12Pushed 4y ago1 watchersCompare

[ Source](https://github.com/theDisco/Arachne)[ Packagist](https://packagist.org/packages/aferalabs/arachne)[ RSS](/packages/aferalabs-arachne/feed)WikiDiscussions master Synced 1mo ago

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

[![Build Status](https://camo.githubusercontent.com/6eaa823e6b6a74013891846a93935fba651e5108641c83a135d7d3ca3c7bc0e4/68747470733a2f2f7472617669732d63692e6f72672f746865446973636f2f41726163686e652e737667)](https://travis-ci.org/theDisco/Arachne)

Arachne
=======

[](#arachne)

Arachne is a Behat 3 extension for testing web services. Similarly to Mink, it exposes multiple methods in a context to facilitate testing of RESTful APIs.

Installation
============

[](#installation)

The preferred way of installing Arachne is through composer. Just add Arachne as a dependency to your project and you are good to go.

```
{
    "require-dev": {
        "aferalabs/arachne": "0.1.*"
    }
}
```

Configuration
=============

[](#configuration)

An example configuration was set up in the example project. Take a look at `examples/behat.yml`.

```
default:
  extensions:
    Arachne\ServiceContainer\ArachneExtension:
      base_url: http://echo.jsontest.com
      paths:
        schema_file_dir: %paths.base%/schemas
        request_file_dir: %paths.base%/requests
        response_file_dir: %paths.base%/responses
      auth:
        provider: Arachne\Auth\DummyProvider
      headers:
        Authorization: Token token=123456
  suites:
    json:
      contexts:
        - Arachne\Context\ArachneContext
          - headers:
              X-Example-Header: Example Value
```

In order to enable the extension, you need to add it to the extensions node of your config.

**base\_url**

`base_url` is the only required configuration value and will be prepended to all requests made by the extension.

**paths.schema\_file\_dir**

Under the hood Arachne uses [json schema](http://json-schema.org/) validator or [xml schema](https://github.com/seromenho/XmlValidator/) validator to validate the structure of the response. In order to use `response should validate against "one_two[.json|.xsd]" schema`, extensions needs to know, where to find schema files. `paths.schema_file_dir` tells Arachne, which folder are the schema files located in. In this particular example, Arachne will look for a schema in `examples/schemas/one_two.json` file.

```
  Scenario:
    Given I use "GET" request method
    When I access the resource url "/one/two"
    And I send the request
    Then the status code should be 200
    And response should be a valid JSON
    And response header "Server" should contain "Google Frontend"
    And response should validate against "one_two" schema #
