lara65535's avatar

DB Not Persisting Through UnitTests

My testing, in memory, sqlite database is not persisting through model calls... The code is the following...

public function setUp()
{
    parent::setUp();

    dd(DB::connection()->getName(), User::all()->first()->getConnectionName());
}

and the result is ...

testing
mysql

Why is the database being reset through the model calls

0 likes
2 replies
patrickcarlohickman's avatar

How did you tell your unit tests to use your testing connection? Also, have you defined protected $connection = 'mysql'; on your models?

lara65535's avatar

Shot. That’s embarrassing. Completely forgot I defined $connection in two models when I was debugging other items.

Thanks!

Please or to participate in this conversation.