softonic / laravel-database-migrate-test-listener
PHPUnit listener to run Laravel database migrations before each testsuite
Installs: 11 564
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 13
Forks: 0
Open Issues: 0
Requires
- php: >=7.3
- illuminate/support: ^7.0 || ^8.0 || ^9.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- php-mock/php-mock-mockery: ^1.3
- phpunit/phpunit: ^9.0
README
This PHPUnit listener run Laravel migrations before each testsuit
Installation
Via composer:
composer require --dev softonic/laravel-database-migrate-test-listener
Documentation
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.
<listeners>
...
<listener class="Softonic\DatabaseMigrateTestListener\DatabaseMigrateTestListener">
<arguments>
<array>
<element key="0">
<string>Feature</string>
</element>
<element key="1">
<string>Integration</string>
</element>
</array>
<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 -->
</arguments>
</listener>
...
</listeners>
From now on before the specified test suite is run, the migrate:fresh
Laravel command will be executed.
Testing
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
License
The Apache 2.0 license. Please see LICENSE for more information.