Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony 如果;框架.测试“;配置未设置为true_Symfony_Phpunit_Symfony4 - Fatal编程技术网

Symfony 如果;框架.测试“;配置未设置为true

Symfony 如果;框架.测试“;配置未设置为true,symfony,phpunit,symfony4,Symfony,Phpunit,Symfony4,我正在尝试使用WebTestCase应用功能测试 class CalculatorControllerTest extends WebTestCase { public function testSumPost() { $client = static::createClient(); $client->request('GET', '/calculator/sum'); $this->assertEquals(20

我正在尝试使用WebTestCase应用功能测试

class CalculatorControllerTest extends WebTestCase
{
    public function testSumPost()
    {
        $client = static::createClient();

        $client->request('GET', '/calculator/sum');

        $this->assertEquals(200, $client->getResponse()->getStatusCode());
    }
}
运行测试时,我收到以下错误消息:

 You cannot create the client used in functional tests if the "framework.test" config is not set to true
我的测试框架:

framework:
 test: ~
 session:
   storage_id: session.storage.mock_file
 router:
   resource: "%kernel.root_dir%/config/routing_test.yml"
  profiler:
   collect: false
My phpunit.xml:(我还尝试在APP_ENV和Debug 1中测试而不是开发,而不是0)


测试/单元

我查看了所有相关问题,但找不到好的答案,有什么想法吗?

在您的
config/packages/test/framework.yaml
中您有
test:~
,但我想应该是
test:true
。请参阅:谢谢,但当我将hem设置为true并重新启动docker容器时,您可能需要重建缓存。您是否尝试过
php bin/console cache:clear--env=test
或者
rm-rf var/cache/test*
如果您使用的是相对标准的Symfony安装,请将
替换为
phpunit.xml
文件中的
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
    backupGlobals               = "false"
    backupStaticAttributes      = "false"
    colors                      = "true"
    convertErrorsToExceptions   = "true"
    convertNoticesToExceptions  = "true"
    convertWarningsToExceptions = "true"
    processIsolation            = "false"
    stopOnFailure               = "false"
    bootstrap                   = "config/bootstrap.php" >

<php>
    <ini name="error_reporting" value="-1" />
    <server name="KERNEL_CLASS" value="AppKernel" />
    <env name="APP_ENV" value="dev" />
    <env name="APP_DEBUG" value="0" />
    <env name="SHELL_VERBOSITY" value="-1" />
    <!-- define your env variables for the test env here -->
</php>

<testsuites>
    <testsuite name="Plein Test Suite">
        <directory>tests/unit</directory>
    </testsuite>
</testsuites>