如标题中所述,只有在通过Symfony的WebTestCase
功能测试发布表单时才会出现此错误。
我正在尝试通过加载索引然后将一些数据发布到该页面上的表单来对某些控制器进行功能测试。每次我尝试发帖时,都会收到“会话开始后无法设置会话ID ”错误。
我正在使用Symfony 2.8.9但我在互联网上找不到任何答案。
class CheckoutTest extends WebTestCase
{
private $client;
public function setUp()
{
include_once(__DIR__ . '/../../../../web/constants.inc.php');
include_once(__DIR__ . '/../../../../app/config/environment.php');
$this->client = static::makeClient(true, array(
'HTTP_HOST' => 'dev.myshop.com',
));
}
public function testStep1()
{
$crawler = $this->client->request('GET', '/contact/');
$this->assertEquals(200, $this->client->getResponse()->isSuccessful());
$form = $crawler->selectButton('Submit')->form();
$this->client->submit($form);
$this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
}
我的config_test.yml文件:
framework:
test: ~
session:
storage_id: session.storage.mock_file
我的phpunit.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
processIsolation="false"
colors="true"
bootstrap="autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
<ini name="intl.default_locale" value="en" />
<ini name="intl.error_level" value="0" />
<ini name="memory_limit" value="-1" />
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>../src/*/*Bundle/Tests</directory>
<directory>../src/*/Bundle/*Bundle/Tests</directory>
<directory>../src/*Bundle/Tests</directory>
</testsuite>
</testsuites>
我该如何解决这个问题?