Laravel 使用RefreshDatabase显示未找到驱动程序错误

Laravel 使用RefreshDatabase显示未找到驱动程序错误,laravel,phpunit,Laravel,Phpunit,我正在尝试用laravel编写测试,我已经做了一段时间了,而且效果很好。在这个新项目中,我应该使用TDD和刷新数据库。当我将use RefreshDatabase包括在内时,我会得到一个错误,这是我在从事的其他项目中没有遇到的错误。有什么问题吗 我正在测试的代码 class ParentsTest extends TestCase { use RefreshDatabase; /** @test */ public function createParentTest()

我正在尝试用laravel编写测试,我已经做了一段时间了,而且效果很好。在这个新项目中,我应该使用TDD和刷新数据库。当我将use RefreshDatabase包括在内时,我会得到一个错误,这是我在从事的其他项目中没有遇到的错误。有什么问题吗

我正在测试的代码

class ParentsTest extends TestCase
{
    use RefreshDatabase;

    /** @test */
    public function createParentTest(){
        $this->withoutExceptionHandling();
        $response = $this->post('/create-parent',[
            'fname' => 'Julius',
            'lname' => 'Ssemakula',
            'contact' => '256702913454'
        ]);
        $this->assertDatabaseHas('Parents', ['fname' => 'Julius']);
    }
}
我得到的错误是

1) Tests\Feature\ParentsTest::createParentTest Illumb\Database\QueryException:找不到驱动程序(SQL:PRAGMA 外键=开;)


您需要为正在使用的数据库安装适当的驱动程序。如果您使用的是Linux:

首先使用
PHP--version
找出您正在运行的PHP的哪个版本。我将使用
php7.3
进行演示

对于MySQL:

sudo apt install php7.3-mysql
对于SQLite:

sudo apt install php7.3-sqlite
对于PostgreSQL:

sudo apt install php7.3-pgsql

安装适当的驱动程序后,您的测试应该可以正常运行。

Tengo todas las Extensions instaladas para PDO y aun me da error,lo extraño es que la base de datos que estoy usando es postgresql pero on las pruebas unitarias me da error con SQLite possible que estéutilizando function que no estéan Dispostéan Dispostés de estédésédésésé。(谷歌翻译)