You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After installing a new Laravel 12 project with PHPUnit as the testing framework and adding Laravel sail, configured with MariaDB as the database server, attempting to run sail artisan test or sail test results in 100% failure, as Laravel attempts to connect to MariaDB specifying a database named :memory:, instead of a named testing database or an in-memory database.
newproject-mariadb-1 | 2025-03-07 6:24:12 9 [Warning] Access denied for user 'sail'@'%' to database ':memory:'
(repeated 27x,)
The documentation for sail, in Laravel version 12 reads:
By default, Sail will create a dedicated testing database so that your tests do not interfere with the current state of your database. In a default Laravel installation, Sail will also configure your phpunit.xml file to use this database when executing your tests: <env name="DB_DATABASE" value="testing"/>
However, when inspecting the phpunit.xml file in the project after installing sail, the value for that env tag still reads :memory:, the default value from the Laravel installation.
After changing the value to testing and running sail artisan test, PHPUnit connects to MariaDB and uses the testing database as described, leading to no errors.
Steps To Reproduce
Install a new Laravel 12 project (in this case, I used the composer installer, v 5.13.0, selecting Vue, Laravel's built-in authentication and PHPUnit at their respective prompts)
Install Laravel Sail, (I chose MariaDB, Redis, Mailpit and Selenium at the services prompt).
Run ./vendor/bin/sail up and wait for all services to be available.
In another console window, run sail artisan test or sail test
Observe the described failure.
The text was updated successfully, but these errors were encountered:
I did not observe any errors from the InteractsWithDockerComposeServices.php method configurePhpUnit() when running php artisan sail:install, so I am at a loss as to why it didn't properly replace this value.
As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.
If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.
As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.
If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.
Thank you!
There are at least 2 ways:
fix tests config :memory: => testing
fix tests to use correct db driver from config (currently - :memory:)
Sail Version
1.41
Laravel Version
12.0
PHP Version
8.3.14
Operating System
Windows (WSL)
OS Version
10 (Build 19045.5371)
Description
After installing a new Laravel 12 project with PHPUnit as the testing framework and adding Laravel sail, configured with MariaDB as the database server, attempting to run
sail artisan test
orsail test
results in 100% failure, as Laravel attempts to connect to MariaDB specifying a database named:memory:
, instead of a named testing database or an in-memory database.The documentation for sail, in Laravel version 12 reads:
However, when inspecting the phpunit.xml file in the project after installing sail, the value for that env tag still reads
:memory:
, the default value from the Laravel installation.After changing the value to
testing
and runningsail artisan test
, PHPUnit connects to MariaDB and uses thetesting
database as described, leading to no errors.Steps To Reproduce
./vendor/bin/sail up
and wait for all services to be available.sail artisan test
orsail test
The text was updated successfully, but these errors were encountered: