PHPUnit listener to run Laravel database migrations before each testsuite

3.1.0 2022-10-04 08:07 UTC


Latest Version Software License Build Status Coverage Status Quality Score Total Downloads Average time to resolve an issue Percentage of issues still open

This PHPUnit listener run Laravel migrations before each testsuit


Via composer:

composer require --dev softonic/laravel-database-migrate-test-listener


To use the listener add it to your phpunit.xml, defining on which test suites it should be activated, if it should seed data and the database connection to use.

    <listener class="Softonic\DatabaseMigrateTestListener\DatabaseMigrateTestListener">
              <element key="0">
              <element key="1">
            <integer>1</integer> <!-- Set 1 if you want to seed data -->
            <string>sqlite</string> <!-- Database connection -->
            <string>>App\\Database\\Seeds\\Foo\\DatabaseSeeder</string> <!-- Database Seeder -->

From now on before the specified test suite is run, the migrate:fresh Laravel command will be executed.


softonic/laravel-database-migrate-test-listener has a PHPUnit test suite and a coding style compliance test suite using PHP CS Fixer.

To run the tests, run the following command from the project folder.

$ docker-compose run test


The Apache 2.0 license. Please see LICENSE for more information.