A Laravel package that builds databases for your tests, improving their speed.

0.12.12 2024-08-15 04:13 UTC

README

Latest Version on Packagist PHP Version Laravel GitHub Workflow Status Buy The World a Tree Contributor Covenant

code-distortion/adapt is a package for Laravel that builds databases for your tests.

Features

  • Adapt is a swap-in replacement for Laravel's RefreshDatabase, DatabaseMigrations, and DatabaseTransactions 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.

Documentation

The documentation for this package has a its own dedicated page. Please look there for details on how to install and configure Adapt.

Changelog

Please see CHANGELOG for more information on what has changed recently.

SemVer

This library uses SemVer 2.0.0 versioning. This means that changes to X indicate a breaking change: 0.0.X, 0.X.y, X.y.z. When this library changes to version 1.0.0, 2.0.0 and so forth, it doesn't indicate that it's necessarily a notable release, it simply indicates that the changes were breaking.

Testing

composer test

Treeware

This package is Treeware. If you use it in tests of a production project, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

Contributing

Please see CONTRIBUTING for details.

Code of Conduct

Please see CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email tim@code-distortion.net instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.