Does it need to drop views? Are you using view? If not, just remove that property from your TestCase
//protected $dropViews = true; //remove this
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am trying to use a real Sql Server connection to run my php unit test in Laravel because SqLite does not have the function I am trying to test. The database name is "Test" and the connection details have all been added to database.php.
I have changed my phpunit.xml env variables to refer to the new test database.
<env name="DB_CONNECTION" value="test_sqlserver"/>
<env name="DB_DATABASE" value="Test"/>
Now, when I try to run a simple test with a class that use the RefreshDatabase trait, or even the DatabaseMigrations trait, it result in the following error: Symfony\Component\Console\Exception\InvalidOptionException: The "--drop-views" option does not exist.
Now, as a workaround I can add the following function in my test case. The error goes away, but now no test works correctly because the trait does not migrate the database.
protected function migrateFreshUsing()
{
$seeder = $this->seeder();
return array_merge([
// '--drop-views' => $this->shouldDropViews(),
// '--drop-types' => $this->shouldDropTypes(),
],
// $seeder ? ['--seeder' => $seeder] : ['--seed' => $this->shouldSeed()]
);
}
Since the seeder works for the real database, I wonder why it doesnt in phpunit? How can I make test run with the RefreshDatabase trait with sql server?
Please or to participate in this conversation.