We have a Phing script that is used by Hudson to build/test our PHP site.
Some of our unit tests load the main function library; others use a mock to avoid having to do so (or to provide specific faked results for the test).
The unit tests all run perfectly when run in isolation (ie on the command line, using phpunit
). However when we run them together as a batch in Phing, we get errors.
The errors are in tests where we have written mocks for certain functions. The error says that we are declaring the function twice. It is clearly attempting to include the real function library as well as the mocks.
The tests are including code that is mutually exclusive, so they need to be run in isolation from each other; it would appear that Phing is running them all in a single process, so the includes are clashing.
The relevant part of the phing script looks like this:
<phpunit haltonfailure="true" printsummary="true">
<batchtest>
<fileset dir="${ws}/path/to/site/root/">
<include name="*Test.php" />
<include name="*/*Test.php" />
<include name="*/*/*Test.php" />
<include name="*/*/*/*Test.php" />
</fileset>
</batchtest>
<formatter type="xml" todir="${builddir}/logs" outfile="units.xml" />
</phpunit>
Is there a way to get phing to run the tests independantly of each other, without specifying each one separately in the build script?