0

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>

2 Answers 2

1

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?

Sign up to request clarification or add additional context in comments.

1 Comment

I tried adding the suffix with no luck. I was going to try the whitelist approach (though it seems to me the blacklist approach should work) but am not sure what the path would be when I am running the project in eclipse.
0

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');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.