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?
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>    
                        Actually this can be done with a blacklist as well. The path needs to be relative to your tests directory.
This did the trick in my project:
<filter>
    <blacklist>
        <directory suffix=".php">../../../cache</directory>
    </blacklist>
</filter>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With