进行API集成测试时,碰到如下问题:
There was 1 error:
1) Tests\Feature\ExampleTest::testBasicTest
Illuminate\Database\QueryException: could not find driver (SQL: PRAGMA foreign_keys = ON;)
......
Caused by
Doctrine\DBAL\Driver\PDOException: could not find driver
......
Caused by
PDOException: could not find driver
......
ERRORS!
Tests: 2, Assertions: 1, Errors: 1.
一开始没仔细看,直接看到“PDOException: could not find driver”这句。心想这不就是PDO驱动未找到么,肯定是php.ini中驱动没开,但转念一想,不对啊,之前的项目怎么可能不使用pdo?肯定开着。
带着怀疑的态度,去打开php.ini问题,发现没错,pdo扩展是开启的。
网上找到类似问题,说开启sqlite就好了,也没有说明原因,照做试了一下,发现是正确的,虽然出现新的问题但之前数据库相关的错误的确消失了,没想明白为何,所以来立个flag,后面有时间再研究!