Skip to content

Limit the number of migrations/seeders run during phpunit tests with Sqlite. Designed for repos with a large number of migrations/seeders to quickly refresh the database.

License

Notifications You must be signed in to change notification settings

brandonbest/php-unittest-sqlite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP UnitTest Sqlite

This package optimizes unit testing speed, especially for packages with a large number of migrations and/or seeders.

The package works by managing two copies of a sqlite database, base and copy. Migrations and seeders are run on copy if base does not exist. Copy is cloned into base. Every unit test with RefreshDatabase trait will delete copy and clone base into copy.

Base is deleted at the end of the unit test (you can keep Base around with a simple configuration update).


Setup

Install

composer require --dev brandonbest/php-unittest-sqlite

PHP Unit

Add the following listener to phpunit.xml.

<listeners>
    <listener class="BrandonBest\UnittestSqlite\DatabaseTestListener"/>
</listeners>

Commands

php artisan sqlite:delete Deletes the base file.

Future Plans

  • Automatically detect new migrations and update the base sqlite

About

Limit the number of migrations/seeders run during phpunit tests with Sqlite. Designed for repos with a large number of migrations/seeders to quickly refresh the database.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages