I\'m trying to write a functional test for my project in Symfony2. I\'d like to test if a user can access a page, fill up a form and submit it. I\'m trying to find a way to roll
Are you doing more than one request with the Client? If so, you problem might be that the client shutdowns the kernel after one request was performed. But you can disable that with $this->client->disableReboot() So this snippet snippet should be idempotent:
public function setUp()
{
$this->client = $this->createClient(['environment' => 'test']);
$this->client->disableReboot();
$this->em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
$this->em->beginTransaction();
}
public function tearDown()
{
$this->em->rollback();
}
public function testCreateNewEntity()
{
$this->client->request('GET', '/create/entity/form');
$this->client->request('POST', '/create/entity/unique/123');
}