浏览器访问正常,而PHPUnit失败

时间:2017-03-21 18:32:19

标签: php phpunit

我正在使用symfony2.8,FOSUserBundle和PHPUnit 5.7

我可以通过浏览器访问/登录。

然而PHPUnit失败了。

所以我只是转储PHPUnit的$ client-> getResponse()

$client = static::createClient();

$crawlerLogin = $client->request('GET', '/login');
print $client->getResponse()->getContent();

这些是错误代码的标题。 你觉得为什么会这样吗???

Failed asserting that '<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta name="robots" content="noindex,nofollow" />
        <title>    Failed to start the session because headers have already been sent by &quot;phar:///usr/local/bin/phpunit/phpunit/Util/Printer.php&quot; at line 110. (500 Internal Server Error)
</title>

这是我的phpunit.xml

/app/phpunit.xml

<?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                   = "bootstrap.php.cache" >

    <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>

0 个答案:

没有答案