PHPackages                             dees040/festing - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. dees040/festing

ActiveLibrary[Testing &amp; Quality](/categories/testing)

dees040/festing
===============

Fasten up your unit tests in Laravel by more than 100%

1.0.6(6y ago)364.3kMITPHPCI failing

Since Mar 20Pushed 6y ago4 watchersCompare

[ Source](https://github.com/dees040/festing)[ Packagist](https://packagist.org/packages/dees040/festing)[ RSS](/packages/dees040-festing/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (4)Versions (10)Used By (0)

Fast Laravel Testing
====================

[](#fast-laravel-testing)

[![Latest Stable Version](https://camo.githubusercontent.com/4cf4bca0698dc448e1701106db9b10bbb9e217be4a459a624f8942e339d63e58/68747470733a2f2f706f7365722e707567782e6f72672f646565733034302f66657374696e672f762f737461626c65)](https://packagist.org/packages/dees040/festing)[![Total Downloads](https://camo.githubusercontent.com/a8738184d4d63edcf62b685820399a4ae9eb7cd92ed94c178602b493277c39cf/68747470733a2f2f706f7365722e707567782e6f72672f646565733034302f66657374696e672f646f776e6c6f616473)](https://packagist.org/packages/dees040/festing)[![Build status](https://camo.githubusercontent.com/b6a915a1c4fc628a3ef71c4a3f6c5e3203208cffb5e59a9459ae1c190bf7dfec/68747470733a2f2f7472617669732d63692e6f72672f646565733034302f66657374696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/dees040/festing)

Festing is a very very great name made by combining the words fast and testing. Because that is what this package is for. Faster tests in Laravel. The package is inspired by a great article from [Nate Denlinger](https://natedenlinger.com/my-suggestions-to-speed-up-testing-with-laravel-and-phpunit/).

Before 'Festing':

[![Before fast database tests](https://camo.githubusercontent.com/6937939d6cb15913aa1101ac77586fb8ab3b71c1ab995458cc6ebdc4fe6c68f8/68747470733a2f2f692e696d6775722e636f6d2f6d6274525553332e706e67)](https://camo.githubusercontent.com/6937939d6cb15913aa1101ac77586fb8ab3b71c1ab995458cc6ebdc4fe6c68f8/68747470733a2f2f692e696d6775722e636f6d2f6d6274525553332e706e67)

After 'Festing':

[![After fast database tests](https://camo.githubusercontent.com/68d83ef3ddb563c5fd18db61d08d6eb0ccd9fc19dd3b794b5bbc55bcc59977fe/68747470733a2f2f692e696d6775722e636f6d2f4b665a73466d312e706e67)](https://camo.githubusercontent.com/68d83ef3ddb563c5fd18db61d08d6eb0ccd9fc19dd3b794b5bbc55bcc59977fe/68747470733a2f2f692e696d6775722e636f6d2f4b665a73466d312e706e67)

Installation
------------

[](#installation)

Installation and setup time is estimated to be around 5 minutes in existing Laravel projects and 2 minutes in new projects. Install this package via composer.

```
composer require --dev dees040/festing
```

If you're using Laravel &gt;= 5.5 this package will automatically be added to your providers list. If using a lower version, add the service provider to the `providers` array in `config/app.php`.

```
Dees040\Festing\ServiceProvider::class,
```

You're now ready for setup.

The package comes with a small config file. The default config should be good in most use cases. However, feel free to change it. To publish the config file run the following command

```
php artisan vendor:publish --provider="Dees040\Festing\ServiceProvider" --tag="config"
```

Setup
-----

[](#setup)

First you should update the `database.php` config file. We should add a connection specifically for testing. You can use the following array.

```
'testing' => [
    'driver' => 'sqlite',
    'database' => database_path('testing.sqlite'),
    'prefix'   => '',
],
```

In the package config you can specify which connection to use while testing. By default it will use the `testing` connection, which we've just added to the `connections` array. You should also add or update this in `` tag located in the `phpunit.xml` file.

```

```

Because Laravel don't have an option to boot your testing traits like the model traits we need to add a little bit of functionality in our `tests/TestCase.php` file. If you haven't overwritten the `setUpTraits()` method yet, you can add this to the `TestCase.php`.

```
use Dees040\Festing\FestTheDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
    use CreatesApplication, FestTheDatabase;

    /**
     * Boot the testing helper traits.
     *
     * @return array
     */
    protected function setUpTraits()
    {
        $uses = parent::setUpTraits();

        if (isset($uses[\Dees040\Festing\ShouldFest::class])) {
            $this->runFester();
        }

        return $uses;
    }
```

If you already have overwritten the `setUpTraits()` method just add the if statement to the method body. **Also your `TestCase.php` should use the `FestTheDatabase` trait.** In the examples directory you can see an example `TestCase.php` and unit test.

### In test cases

[](#in-test-cases)

To actually execute the database refresher you need to use `ShouldFest` trait in your test cases. This traits is used like the `ShouldQueue` interface, it only executes the code if it's detected. It also replaces the `RefreshDatabase` trait from Laravel.

```
