2017 © Pedro Peláez
 

library behat-silex-extension

Behat extension for silex

image

tabbi89/behat-silex-extension

Behat extension for silex

  • Friday, February 24, 2017
  • by tabbi89
  • Repository
  • 2 Watchers
  • 0 Stars
  • 509 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 1 % Grown

The README.md

BehatSilexExtension

This extension offers an easy way to begin testing Silex applications with Behat. If You are familiar with Symfony2Extension for behat then setup with this extension will be very simple. Like the extension mentioned above it uses bare Application do it doesn't depend on anything else like Goutte so it is just faster in usage. On each scenario we have fresh new instance of Application. Extension offers ApplicationDictionary which allows to access Your application., (*1)

Build Status, (*2)

Installation

``` bash composer require behat/behat behat/mink behat/mink-extension tabbi89/behat-silex-extension --dev, (*3)


Usage ----- Next, within your project root, create a `behat.yml` file, and add: ```YAML default: extensions: Tabbi89\Behat\SilexExtension: kernel: bootstrap: app/autoload.php class: Tabbi89\Behat\SilexExtension\Tests\TestApp\App\Application env: test debug: true testSession: true Behat\MinkExtension: default_session: silex sessions: silex: silex: ~

Here, is where we reference the Silex extension, and tell Behat to use it as our default session. Extension allows some basic configuration values which will be passed to Your application (env, debug, testSession), (*4)

If You want to use extension with Your file as main point:, (*5)

default:
    extensions:
        Tabbi89\Behat\SilexExtension:
            kernel:
                bootstrap: app/autoload.php
                path: app/Application.php
                env: test
                debug: true
                testSession: true
        Behat\MinkExtension:
            default_session: silex
            sessions:
                silex:
                    silex: ~

If You have more questions about application looks check examples in tests/app/* and configuration tests/behat.yml.dist, (*6)

ApplicationDictionary

Just include ApplicationDictionary trait in Your FeatureContext to access Your application:, (*7)

``` PHP, (*8)

use Behat\Behat\Context; use Behat\Behat\Context\SnippetAcceptingContext; use Tabbi89\Behat\SilexExtension\Context\ApplicationAwareContext; use Tabbi89\Behat\SilexExtension\Context\ApplicationDictionary;, (*9)

class FeatureContext implements SnippetAcceptingContext, ApplicationAwareContext { use ApplicationDictionary;, (*10)

/**
 * @Given I setup application
 */
public function iSetupApplication()
{
    $session = $this->getService('session');
    $application = $this->getApp();
    // ...
}

} ```, (*11)

License

This bundle is under the MIT license., (*12)

The Versions