Blog Archive

Wednesday 29 January 2014

PHPUnit: cannot open file bootstrap.php

This post is google fodder for anyone who comes across the error 'cannot open file: /some/directory/here/tests/unit/bootstrap.php' when attempting to run unit tests with PHPUnit. In particular, I got this error when trying to set up unit tests for a new project in PHPEd. The reason for the error in this case is that PHPEd helpfully adds a default phpunit.xml file including a switch that attempts to load said bootstrap file.

To fix: Just edit the phpunit.xml file (or it might be named phpunit.xml.dist) in the root folder of the project, and remove the switch: bootstrap="tests/unit/bootstrap.php".