I'm running a series of PHPunit tests and have a controller that is reporting 100% coverage. In the coverage report however, only 5 of its 84 lines of code are marked "green"
I'm wondering what factors might be causing this issue?
One interesting point that might be causing it is 'indirect calls'. This particular controller is the parent of a number of other controllers, and since so many other objects inherit from it maybe the code gets called for elsewhere... but then wouldn't it turn green?
As it stands the only method that is turning green is the __construct
method.
I don't know if that's actually enough to go on, but if anyone has a bit more knowledge of how Unit Testing determines coverage I'd love to hear it.
Edit in response to `Gaurav's comment:
The phpunit command line is phpunit --configuration admin.xml
and admin.xml reads
<phpunit bootstrap="./admin/applications/admin/bootstrap.php" colors="true">
<testsuite name="AdminTestSuite">
<directory suffix=".php">./admin/applications/admin/</directory>
<directory suffix=".php">./admin/applications/shared/</directory>
</testsuite>
<filter>
<whitelist>
<directory suffix=".php">../admin/applications/admin/controllers</directory>
<directory suffix=".php">../admin/applications/shared/controllers</directory>
<directory suffix=".php">../admin/applications/shared/helpers</directory>
<directory suffix=".php">../admin/lib/controllers</directory>
<directory suffix=".php">../admin/lib/helpers</directory>
<directory suffix=".php">../admin/lib/models</directory>
<directory suffix=".php">../admin/lib/utils</directory>
</whitelist>
<blacklist>
<file>../dm_admin/applications/shared/controllers/DashboardController.php</file>
<directory suffix=".php">../admin/lib/crons</directory>
</blacklist>
</filter>
<logging>
<log type="coverage-html" target="/projects/ut/admin/" charset="UTF-8"
yui="true" highlight="true"
lowUpperBound="50" highLowerBound="80"/>
<log type="testdox-html" target="/projects/ut/admin/testdox.html" />
</logging>
</phpunit>
In response to jakenoble:
the helper is reading 100% coverage
but inside we see
It goes on for 1099 lines, with the occasional green... but no red.