CodeView
Back to article:
prod
tests
integration
reference-output
Ko
resources
test-clones
xml
custom-file
default-file
dist-file
special
tools
Base
Ko
unit
Limitations when testing XML configs ==================================== XML configs are hard to test. ## Background: When using XML configs, PHPUnit (as of 3.6) detects new test classes with a static mechanism: - taking stock of all declared classes (using PHP's get_declared_classes() function) - opening the test file - diffing the declared classes. When testing a harness, the same dummy test is accessed repeatedly. It works the first time, but the second time the test class is already declared, the diff is empty, and the tests are not picked up by PHPUnit. Classes, as opposed to objects, cannot be unloaded or be "un-declared". This detection nightmare takes place in PHPUnit_Util_Class::collectStart() and PHPUnit_Util_Class::collectEnd(). ## Restrictions Each XML config file - must be tested only once - must point to a unique test class which is used exclusively for this XML config file. - must be set up with the desired switches in tools/Base/helpers/DebugFactory.php Default configuration files, ie phpunit.xml or phpunit.xml.dist, must each be placed in a directory of their own. ## Alternative workarounds XML config files and test classes could be created on the fly in a temp directory, with different test class names for each iteration.