【发布时间】:2021-01-30 12:07:31
【问题描述】:
我已经用 phpunit 运行了我的 laravel 应用程序。 一切都很好,直到我再次运行测试时出现此错误。
Illuminate\Database\QueryException: could not find driver (SQL: PRAGMA foreign_keys = ON;)
Caused by
PDOException: could not find driver
这是我的 phpunit.xml 文件:
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
</php>
OS: Windows 10 | php version: PHP 7.4.11 | sqlite version: SQLite version 3.19.1
有人在 laravel 6 和 phpunit 中遇到过这个错误吗?
【问题讨论】:
-
您能发布更多信息吗?就像您的 phpunit.xml 文件一样。你在用 sqlite 吗?
-
是的,我使用 sqlite 和数据库值作为内存。请参考我更新的帖子@JonathanMartins
-
你的操作系统是什么?什么是PHP版本?你有安装 sqlite 驱动吗?
-
是的,我已经安装了 sqlite。根据您的问题更新了我的帖子。