无法在MockArraySessionStorage.php:127上启动会话后设置会话ID。

问题描述 投票:0回答:1
我想通过功能测试来测试表单。填写表格然后提交后,显示以下错误消息:

[2020-06-11 17:45:32]请求。严重:未捕获的PHP异常LogicException:“会话启动后无法设置会话ID。”在/var/www/renault-del/del/src/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php第127行{“ exception”:“ [object](LogicException(code :0):会话开始后无法设置会话ID。在/var/www/renault-del/del/src/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php: 127)“} []

有关信息,这是我用来填写表格的脚本:

class CmsBlockControllerTest extends WebTestCase { /** @var Client */ private $client; protected function setUp() { parent::setUp(); $this->client = static::createClient(); } public function testNewAction(): void { $crawler = $this->client->request( 'GET', $this->generateRoute('delbackoffice_cms_block_new') // my own function to generate a route ); $form = $crawler->selectButton('Enregistrer') ->form([ 'block[title]' => 'title', 'block[identifier]' => 'identifier', 'block[content]' => 'content']); $this->client->submit($form); } protected function tearDown() { parent::tearDown(); $this->client = null; $this->tokenStorage = null; $this->globalVariables = null; } }

在此先谢谢你

我想通过功能测试来测试表单。填写然后提交表单后,将显示以下错误消息:[2020-06-11 17:45:32] request.CRITICAL:未捕获的PHP异常...

symfony testing symfony-2.8
1个回答
0
投票
一段时间后,我在以下链接中找到了解决方法

通过在test.client.class上调用disableReboot

© www.soinside.com 2019 - 2024. All rights reserved.