Take the 2-minute tour ×

I have 2 directories: project1 and project2. When I run PHPUnit in project1/tests, it works fine. When I run it in project2/tests, it works fine, except does not produce any code coverage reports. The phpunit.xml config files are virtually identical. There are some differences in the bootstraps that each calls, however I don't think these are material. (I have checked out the paths and they are fine).

Any ideas? How can I go about diagnosing this problem?

Here is the phpunit.xml from project2/tests:

<phpunit bootstrap="./TestBootstrap.php">
<testsuite name="OpenCompany">
        <directory suffix=".php">..\library\</directory>
        <directory suffix=".php">..\application\</directory>
            <directory suffix=".phtml">..\application\</directory>
    <log type="coverage-html" target="./output/report" charset="UTF-8" yui="true" highlight="false" lowUpperBound="35" highLowerBound="70"/>
    <log type="coverage-clover" target="./output/coverage.xml"/>
    <log type="json" target="./output/logfile.json"/>
    <log type="tap" target="./output/logfile.tap"/>
    <log type="junit" target="./output/logfile.xml" logIncompleteSkipped="false"/>
    <log type="testdox-html" target="./output/testdox.html"/>
    <log type="testdox-text" target="./output/testdox.txt"/>

And here's the TestBootstrap.php:


// Adapted from tutorial by Matthew Weier O'Phinney
// Tutorial is dated 11/09/2008

// Set location

// Set Error Reporting to All, Strict
error_reporting(E_ALL | E_STRICT);

// Sets include paths relative to location of TestBootstrap.php
$root           = realpath(dirname(__FILE__).'/../');  // resolves to project directory
$library        = $root.'/library';
$tests          = $root.'/tests';
$dbtables       = $root.'/application/models/DbTable';

$path = array($models, $library, $dbtables, $tests, get_include_path());
set_include_path(implode(PATH_SEPARATOR, $path));

// Set Application Constants
if (!defined('APPLICATION_PATH')) {define('APPLICATION_PATH', $root.'/application');}
if (!defined('APPLICATION_ENV')) {define('APPLICATION_ENV', 'testing');}

// Get Autoloading happening
require_once 'Zend/Loader/Autoloader.php';

// Setup a default DB connection
$db = Zend_Db::factory('Pdo_Mysql', array(
        'host'      =>  'localhost',
        'username'  =>  'root',
        'password'  =>  '',
        'dbname'    =>  'openco_v1_0'

// Store some stuff in the registry
// Zend_Registry::set('testRoot', $root);
// Zend_Registry::set('testBootstrap', $root.'/application/bootstrap.php');

// Unset global variables that are no longer required
unset($root, $library, $models, $dbtables, $controllers, $tests, $path);

Any assistance appreciated!

share|improve this question
Do you have xdebug extension installed and/or enabled? –  Marcin Mar 12 '11 at 4:59

1 Answer 1

up vote 1 down vote accepted

Ok, sorted this out. There were errors in the models (presumably parse errors), so PHPUnit could not make sense of the code in order to determine how much was covered by the tests.

I excluded the /applications/models tests from the whitelist and it is working fine now. Once I've worked through the models and fixed the errors, I'll remove the exclusion.

share|improve this answer

Your Answer


