I have a PHP MVC framework with multiple 'applications' under this system the organization goes
\project\apps\app1\
\project\apps\app2\
\project\apps\shared\
Each application can have it's own set of controllers
\project\apps\app1\controllers\FooContoller.php
\project\apps\app2\controllers\FooContoller.php
\project\apps\shared\controllers\BarContoller.php
I'd like to set up my PHPUnit testing space to be able to test each of the application directories, but I'm hoping to do it in the "best" way.
The setup of PHPUnit is like:
\project\PHPUnit
\project\PHPUnit\phpunit.xml
\project\PHPUnit\apps\app1\bootstrap.php
\project\PHPUnit\apps\app1\controllers
\project\PHPUnit\apps\app1\controllers\FooControllerTest.php
\project\PHPUnit\apps\app2\bootstrap.php
\project\PHPUnit\apps\app2\controllers
\project\PHPUnit\apps\app2\controllers\FooControllerTest.php
Now here's the question: what is the "best practise" way to configure my phpunit.xml files?
As it stands, I tried to include both applications as their own test suite in the XML file, but I run into a "Cannot Redeclare Class: FooController " pretty quickly.
To my mind, the ideal situation would be to configure the XML so that all the tests ran for app1 then memory was 'cleared' and all the tests were run for app2.
It might however, be the case that in terms of best practise it's best to have multiple XML files, one for each APP. (Then perhaps a batch/shellscript file to run a "test all" or test X)
If we look at a 'typical' PHPUnit XML config file:
<phpunit bootstrap="./apps/app1/bootstrap.php" colors="true">
<testsuite name="App1TestSuite">
<directory>./</directory>
</testsuite>
<filter>
<whitelist>
<directory suffix=".php">./apps/app1/controllers/</directory>
<directory suffix=".php">./apps/shared/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./log/report.html" charset="UTF-8"
yui="true" highlight="true"
lowUpperBound="50" highLowerBound="80"/>
<log type="testdox-html" target="./log/testdox.html" />
</logging>
</phpunit>
Should I go with many of these? Or should I add the tag and have all files Setups combined in a single XML configuration.
If the best practise is 'single configuration' ... does anyone know how you go about enabling multiple 'bootstraps'? Since each APP loads with slightly different global variables, and some will load slightly different versions of same-named classes, it would be necessary to clear everything and start again.
I'm interested in building the 'optimal' system for testing from the start but obviously have a few holes in my knowledge.