gpt4 book ai didi

symfony - 如何在要求我在 phpunit.xml 中设置 KERNEL_DIR 的 PHPUnit 中解决此问题?

转载 作者:行者123 更新时间:2023-12-03 20:30:34 24 4
gpt4 key购买 nike

这是我的 phpunit.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="true"
strict="true"
bootstrap="./vendor/autoload.php">
<testsuites>
<php>
<server name="KERNEL_DIR" value="app" />
<ini name="display_errors" value="true"/>
</php>
<testsuite name="Functional Tests">
<directory>./tests/src/myApp/AppBundle/functional</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
</phpunit>

这是测试类
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class MyTest extends WebTestCase
{
private $client;

public function setUp()
{
$this->client = static::createClient();
}

运行测试时,我得到了 setUp 中的一行:

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

最佳答案

移动 <php> ... </php>出了<testsuites>...阻止到它自己的顶级。

这是我自己的主要项目的精简副本:

<phpunit 
bootstrap = "app/bootstrap_test.php"
verbose = "true"
>
<php>
<ini name="memory_limit" value="-1" />
<!-- <server name="KERNEL_DIR" value="./app/" /> older-style -->
<server name="KERNEL_CLASS" value="AppKernel" />
<server name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
</php>

<testsuites>
<testsuite name="project.name">
<directory suffix=".php">./src/*Bundle</directory>
<directory suffix=".php">./src/AppBundle</directory> -->
<directory>./tests/App</directory>
</testsuite>
</testsuites>

关于symfony - 如何在要求我在 phpunit.xml 中设置 KERNEL_DIR 的 PHPUnit 中解决此问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49096015/

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