phpzend-frameworkphpunitcode-coveragezend-autoloader

How can PHPUnit code coverage ignore my autoloader?


I have a bootstrap in my phpunit config that runs the Zend\Loader\StandardAutoloader.php. I can get PHPUnit code coverage to ignore it when I add

<filter>
   <blacklist>
       <directory suffix=".php">/absolute/path/to/zf</directory>
   </blacklist>
</filter>

to the PHPUnit config XML file. But I have to specify an absolute path. I want it to be a relative path but PHPUnit is not ignoring the Zend folder in the code coverage. I don't want to add different location for when I'm working at home and I don't want other developers adding their own paths. The Zend Framework is in the php.ini include_path setting but this does not work:

<filter>
   <blacklist>
       <directory suffix=".php">./Zend</directory>
   </blacklist>
</filter>

Any suggestions?


Solution

  • You can exclude paths from the code coverage with the <exclude>...</exclude> directive within your <filter><whitelist>:

    <filter>
        <whitelist>
            <directory suffix=".php">../src/library/</directory>
            <!-- add more directories -->
            <exclude>
                <directory suffix=".phtml">./src/application/</directory>
                <directory suffix=".php">./Zend/</directory>
                <!-- add more directories with relative or absolute path -->
            </exclude>
        </whitelist>
    </filter>