Laravel 6 PHPUnit Testing - Could Not Find Driver (SQL: PRAGMA Foreign_keys = ON;)

- 1 answer

I'm started to write tests in Laravel. My application works, I can login, run migrations, but when I'm trying to test the login, I'm getting the following error:

could not find driver (SQL: PRAGMA foreign_keys = ON;)

My DB is in Postgres, and my test is as follows:

/** @test */
public function user_login_ok()
    $response = $this->json('POST', '/api/login', [
       'email' => '[email protected]',
       'password' => 'test'

    $this->assertEquals(200, $response->getStatusCode());

I'm not worried (for now) if my test is good enough or even right, but to solve this error.



Do you have a testing environment specific .env file? Do you have php section environment configuration in your phpunit.xml file?

If either of these has configuration for your database connection, they should be reviewed to make sure they are configured correctly.