pavlakis/slim-behat-extension

Slim 3 extension for Behat

1.0.1 2016-01-11 23:24 UTC

README

This extension was written based on the Behat Laravel Extension

Can install it with composer through packagist

 composer require --dev pavlakis/slim-behat-extension

On your behat.yml file add the extension within the extensions section

    Pavlakis\Slim\Behat: ~

The above is the minimum setup as long as you are using Akrabat's Slim 3 Skeleton with the default location for settings.php at app/settings.php

Alternatively, pass the location of the config_file

  config_file: ../../app/configs/settings_test.php

Apart from the config (settings.php) all other parameters are optional, however you can also pass:

      config_file: ../../app/configs/settings_test.php
      dependencies_file: ../../app/dependencies.php
      middleware_file: ../../middleware.php
      routes_file: ../../routes.php

In your FeatureContext file

  • Include the KernelAwareContext interface
  • Include the Pavlakis\Slim\Behat\Context\App trait
  • Access the Slim 3 app using $this->app

Feature Context example using Mink

use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;

use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\MinkExtension\Context\MinkContext;
use Pavlakis\Slim\Behat\Context\App;
use Pavlakis\Slim\Behat\Context\KernelAwareContext;

/**
 * Defines application features from the specific context.
 */
class FeatureContext extends MinkContext implements Context, SnippetAcceptingContext, KernelAwareContext
{
    use App;

    /**
     * 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()
    {
    }
}

Accessing your dependencies

$this->app->getContainer()->get('db')