Skip to content

[Bug]: extend(RefreshDatabase::class) refreshes local database #1663

@pavloselpidorou

Description

@pavloselpidorou

What Happened

When i use pest()->extend(Tests\TestCaseUnit::class)->in('Unit'); in my Pest.php when i run my tests it refreshes my database that i have configured in .env, even when my test database i have theses environment variables inside my phpunit.xml

<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>

How to Reproduce

On a Laravel application using Pest, add the following to your Pest.php

pest()->extend(Tests\TestCaseUnit::class)->extend(RefreshDatabase::class);

Set the values in phpunit.xml

<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>

or .env.testing should have

DB_CONNECTION=sqlite
DB_DATABASE=:memory:

Then when running tests, it should refresh the database used in your .env

Sample Repository

No response

Pest Version

4.4.2

PHP Version

8.4

Operation System

macOS

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions