quiborgue/laravel-behat-traits

Useful traits to use with Behat on Laravel

0.1.1 2015-06-19 03:57 UTC

This package is not auto-updated.

Last update: 2024-11-23 17:17:19 UTC


README

Usage:

Add to composer.json

"require-dev": {
    "behat/behat": "3.0.*",
    "quiborgue/utils": "dev-master",
    "quiborgue/laravel-behat-traits": "dev-master"
},

Edit your FeatureContext

<?php
require_once __DIR__.'/../../bootstrap/autoload.php';

use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;

use Quiborgue\LaravelBehatTraits\Traits\LaravelSetup;
use Quiborgue\LaravelBehatTraits\Traits\RestContext;
use Quiborgue\LaravelBehatTraits\Traits\WebContext;

/**
 * Defines application features from the specific context.
 */
class FeatureContext implements Context, SnippetAcceptingContext
{
    use LaravelSetup;
    use RestContext;
    use WebContext;
    /**
     * Initializes context.
     *
     * Every scenario gets its own context instance.
     * You can also pass arbitrary arguments to the
     * context constructor through behat.yml.
     */
    public function __construct()
    {
    }
}

Available steps

RestContext |  When /^(?:I )?send a ([A-Z]+) request to "([^"]+)"$/
RestContext |  When /^(?:I )?send a ([A-Z]+) request to "([^"]+)" with parameters:$/
RestContext |  Then the response status should be :code
RestContext |  Then the JSON response should be:
RestContext |  Then the JSON response should be an array with :count elements
WebContext  | Given I am logged in
WebContext  |  When I visit :uri
WebContext  |  Then I should see :text