Symfony 3功能测试错误(KERNEL_DIR或WebTestCase)

时间:2017-07-11 00:41:02

标签: php symfony phpunit

我需要帮助,文档没有帮助。

我有<?xml version="1.0" encoding="UTF-8"?> <!-- https://phpunit.de/manual/current/en/appendixes.configuration.html --> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="app/autoload.php" > <php> <ini name="error_reporting" value="-1" /> <server name="KERNEL_DIR" value="app" /> </php> <testsuites> <testsuite name="Project Test Suite"> <directory>tests</directory> </testsuite> </testsuites> <filter> <whitelist> <directory>src</directory> <exclude> <directory>src/*Bundle/Resources</directory> <directory>src/*/*Bundle/Resources</directory> <directory>src/*/Bundle/*Bundle/Resources</directory> </exclude> </whitelist> </filter> </phpunit> ,我没有使用自定义内核,但是功能测试没有运行。

phpunit.xml.dist:

/usr/bin/php /home/jorgee/Desktop/Proyectos/Nano/proyecto-nano/vendor/phpunit/phpunit/phpunit --no-configuration /home/jorgee/Desktop/Proyectos/Nano/proyecto-nano/tests --teamcity
Testing started at 21:35 ...
PHPUnit 6.1.0 by Sebastian Bergmann and contributors.


Either set KERNEL_DIR in your phpunit.xml according to https://symfony.com/doc/current/book/testing.html#your-first-functional-test or override the WebTestCase::createKernel() method.
 /home/jorgee/Desktop/Proyectos/Nano/proyecto-nano/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php:126
 /home/jorgee/Desktop/Proyectos/Nano/proyecto-nano/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php:165
 /home/jorgee/Desktop/Proyectos/Nano/proyecto-nano/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php:146
 /home/jorgee/Desktop/Proyectos/Nano/proyecto-nano/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php:33
 /home/jorgee/Desktop/Proyectos/Nano/proyecto-nano/tests/AppBundle/Controller/Security/LoginControllerAcceptanceTest.php:19

错误:

app.use('/signup',signup);
app.use('/login',login);
app.use('/profile',profile);

1 个答案:

答案 0 :(得分:1)

您使用--no-configuration运行phpunit,这会阻止phpunit加载配置文件。

加载文件,或将KERNEL_DIR设置为环境变量。