Symfony3 phpunit xml

Hello everyone PhpUnit installed in my Symfony3 project, and when I run the terminal application bin / phpunit -c, I get this error:

Could not load XML from empty string

I got to Google, and it turned out that I need to attach the phpunit.xml file in my app / directory so that it looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
        backupGlobals               = "false"
        backupStaticAttributes      = "false"
        colors                      = "true"
        convertErrorsToExceptions   = "true"
        convertNoticesToExceptions  = "true"
        convertWarningsToExceptions = "true"
        processIsolation            = "false"
        stopOnFailure               = "false"
        syntaxCheck                 = "false"
        bootstrap                   = "autoload.php" >

    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>../src/*/*Bundle/Tests</directory>
            <!--directory>../src/*/Bundle/*Bundle/Tests</directory-->
        </testsuite>
    </testsuites>

    <!--
    <php>
        <server name="KERNEL_DIR" value="/path/to/your/app/" />
    </php>
    -->

    <filter>
        <whitelist>
            <directory>../src</directory>
            <exclude>
                <directory>../src/*/*Bundle/Resources</directory>
                <directory>../src/*/*Bundle/Tests</directory>
                <!--directory>../src/*/Bundle/*Bundle/Resources</directory>
                <directory>../src/*/Bundle/*Bundle/Tests</directory-->
            </exclude>
        </whitelist>
    </filter>

</phpunit>

So, now it works fine, but the questions that I cannot find answers to are the following:

  • Why does the php module need this file, I see that the file shows phpunit where to look for tests, but is that all?

  • I created this file manually to create it automatically using the terminal command.

  • As far as I understand, <whitelist>where is phpunit allowed to "watch"? and <exlude>, where phpunit is not allowed to "watch"? and if so, why would it <directory>../src/*/*Bundle/Tests</directory>be in <exlude>, if that's where the test is.

+4
3

symfony3 PHPUnit , -c (). , :

>bin/phpunit

+5

:

  • . PHPUnits. .
  • Symfony phpunit.xml.dist (. ). .dist , , Symfony, . , , parameters.yml.dist. phpunit.xml . , phpunit.xml VCS, , , , .
  • <whitelist> <exclude> , PHPUnit . <filter>, , PHPUnit . , , , .

, , . , 2, phpunit . .

+1

@Matteo, Symfony3 .

, Symfony3 :

phpunit -c phpunit.xml.dist

The default configuration file "phpunit.xml.dist" is automatically created in your Symfony3 directory structure, you can change it as you wish. I just checked that the above works on my system.

0
source

All Articles