Skip to content

PHPunit Tests failing after upgrading to Laravel 11 #51652

Answered by javis
javis asked this question in General
Discussion options

You must be logged in to vote

I finally was able to find the fix.

In order for the new RefreshDatabase Trait to work with multiple database connections, you have to specify the names of the databases in your Test class using the connectionsToTransact property.

Example:

<?php

namespace Tests;


use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

abstract class TestCase extends BaseTestCase
{
    use RefreshDatabase;

    protected $connectionsToTransact = [
        'sqlite',
        'legacy',
        'issues',
    ];
    
}

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by javis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants