quiborgue / php-laravel-behat-traits by calimaborges

Useful traits to use with Behat on Laravel
518
0
3
Package Data
Maintainer Username: calimaborges
Maintainer Contact: dev@quiborgue.com (Quiborgue)
Package Create Date: 2015-06-18
Package Last Update: 2015-06-19
Language: PHP
License: MIT
Last Refreshed: 2024-11-22 03:09:04
Package Statistics
Total Downloads: 518
Monthly Downloads: 2
Daily Downloads: 0
Total Stars: 0
Total Watchers: 3
Total Forks: 0
Total Open Issues: 0

Laravel Behat Traits

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