I have a PHP MVC framework with several "applications" in this system, the organization is going
\project\apps\app1\ \project\apps\app2\ \project\apps\shared\
Each application can have its own set of controllers.
\project\apps\app1\controllers\FooContoller.php \project\apps\app2\controllers\FooContoller.php \project\apps\shared\controllers\BarContoller.php
I would like to set up my PHPUnit test space to check each of the application directories, but I hope to make this a "better" way.
PHPUnit setup is similar:
\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 the question is: what is the best practice way to set up phpunit.xml files?
Be that as it may, I tried to include both applications in my own test suite in an XML file, but I quickly run "Unable to Redeclare Class: FooController".
In my opinion, the ideal situation would be to configure XML so that all tests run for app1 , then the memory is "cleared" and all tests run for app2 .
However, it may be that from a best practice point of view, it is best to have multiple XML files, one for each APP. (Then maybe a batch / shellscript file to run "test all" or test X)
If we look at the “typical” PHPUnit XML configuration 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>
Do I have to go with many of them? Or should I add a tag and combine all the settings files in a single XML configuration.
If best practice is a “single configuration” ... does anyone know how you are going to include multiple “boot” ones? Since each APP loads several different global variables, and some will load slightly different versions of the classes of the same name, you will need to clear everything and start again.
I am interested in creating an “optimal” system for testing from the very beginning, but, obviously, it has several phenomena that I know of.