Giter Club home page Giter Club logo

symfony2extension's Introduction

Symfony2Extension

Build Status

Provides integration layer for Symfony2:

  • Complete integration into Symfony2 bundle structure - you can run isolated bundle suite by bundle shortname, classname or even full path
  • KernelAwareInterface, which provides initialized and booted kernel instance for your contexts
  • Additional symfony2 session (sets as default) for Mink (if MinkExtension is installed)

between Behat 2.4+ and Symfony2+

Installation

This extension requires:

  • Behat 2.4+

Through PHAR

Download Behat phar from:

After downloading and placing behat.phar into project directory, you need to download and activate Symfony2Extension:

  1. Download extension

  2. Put downloaded phar package into folder with Behat

  3. Tell Behat about extensions with behat.yml configuration:

    # behat.yml
    defaults:
      # ...
      extensions:
        symfony2_extension.phar: ~

    For all configuration options, check extension configuration class.

Through Composer

  1. Set dependencies in your composer.json:

    {
        "require": {
            ...
    
            "behat/symfony2-extension": "*"
        }
    }
  2. Install/update your vendors:

    $> curl http://getcomposer.org/installer | php
    $> php composer.phar install
  3. Activate extension in your behat.yml:

    # behat.yml
    defaults:
      # ...
      extensions:
        Behat\Symfony2Extension\Extension: ~

Usage

After installing extension, there would be 2 usage options available for you:

  1. If you're on the php 5.4+, you can simply use Behat\Symfony2Extension\Context\KernelDictionary trait inside your FeatureContext or any of its subcontexts. This trait will provide getKernel() and getContainer() methods for you.
  2. Implementing Behat\Symfony2Extension\Context\KernelAwareInterface with your context or its subcontexts. This will give you more customization options. Also, you can use this mechanism on multiple contexts avoiding the need to call parent contexts from subcontexts when only thing you need is mink instance.

There's common thing between those 2 methods. In each of those, target context will implement setKernel(HttpKernel $kernel) method. This method would be automatically called immediately after each context creation before each scenario. Note that this kernel will be automatically rebooted between scenarios, so your scenarios would have almost absolutely isolated state.

Initialize bundle suite

Just run:

$> php behat.phar --init @YouBundleName

Run bundle suite

$> php behat.phar @YouBundleName

Using symfony2 Mink session

Symfony2Extension comes bundled with custom symfony2 session for Mink, which is disabled by default. In order to use it, you should download/install/activate MinkExtension and enabling mink_driver in Symfony2Extension:

# behat.yml
defaults:
  # ...
  extensions:
    symfony2_extension.phar:
      mink_driver: true
    mink_extension.phar: ~

Also, you can make symfony2 session default one by setting default_session option in MinkExtension:

# behat.yml
defaults:
  # ...
  extensions:
    symfony2_extension.phar:
      mink_driver: true
    mink_extension.phar:
      default_session: 'symfony2'

Copyright

Copyright (c) 2012 Konstantin Kudryashov (ever.zet). See LICENSE for details.

Contributors

Sponsors

symfony2extension's People

Contributors

everzet avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.