PHP如何排除目录中的所有文件但不排除子目录

时间:2017-08-01 16:57:06

标签: phpunit code-coverage

我有这样的问题。我想排除SomeBundle \ Entity中的所有文件,但不想排除SomeBundle \ Entity \ Repository和SomeBundle \ Entity \ Factory。

SomeBundle\Entity
SomeBundle\Entity\Repository
SomeBundle\Entity\Factory

SomeBundle\Entity\File1.php
SomeBundle\Entity\File2.php
SomeBundle\Entity\File3.php

我试着用

    <filter>
        <whitelist>
            <directory>./../src/SomeBundle</directory>
            <exclude>
                <directory suffix=".php">./../src/SomeBundle/Entity</directory>
            </exclude>
        </whitelist>
    </filter>

但结果是,我在SomeBundle \ Entity中排除了所有...

1 个答案:

答案 0 :(得分:0)

<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true">
    <testsuites>
        <testsuite name="Test Suite">
            <directory>SomeBundle</directory>
            <directory>SomeBundle/Entity/**</directory>
            <exclude>SomeBundle/Entity</exclude>
        </testsuite>
    </testsuites>
</phpunit>