{"id":18796019,"url":"https://github.com/dees040/festing","last_synced_at":"2025-04-13T15:42:02.381Z","repository":{"id":56964706,"uuid":"126000853","full_name":"dees040/festing","owner":"dees040","description":"Fasten up your unit tests in Laravel by more than 100%","archived":false,"fork":false,"pushed_at":"2020-03-04T15:30:49.000Z","size":29,"stargazers_count":36,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-27T06:44:41.462Z","etag":null,"topics":["laravel","php","unit-testing"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dees040.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-20T10:32:10.000Z","updated_at":"2022-10-15T15:32:29.000Z","dependencies_parsed_at":"2022-08-21T06:10:09.984Z","dependency_job_id":null,"html_url":"https://github.com/dees040/festing","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dees040%2Ffesting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dees040%2Ffesting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dees040%2Ffesting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dees040%2Ffesting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dees040","download_url":"https://codeload.github.com/dees040/festing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248739997,"owners_count":21154248,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","php","unit-testing"],"created_at":"2024-11-07T21:36:09.563Z","updated_at":"2025-04-13T15:42:02.361Z","avatar_url":"https://github.com/dees040.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fast Laravel Testing\n\n\u003ca href=\"https://packagist.org/packages/dees040/festing\"\u003e\u003cimg src=\"https://poser.pugx.org/dees040/festing/v/stable\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/dees040/festing\"\u003e\u003cimg src=\"https://poser.pugx.org/dees040/festing/downloads\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://travis-ci.org/dees040/festing\"\u003e\u003cimg src=\"https://travis-ci.org/dees040/festing.svg?branch=master\" alt=\"Build status\"\u003e\u003c/a\u003e\n\nFesting 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/).\n\nBefore 'Festing':\n\n![Before fast database tests](https://i.imgur.com/mbtRUS3.png)\n\nAfter 'Festing':\n\n![After fast database tests](https://i.imgur.com/KfZsFm1.png)\n\n## Installation\n\nInstallation 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.\n\n```bash\ncomposer require --dev dees040/festing\n```\n\nIf you're using Laravel \u003e= 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`.\n\n```php\nDees040\\Festing\\ServiceProvider::class,\n```\n\nYou're now ready for setup.\n\nThe 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\n\n```bash\nphp artisan vendor:publish --provider=\"Dees040\\Festing\\ServiceProvider\" --tag=\"config\"\n```\n\n## Setup\n\nFirst you should update the `database.php` config file. We should add a connection specifically for testing. You can use the following array.\n\n```php\n'testing' =\u003e [\n    'driver' =\u003e 'sqlite',\n    'database' =\u003e database_path('testing.sqlite'),\n    'prefix'   =\u003e '',\n],\n```\n\nIn 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 `\u003cphp\u003e` tag located in the `phpunit.xml` file.\n\n```xml\n\u003cenv name=\"DB_CONNECTION\" value=\"testing\"/\u003e\n```\n\nBecause 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`.\n\n```php\n\nuse Dees040\\Festing\\FestTheDatabase;\nuse Illuminate\\Foundation\\Testing\\TestCase as BaseTestCase;\n\nabstract class TestCase extends BaseTestCase\n{\n    use CreatesApplication, FestTheDatabase;\n\n\n    /**\n     * Boot the testing helper traits.\n     *\n     * @return array\n     */\n    protected function setUpTraits()\n    {\n        $uses = parent::setUpTraits();\n    \n        if (isset($uses[\\Dees040\\Festing\\ShouldFest::class])) {\n            $this-\u003erunFester();\n        }\n    \n        return $uses;\n    }\n```\n\nIf 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.\n\n### In test cases\n\nTo 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.\n\n```php\n\u003c?php\n\nnamespace Tests\\Unit;\n\nuse Tests\\TestCase;\nuse Dees040\\Festing\\ShouldFest;\n\nclass ExampleTest extends TestCase\n{\n    use ShouldFest;\n    \n    /**\n     * A basic test example.\n     *\n     * @return void\n     */\n    public function testBasicTest()\n    {\n        $this-\u003eassertTrue(true);\n    }\n}\n```\n\n### Command\n\nThe package come with a command (`make:fest`) which is the same as `php artisan make:test`. The only difference is that it uses the `ShouldFest` trait instead of the default `RefreshDatabase` trait provided by Laravel.\n\n## Config\n\nCheck the [config file](https://github.com/dees040/festing/blob/master/src/config/festing.php) for descriptions about all the config.\n\n### Cached data\n\nBefore we cache the data to make the tests significantly faster we run a list of artisan commands. Be default we run `php artisan migrate`. But if you'd like to change this or want to run more commands (i.e. `php artisan db:seed`) you can change the `commands` array config value. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdees040%2Ffesting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdees040%2Ffesting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdees040%2Ffesting/lists"}