Skip to content

Default phpunit.xml configuration invalid for testing and does not match the documentation. #773

Open
@bredmor

Description

@bredmor

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 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

  1. 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)
  2. Install Laravel Sail, (I chose MariaDB, Redis, Mailpit and Selenium at the services prompt).
  3. Run ./vendor/bin/sail up and wait for all services to be available.
  4. In another console window, run sail artisan test or sail test
  5. Observe the described failure.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions