I want to test a form via functional tests. After filling in the form et then submit , the following error message was displayed :
[2020-06-11 17:45:32] request.CRITICAL: Uncaught PHP Exception LogicException: "Cannot set session ID after the session has started." at /var/www/renault-del/del/src/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php line 127 {"exception":"[object] (LogicException(code: 0): Cannot set session ID after the session has started. at /var/www/renault-del/del/src/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php:127)"} []
For information , this is my script that i used to sumit a form :
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;
}
}
And thank you in advance
Aucun commentaire:
Enregistrer un commentaire