allow to prefill timesheet description by get param (#2580)

This commit is contained in:
Toby Batch
2021-08-08 13:29:12 +01:00
committed by GitHub
parent c063aed867
commit f80fe0e4d0
2 changed files with 59 additions and 0 deletions

View File

@@ -497,6 +497,60 @@ class TimesheetControllerTest extends ControllerBaseTest
$this->assertEquals(['one', 'two', 'three'], $timesheet->getTagsAsArray());
}
public function testCreateActionWithDescription()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$this->request($client, '/timesheet/create?description=Lorem%20Ipsum');
$this->assertTrue($client->getResponse()->isSuccessful());
$form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();
$client->submit($form, [
'timesheet_edit_form' => [
'hourlyRate' => 100,
'project' => 1,
'activity' => 1,
]
]);
$this->assertIsRedirect($client, $this->createUrl('/timesheet/'));
$client->followRedirect();
$this->assertTrue($client->getResponse()->isSuccessful());
$this->assertHasFlashSuccess($client);
$em = $this->getEntityManager();
/** @var Timesheet $timesheet */
$timesheet = $em->getRepository(Timesheet::class)->findAll()[0];
$this->assertEquals('Lorem Ipsum', $timesheet->getDescription());
}
public function testCreateActionWithDescriptionHtmlInjection()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$this->request($client, '/timesheet/create?description=Some text"><bold>HelloWorld<%2Fbold>');
$this->assertTrue($client->getResponse()->isSuccessful());
$form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();
$client->submit($form, [
'timesheet_edit_form' => [
'hourlyRate' => 100,
'project' => 1,
'activity' => 1,
]
]);
$this->assertIsRedirect($client, $this->createUrl('/timesheet/'));
$client->followRedirect();
$this->assertTrue($client->getResponse()->isSuccessful());
$this->assertHasFlashSuccess($client);
$em = $this->getEntityManager();
/** @var Timesheet $timesheet */
$timesheet = $em->getRepository(Timesheet::class)->findAll()[0];
$this->assertEquals('Some text"><bold>HelloWorld</bold>', $timesheet->getDescription());
}
public function testEditAction()
{
$client = $this->getClientForAuthenticatedUser();