This issue has existed since I started working on this project several months ago, and I have not found a solution anywhere on the net.
I am running PHPStorm 2018.3.2 on Windows 10 with, PHP version 5.3.3 on a Vagrant box with CentoOS 6.5. Remote interpreter and xdebug is set up and working.
When I try to run a unit test directly from the project folder in PHPStorm (right click -> Run Script (PHPUnit)), I get fatal errors on the first reference to any model in the project. The unit test script will run until it hits a reference to a class defined in the application. The error message:
PHP Fatal error: Call to a member function delete() on a non-object in /vagrant/project.com/tests/library/SomeModel.php on line 33
I have to open the run configuration and set an alternative configuration file, with the absolute path to the phpunit.xml file on my Windows machine. Once set, the test will run without any issues.
My default configuration file is located in the project/tests folder, which is mapped to a shared directory on the Vagrant box. The path to the default configuration file is:
I have to manually set the path to an alternative configuration file:
The following directories are mapped in the PHPStorm project mappings:
C:\vagrant\project.com -> /vagrant/project.com
C:\vagrant\project.com\application -> /vagrant/project.com/application
C:\vagrant\project.com\application\models -> /vagrant/project.com/application/models (this is where the majority of objects are defined)
C:\vagrant\project.com\tests -> /vagrant/project.com/tests
C:\vagrant\project.com\tests\phpunit.xml -> /vagrant/project.com/tests/phpunit.xml (grasping at straws with this one, but no luck)
It would be awesome if anyone knows what is causing this. It seems like a path mapping issue, but I believe I have defined all necessary paths.