小编yos*_*ini的帖子

如果“framework.test”配置未设置为 true,则无法创建功能测试中使用的客户端

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

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

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

        $this->assertEquals(200, $client->getResponse()->getStatusCode());
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行测试时,出现以下错误消息:

 You cannot create the client used in functional tests if the "framework.test" config is not set to true
Run Code Online (Sandbox Code Playgroud)

我的测试框架:

framework:
 test: ~
 session:
   storage_id: session.storage.mock_file
 router:
   resource: "%kernel.root_dir%/config/routing_test.yml"
  profiler:
   collect: false
Run Code Online (Sandbox Code Playgroud)

我的 phpunit.xml:(我也尝试在 APP_ENV 中测试而不是 dev & 调试 1 而不是 0)

<?xml version="1.0" encoding="UTF-8"?>

<phpunit
    backupGlobals               = "false"
    backupStaticAttributes      = "false"
    colors                      = "true"
    convertErrorsToExceptions   = "true"
    convertNoticesToExceptions …
Run Code Online (Sandbox Code Playgroud)

phpunit symfony symfony4

11
推荐指数
1
解决办法
6296
查看次数

标签 统计

phpunit ×1

symfony ×1

symfony4 ×1