Introduction
code-distortion/adapt is a package for Laravel that builds databases for your tests.
How it Works
Adapt works in the same way that Laravel's database-building traits work - when you run your test-suite, it builds your database before each test.
It's designed to get the most speed and convenience from your test-databases.
Features
- Adapt is a swap-in replacement for Laravel's
RefreshDatabase
,DatabaseMigrations
, andDatabaseTransactions
traits. - To get the best speeds, your databases are reused (when possible) each time you run your tests.
- A new (experimental MySQL) journaling method for reusing databases. This is an alternative for when transactions can't be used (like when browser testing).
- You don't need to create empty databases beforehand. They're created automatically.
- There's no need to drop or rebuild databases yourself. They are automatically rebuilt when you change your migrations, seeders or factories.
- Lets you import custom sql-dump files before running your migrations.
- Your tests can use different seeders for different tests, without them needing to be re-run each time.
- You can include Dusk browser tests in your normal test run - there's no need to run
php artisan dusk
separately. - You can run your tests in parallel, separate databases are created for each process.
- You can also run Dusk browser tests in parallel.
- If your project has more than one database, you can build them as well. Each with their own migrations and seeders.
- If you have two or more Laravel codebases in your project, you can have one build databases for the others.
Compatibility
- Databases: MySQL, MariaDB, PostgreSQL, SQLite and SQLite :memory:
- Testing frameworks and tools: PHPUnit, Pest, ParaTest and Dusk
- Laravel: 5.1 - 10.x
- PHP: 7.0 - 8.2
- OS: Linux and macOS