tabbi89 / behat-silex-extension
Behat extension for silex
Installs: 1 106
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=5.3.9
- behat/behat: ~3.0,>=3.0.4
- behat/mink-browserkit-driver: ~1.3
- silex/silex: ^1.2,>=1.2
Requires (Dev)
- behat/mink: ~1.7
- behat/mink-extension: ~2.1
- phpspec/phpspec: ^2.4
This package is not auto-updated.
Last update: 2024-12-25 18:47:21 UTC
README
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.
Installation
composer require behat/behat behat/mink behat/mink-extension tabbi89/behat-silex-extension --dev
Usage
Next, within your project root, create a behat.yml
file, and add:
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
)
If You want to use extension with Your file as main point:
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
ApplicationDictionary
Just include ApplicationDictionary
trait in Your FeatureContext to access Your application:
use Behat\Behat\Context; use Behat\Behat\Context\SnippetAcceptingContext; use Tabbi89\Behat\SilexExtension\Context\ApplicationAwareContext; use Tabbi89\Behat\SilexExtension\Context\ApplicationDictionary; class FeatureContext implements SnippetAcceptingContext, ApplicationAwareContext { use ApplicationDictionary; /** * @Given I setup application */ public function iSetupApplication() { $session = $this->getService('session'); $application = $this->getApp(); // ... } }
License
This bundle is under the MIT license.