Skip to content

Commit

Permalink
Renamed the extension class to benefit from the behat shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
stof committed May 9, 2014
1 parent cbcd688 commit a9fea2e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 92 deletions.
108 changes: 25 additions & 83 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,6 @@ This extension requires:

* Behat 3.0+

Through PHAR
~~~~~~~~~~~~

First, download phar archives:

* `behat.phar <http://behat.org/downloads/behat.phar>`_ - Behat itself
* `symfony2_extension.phar <http://behat.org/downloads/symfony2_extension.phar>`_
- integration extension

After downloading and placing ``*.phar`` into project directory, you need to
activate ``Symfony2Extension`` in your ``behat.yml``:

.. code-block:: yaml
default:
# ...
extensions:
symfony2_extension.phar: ~

Through Composer
~~~~~~~~~~~~~~~~
Expand All @@ -51,7 +32,7 @@ The easiest way to keep your suite updated is to use `Composer <http://getcompos
{
"require": {
...
"behat/symfony2-extension": "~2.0@dev"
}
}
Expand All @@ -69,7 +50,7 @@ The easiest way to keep your suite updated is to use `Composer <http://getcompos
default:
# ...
extensions:
Behat\Symfony2Extension\Extension: ~
Behat\Symfony2Extension: ~
4. Register a suite for your bundle:

Expand All @@ -81,37 +62,24 @@ The easiest way to keep your suite updated is to use `Composer <http://getcompos
type: symfony_bundle
bundle: AcmeDemoBundle
.. note::

If you're using Symfony2.1 with Composer, there could be a conflict of
Symfony2 with Behat, that will prevent Symfony2 from loading Doctrine
or Validation annotations. This is not a problem with the latest version
of Composer, but if you are running an older version and see errors,
just update your ``app/autoload.php``:

.. code-block:: php
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
Through PHAR
~~~~~~~~~~~~

if (!class_exists('Composer\\Autoload\\ClassLoader', false)) {
$loader = require __DIR__.'/../vendor/autoload.php';
} else {
$loader = new Composer\Autoload\ClassLoader();
$loader->register();
}
First, download phar archives:

// intl
if (!function_exists('intl_get_error_code')) {
require_once __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
* `behat.phar <http://behat.org/downloads/behat.phar>`_ - Behat itself
* `symfony2_extension.phar <http://behat.org/downloads/symfony2_extension.phar>`_
- integration extension

$loader->add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');
}
After downloading and placing ``*.phar`` into project directory, you need to
activate ``Symfony2Extension`` in your ``behat.yml``:

AnnotationRegistry::registerLoader('class_exists');
.. code-block:: yaml
return $loader;
default:
# ...
extensions:
symfony2_extension.phar: ~
.. note::

Expand All @@ -127,7 +95,7 @@ The easiest way to keep your suite updated is to use `Composer <http://getcompos
},
This will make the ``behat`` command available from the ``bin`` directory. If you run
behat this way, you do not need to download ``behat.phar``.
behat this way, you do not need to download ``behat.phar``

Usage
-----
Expand Down Expand Up @@ -206,47 +174,24 @@ BrowserKit driver for Mink:
}
}
The new Mink driver will be enabled automatically.
The new Mink driver will be available for usage:

.. code-block:: yaml
default:
# ...
extensions:
Behat\Symfony2Extension\Extension: ~
Behat\MinkExtension\Extension: ~
Also, you can make the ``symfony2`` session the default one by setting ``default_session``
option in MinkExtension:

.. code-block:: yaml
default:
# ...
extensions:
Behat\Symfony2Extension\Extension: ~
Behat\MinkExtension\Extension:
default_session: 'symfony2'
Behat\Symfony2Extension: ~
Behat\MinkExtension:
sessions:
my_session:
symfony2: ~
.. caution::

The KernelDriver of the symfony2 session requires using a Symfony environment where
the test mode of the FrameworkBundle is enabled. It uses the ``test`` environment by
default, for which it is the case in the Symfony2 Standard Edition.

.. note::

If you use the MinkExtension but don't want to enable the symfony2 session,
you can disable it explicitly:

.. code-block:: yaml
default:
# ...
extensions:
Behat\Symfony2Extension\Extension:
mink_driver: false
Behat\MinkExtension\Extension: ~
The KernelDriver requires using a Symfony environment where the test mode of the
FrameworkBundle is enabled. It uses the ``test`` environment by default, for which it
is the case in the Symfony2 Standard Edition.

Configuration
-------------
Expand Down Expand Up @@ -274,6 +219,3 @@ configure Symfony2 kernel inside Behat to fulfil all your needs.
``Features\Context\FeatureContext``.
- ``class_suffix`` - suffix from bundle classname for context class. Defaults to
``Features``.

* ``mink_driver`` - if set to true - extension will load the ``symfony2`` session
for Mink.
2 changes: 1 addition & 1 deletion init.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
}
}, true, false);

return new Behat\Symfony2Extension\Extension;
return new Behat\Symfony2Extension\ServiceContainer\Symfony2Extension;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace spec\Behat\Symfony2Extension\ServiceContainer\Driver;

use Behat\Symfony2Extension\Extension;
use Behat\Symfony2Extension\ServiceContainer\Symfony2Extension;
use PhpSpec\ObjectBehavior;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;

Expand Down Expand Up @@ -36,6 +36,6 @@ function it_creates_a_kernel_driver_definition()
$definition->getClass()->shouldBe('Behat\Symfony2Extension\Driver\KernelDriver');
$args = $definition->getArguments();
$args[0]->shouldBeAnInstanceOf('Symfony\Component\DependencyInjection\Reference');
$args[0]->__toString()->shouldBe(Extension::KERNEL_ID);
$args[0]->__toString()->shouldBe(Symfony2Extension::KERNEL_ID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Behat\Symfony2Extension\ServiceContainer\Driver;

use Behat\MinkExtension\ServiceContainer\Driver\DriverFactory;
use Behat\Symfony2Extension\Extension;
use Behat\Symfony2Extension\ServiceContainer\Symfony2Extension;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
Expand Down Expand Up @@ -57,7 +57,7 @@ public function buildDriver(array $config)
}

return new Definition('Behat\Symfony2Extension\Driver\KernelDriver', array(
new Reference(Extension::KERNEL_ID),
new Reference(Symfony2Extension::KERNEL_ID),
'%mink.base_url%',
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* with this source code in the file LICENSE.
*/

namespace Behat\Symfony2Extension;
namespace Behat\Symfony2Extension\ServiceContainer;

use Behat\Behat\Context\ServiceContainer\ContextExtension;
use Behat\Behat\Gherkin\ServiceContainer\GherkinExtension;
Expand All @@ -28,8 +28,9 @@
* Symfony2 extension for Behat class.
*
* @author Konstantin Kudryashov <[email protected]>
* @author Christophe Coevoet <[email protected]>
*/
class Extension implements ExtensionInterface
class Symfony2Extension implements ExtensionInterface
{
const KERNEL_ID = 'symfony2_extension.kernel';

Expand Down
4 changes: 2 additions & 2 deletions testapp/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ default:
progress:
paths: false
extensions:
Behat\Symfony2Extension\Extension: ~
Behat\MinkExtension\Extension:
Behat\Symfony2Extension: ~
Behat\MinkExtension:
default_session: 'symfony2'
sessions:
symfony2:
Expand Down

0 comments on commit a9fea2e

Please sign in to comment.