CakePHP 3:运行 phpunit 时无法插入固定装置

CakePHP 3: Unable to insert fixtures when running phpunit

我刚刚烘焙了一些固定装置和一些测试用例,每当我 运行 vendor/bin/phpunit 我得到以下错误的版本:

$ vendor/bin/phpunit
PHPUnit 4.7.7 by Sebastian Bergmann and contributors.

IException: Unable to insert fixtures for "App\Test\TestCase\Controller\ScreensControllerTest" test case. SQLSTATE[HY000] [2002] No such file or directory in [/Applications/MAMP/htdocs/myapp/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureManager.php, line 254]

夹具和测试是使用烘焙工具自动烘焙的。我检查了 $fixtures 属性 中的每个项目对应于 tests/Fixture/ 中的一个文件。如果我在任何测试 class 中注释掉 $fixtures 声明,错误就会移动到下一个 class。所以在任何特定的 fixture/test.

中语法都不错

这个错误意味着PHP无法连接到数据库。如果您使用的是 SQLite 数据库,请确保该目录可写且存在。