phpspec Extension for testing Silex applications.
Add this to your composer.json
:
{
"require": {
"lasotaartur/phpspec-silex": "dev-master"
}
}
then add this to your phpspec.yml
:
extensions:
- PhpSpec\Silex\Extension\SilexExtension
This extension provides you with a bootstrapped Silex environment when writing your phpspec tests.
in your phpspec.yml
.
By default, the extension will bootstrap your app by looking for app/bootstrap.php
.
You can manually specify the path to the bootstrap file, like so:
laravel_extension:
bootstrap_path: "/your/path/bootstrap.php"
Example of bootstrap.php
<?php
$app = new Silex\Application();
$app->get('/hello/{name}', function ($name) use ($app) {
return 'Hello '.$app->escape($name);
});
return $app;
If you want use silex $app extend your specs
from PhpSpec\Silex\SilexObjectBehavior
.
Example
<?php
namespace spec;
use PhpSpec\Silex\SilexObjectBehavior;
class ProductSpec extends SilexObjectBehavior
{
function it_let()
{
$this->app #this is silex application
}
}