0
votes

I am trying to use phpunit through the CLI in order to migrate from Netbeans to Sublime Text. I have the weirdest issue when giving phpunit the path to the phpunit.xml file : it only accepts absolute path et refuses any relative path. Any relative path given to the phpunit.xml file leads to this error :

Could not read "phpunit.xml"

Example :

Maximes-MacBook-Pro:Frontoffice mbritto$ pwd
/Users/mbritto/Documents/Frontoffice
Maximes-MacBook-Pro:Frontoffice mbritto$ phpunit -c phpunit.xml
Could not read "phpunit.xml".

The phpunit.xml is present in this folder and is readable by my user. It actually works if I don't give the path to the file :

Maximes-MacBook-Pro:Frontoffice mbritto$ phpunit
PHPUnit 3.7.28 by Sebastian Bergmann.

Configuration read from /Users/mbritto/Documents/Frontoffice/phpunit.xml

#Preparing Application Unit Tests
.^C

Or if I give the absolute path to the file :

Maximes-MacBook-Pro:Frontoffice mbritto$ phpunit -c /Users/mbritto/Documents/Frontoffice/phpunit.xml
PHPUnit 3.7.28 by Sebastian Bergmann.

Configuration read from /Users/mbritto/Documents/Frontoffice/phpunit.xml

#Preparing Application Unit Tests
..^C

I need this in order to use the phpunit plugin in Sublime Text which gives the phpunit.xml file to the command line with the path to the file to test.

My config :

  • OSX 10.9.1
  • PHP 5.4.24 (via brew)
  • PHPUnit 3.7.28 (via brew) (also tested with a phar)

Any idea why it would do that ?

1

1 Answers

1
votes

I finally found out what was wrong with my tests; in my bootstrap.php file I was doing this :

chdir(dirname(__FILE__) . "/../src/");

So that classes and autoload would find actual classes that are separated from my test classes. If I remove this line, the tests crashes because it can't find my classes but at least my tests are executed. I'll work on the include path rather than changing directory so my tests will be working again.