Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP 3: Unable to insert fixtures when running phpunit

I just baked some Fixtures and some TestCases and whenever I run vendor/bin/phpunit I get a version of the following error:

$ 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]

The fixtures and tests were baked automatically using the bake tools. I checked that each item in the $fixtures property corresponds to a file in tests/Fixture/. If I comment out the $fixtures declaration in any of the test classes the error just moves to the next class. So it's not bad syntax in any specific fixture/test.

like image 342
emersonthis Avatar asked Jul 16 '15 15:07

emersonthis


1 Answers

This error means that PHP is not able to connect to the database. If you are using a SQLite database, make sure the directory is writable and exists.

like image 194
José Lorenzo Rodríguez Avatar answered Oct 24 '22 13:10

José Lorenzo Rodríguez