"in phpunit. xml.dist-6ren"> "in phpunit. xml.dist-在尝试 PHPUnit 功能测试时,我得到了 错误: 1) TreningBundle\Tests\Controller\DefaultControllerTest::testIndex Runtim-6ren">
gpt4 book ai didi

symfony - 错误 : "set KERNEL_DIR in your phpunit.xml" but KERNEL_DIR is set ""in phpunit. xml.dist

转载 作者:行者123 更新时间:2023-12-01 11:25:35 24 4
gpt4 key购买 nike

在尝试 PHPUnit 功能测试时,我得到了
错误:

1) TreningBundle\Tests\Controller\DefaultControllerTest::testIndex
RuntimeException: 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.

http://symfony.com/doc/2.8/book/testing.html说:

if your kernel is in a non-standard directory, you'll need to modify your phpunit.xml.dist



我有文件 phpunit.xml.distAppKErnel.php在默认的 Symfony (2.8) 位置,内部 app\目录。无论如何,我在 app/phpunit.xml.dist 中添加了以下行:
<php>
<server name="KERNEL_DIR" value="./" />
</php>

结果相同的错误。

安装的软件包:
doctrine/annotations                 v1.2.7
doctrine/cache v1.6.0
doctrine/collections v1.3.0
doctrine/common v2.6.1
doctrine/dbal v2.5.4
doctrine/doctrine-bundle 1.6.2
doctrine/doctrine-cache-bundle 1.3.0
doctrine/inflector v1.1.0
doctrine/instantiator 1.0.5
doctrine/lexer v1.0.1
doctrine/orm v2.5.4
incenteev/composer-parameter-handler v2.1.2
ircmaxell/password-compat v1.0.4
jdorn/sql-formatter v1.2.17
monolog/monolog 1.19.0
myclabs/deep-copy 1.5.1
paragonie/random_compat v2.0.2
phpdocumentor/reflection-docblock 2.0.4
phpspec/prophecy v1.6.0
phpunit/php-code-coverage 3.3.2
phpunit/php-file-iterator 1.4.1
phpunit/php-text-template 1.2.1
phpunit/php-timer 1.0.8
phpunit/php-token-stream 1.4.8
phpunit/phpunit 5.3.4
phpunit/phpunit-mock-objects 3.1.3
phpunit/phpunit-skeleton-generator 2.0.1
psr/log 1.0.0
sebastian/code-unit-reverse-lookup 1.0.0
sebastian/comparator 1.2.0
sebastian/diff 1.4.1
sebastian/environment 1.3.7
sebastian/exporter 1.2.1
sebastian/global-state 1.1.1
sebastian/object-enumerator 1.0.0
sebastian/recursion-context 1.0.2
sebastian/resource-operations 1.0.0
sebastian/version 1.0.6
sensio/distribution-bundle v5.0.6
sensio/framework-extra-bundle v3.0.16
sensio/generator-bundle v3.0.6
sensiolabs/security-checker v3.0.2
swiftmailer/swiftmailer v5.4.2
symfony/monolog-bundle 2.11.1
symfony/phpunit-bridge v2.8.6
symfony/polyfill-apcu v1.2.0
symfony/polyfill-intl-icu v1.2.0
symfony/polyfill-mbstring v1.2.0
symfony/polyfill-php54 v1.2.0
symfony/polyfill-php55 v1.2.0
symfony/polyfill-php56 v1.2.0
symfony/polyfill-php70 v1.2.0
symfony/polyfill-util v1.2.0
symfony/security-acl v3.0.0
symfony/swiftmailer-bundle v2.3.11
symfony/symfony v2.8.6
twig/twig v1.24.0

使用绝对路径:
<server name="KERNEL_DIR" value="C:\wamp\www\treningPHPUnitSymfony2.8\app" />

同样的错误。

最佳答案

使用 Symfony 2.8.17我们的内核在 /appphpunit.xml.dist在同一水平上。
所以我们补充说;

<php>
....
<server name="KERNEL_DIR" value="app" />
</php>

PS:额外信息;
由于我们的设置,我们还需要使用 putenv("X_ENV=test")获取配置详细信息以完成测试。

关于symfony - 错误 : "set KERNEL_DIR in your phpunit.xml" but KERNEL_DIR is set "<server name="KERNEL_DIR"value ="./">"in phpunit. xml.dist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37497241/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com