本文介绍了如何在要求我在phpunit.xml中设置KERNEL_DIR的PHPUnit中解决此问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的phpunit.xml文件
Here is my phpunit.xml file
<?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的行:
When running the test I get at the line in setUp:
推荐答案
将<php> ... </php>
从<testsuites>...
块移到它自己的顶层.
Move the <php> ... </php>
out of the <testsuites>...
block to it's own top-level.
这是我自己的主项目的精简副本:
Here's a trimmed down copy of my own main project:
<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>
这篇关于如何在要求我在phpunit.xml中设置KERNEL_DIR的PHPUnit中解决此问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!