Reputation: 531
When I generate code coverage for my PHP project, I always get the Symfony autoloader.
I tried adding this to my PHPUnit config with no luck:
<filter>
<blacklist>
<directory>/Symfony/Component</directory>
</blacklist>
</filter>
Upvotes: 0
Views: 1061
Reputation: 25
I'm using composer and tried several variations including the exclusion within a whitelist:
My directory structure is thus:
...
/project/tests
/project/vendor
/project/vendor/composer
...
I tried to get whitelist working:
<whitelist>
<exclude>
<directory suffix=".php">..\vendor\composer\</directory>
<directory suffix=".php">../vendor/composer/</directory>
<directory suffix=".php">..\composer\</directory>
<directory suffix=".php">../composer/</directory>
</exclude>
</whitelist>
That did not work. But this did:
<filter>
<blacklist>
<directory suffix=".php">../vendor/composer</directory>
</blacklist>
</filter>
My configuration xml file is within the tests folder along with a bootstrap file that loads in composer's autoloader.
<?php
require_once(__DIR__. str_repeat(DIRECTORY_SEPARATOR. '..', 1) . DIRECTORY_SEPARATOR . 'vendor'. DIRECTORY_SEPARATOR . 'autoload.php');
Upvotes: 0
Reputation: 6683
First of all you didn't specified suffix attribute to search for specific type of file in blacklist
so it should be
<filter>
<blacklist>
<directory suffix=".php">/Symfony/Component</directory>
</blacklist>
</filter>
if this is not working for you then you can use exclude tag in whitelist block
<filter>
<whitelist>
<directory suffix=".php">../src/library/</directory>
<!-- add more directories -->
<exclude>
<directory suffix=".php">./Zend/</directory>
<!-- add more directories with relative or absolute path -->
</exclude>
</whitelist>
</filter>
Reference: How can PHPUnit code coverage ignore my autoloader?
Upvotes: 1