I am trying to write unit tests for an application where a lot of code changes is not possible. Almost all the .php files in the code base uses some $_SERVER[\'\'] variables lik
I'm not sure about #1, but PHPUnit itself would have to support it. I don't see any way to do that via the command line. However, if you put your current workaround into bootstrap.php
you don't have to do it in each test.
For #2,
elements. I use this in Jenkins.
Update: You typically create bootstrap.php
to setup add the source directory to the include path and initialize the test environment however you need. This file isn't supplied by PHPUnit--unlike phpunit.xml
.
I place it in the same directory as phpunit.xml
, but that's because I have a separate file for each project. It goes in the directory that holds your tests typically. This allows you to run phpunit
from the command-line without telling it how to find those configuration files. Otherwise you have to use --bootstrap
and/or --configuration
to point to them.
Here is how I structure a typical project:
/
build.xml
src/
MyClass.php
test/
MyClassTest.php
phpunit.xml
bootstrap.php