我正在尝试使用 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)