2017 © Pedro Peláez
 

library behat-sf2-service-generator

Behat Symfony2 service generator

image

kix/behat-sf2-service-generator

Behat Symfony2 service generator

  • Thursday, November 20, 2014
  • by kix
  • Repository
  • 0 Watchers
  • 1 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Behat Symfony2 service generator

This is a Behat extension that catches calls to undefined Symfony services and runs PHPSpec to describe them., (*1)

Installation

Just run this:, (*2)

    composer require kix/behat-sf2-service-generator "~0.1" 

And then enable the extension in your behat.yml:, (*3)

default:
  # ...
  extensions:
    Kix\Symfony2ServiceExtension\Symfony2ServiceExtension: ~

Now, when you try to access a non-existent service, you'll be asked if you want to generate a class for it. A YAML config will be dumped on the console for your convinience, too. Here's a quick peek at what it looks like., (*4)

Feature: Generating Symfony services
  Scenario: Creating a service when a ServiceNotFoundException is caught
    When I run behat
    And my step tries to get a service that doesn't exist
    Then a shiny notification is displayed asking if I want to generate it
<?php
class FeatureContext implements Context, SnippetAcceptingContext
{

    // Note I'm using Symfony2Extension here:
    use \Behat\Symfony2Extension\Context\KernelDictionary;

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

    /**
     * @When I run behat
     */
    public function iRunBehat()
    {
        // do nothing
    }

    /**
     * @When my step tries to get a service that doesn't exist
     */
    public function myStepTriesToGetAServiceThatDoesnTExist()
    {
        $this->getContainer()->get('my_bundle.kitten_provider');
    }

}

And boom:, (*5)

Example, (*6)

The Versions

20/11 2014

dev-master

9999999-dev https://github.com/kix/BehatExceptionListener

Behat Symfony2 service generator

  Sources   Download

MIT

The Requires

 

by Stepan Anchugov

bdd symfony2 specbdd storybdd

20/11 2014

0.1.0

0.1.0.0 https://github.com/kix/BehatExceptionListener

Behat Symfony2 service generator

  Sources   Download

MIT

The Requires

 

by Stepan Anchugov

bdd symfony2 specbdd storybdd