Skip to content

lasotaartur/phpspec-silex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

phpspec Silex Extension

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