lasotaartur/phpspec-silex

Test your Silex applications with PhpSpec

2.0.0 2017-12-05 07:14 UTC

This package is not auto-updated.

Last update: 2024-04-07 06:40:24 UTC


README

phpspec Extension for testing Silex applications.

Installation

Add this to your composer.json:

{
    "require": {
        "lasotaartur/phpspec-silex": "dev-master"
    }
}

then add this to your phpspec.yml:

extensions:
    - PhpSpec\Silex\Extension\SilexExtension

Why this extension?

This extension provides you with a bootstrapped Silex environment when writing your phpspec tests.

Configuration

in your phpspec.yml.

App bootstrap path

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;

Usage

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
    }
}