2.2 documentation

Basic Usage

To use Orchestra\Testbench, all you need to do is extend Orchestra\Testbench\TestCase instead of PHPUnit_Framework_TestCase. The fixture app booted by Orchestra\Testbench\TestCase is predefined to follow the base application skeleton of Laravel 4.


class TestCase extends Orchestra\Testbench\TestCase {}

Custom Service Provider

To load your package service provider, override the getPackageProviders.

protected function getPackageProviders()
    return array('Acme\AcmeServiceProvider');

Custom Aliases

To load your package alias, override the getPackageAliases.

protected function getPackageAliases()
    return array(
        'Acme' => 'Acme\Facade'

Overriding setUp() method

Since Orchestral\TestCase overrides Laravel's TestCase, if you need your own setUp() implementation, do not forget to call parent::setUp():

public function setUp()

    // Your code here

Testing Route Filters

By default, route filters are disabled by Laravel because, ideally, you should test the filter separately. In order to overwrite this default, add the following code:


Working with Workbench

Cannot redeclare crypt_random_string()

Due to the requirement with Laravel Framework 4.1, we need to maintain a modified version of phpseclib/phpseclib for developing Laravel/PHP packages using workbench. In order to make this work please include the following code in both your composer.json file for app and workbench:

    "repositories": [
            "type": "vcs",
            "url": "git://github.com/orchestral/phpseclib.git"

Class 'Illuminate\Foundation\Testing\TestCase' not found

Fatal error: Class 'Illuminate\Foundation\Testing\TestCase' not found in /laravel/workbench/foo/bar/vendor/orchestra/testbench/src/Orchestra/Testbench/TestCase.php

Due to the requirement to include laravel/framework when you install orchestra/testbench, please remove any Illuminate dependencies to avoid a failed installation.