Hydra provides a simple and clean way to test Laravel and Lumen packages against multiple versions.

0.1.10 2020-12-29 11:14 UTC

This package is auto-updated.

Last update: 2021-09-06 17:29:09 UTC


Simple and clean testing for Laravel and Lumen packages. Supports Laravel/Lumen 5.8.x, 6.x, 7.x and 8.x.

Stability disclaimer

This package is still in early development stage, and there are many bugs and planned features. Use it at your own risk.


  • PHP 7.1.3 to 8.0


This package what greatly inspired by the orchestra/testbench package.


Hydra configuration must be written at the base of your project. The recognized file names are the following:

  • hydra.yaml
  • hydra.yml
  • hydra.json
  • hydra.php
  • .hydra.yaml
  • .hydra.yml
  • .hydra.json
  • .hydra.php

sandbox (defaults to ./hydra)

The hydra base directory, where the benches will be installed.


A bench is described by a name (its key) and the framework (laravel or lumen) and the framework version constraint. For example, the following configuration:

    framework: laravel
    constraint: ^7.0

will create a bench laravel-7 using the laravel/laravel framework and the SemVer constraint ^7.0.

composer (defaults to composer)

Since Hydra relies on the composer executable, you may want to override the composer executable.

For example:

composer: /user/bin/composer.phar


Installing benches

To install the benches defined in the configuration file, run:

vendor/bin/hydra install

You may use the --only [bench] to install only a single bench (during matrix pipelines).

Cleaning benches

To delete all your benches, simply run:

vendor/bin/hydra clean

In PHPUnit tests

Setup PHPUnit

Since Hydra will basically hijack composer autoloader, you will need to replace the PHPUnit bootstrap file. During installation, Hydra generates a new bootstrap file which has to be specified in PHPUnit configuration.

For example, in a phpunit.xml file:

    <!-- Your other configurations -->

Choose the test bench

The test bench selection is achieved through the HYDRA_BENCH environment variable.

You can run phpunit like this:

HYDRA_BENCH=laravel-7 phpunit [args]

Use the HydraTestCase

In order to set up tests for your package, you have to use the Windy\Hydra\Testing\HydraTestCase class.

Define a configuration:
use Windy\Hydra\Testing\HydraTestCase;

class ExampleTest extends HydraTestCase
    protected function setUpConfig(): array
        return [
            'your-package' => [
                'foo' => 'bar'
Define your providers
use Windy\Hydra\Testing\HydraTestCase;

class ExampleTest extends HydraTestCase
    protected function setUpProviders(): array
        return [
Specific setup for Laravel and Lumen

If you need to run specific setup for Laravel or Lumen, you may use:

use Windy\Hydra\Testing\HydraTestCase;

class ExampleTest extends HydraTestCase
     * Set up Laravel application.
    protected function setUpLaravel(): void
        // Run only for Laravel applications

     * Setup the Lumen application.
    protected function setUpLumen(): void
        // Run only for Lumen applications