API begin and end fields for Admins (#5134)

This commit is contained in:
Kevin Papst
2024-10-25 10:47:58 +02:00
committed by GitHub
parent 31bae44f3c
commit dcc52f1a95
12 changed files with 161 additions and 47 deletions

View File

@@ -295,6 +295,33 @@ class TimesheetControllerTest extends ControllerBaseTest
$this->assertFalse($form->has('fixedRate'));
}
public function getTrackingModeTestData(): array
{
return [
['duration_fixed_begin', User::ROLE_USER, false, false],
['duration_fixed_begin', User::ROLE_SUPER_ADMIN, false, false],
['punch', User::ROLE_USER, false, false],
['punch', User::ROLE_SUPER_ADMIN, false, false],
['default', User::ROLE_USER, true, true],
['default', User::ROLE_SUPER_ADMIN, true, true],
];
}
/**
* @dataProvider getTrackingModeTestData
*/
public function testCreateActionWithTrackingModeHasFieldsForUser(string $trackingMode, string $user, bool $showBeginTime, bool $showEndTime): void
{
$client = $this->getClientForAuthenticatedUser($user);
$this->setSystemConfiguration('timesheet.mode', $trackingMode);
$this->request($client, '/timesheet/create');
$this->assertTrue($client->getResponse()->isSuccessful());
$form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();
$this->assertEquals($showBeginTime, $form->has('timesheet_edit_form[begin_time]'));
$this->assertEquals($showEndTime, $form->has('timesheet_edit_form[end_time]'));
}
public function testCreateActionWithFromAndToValues(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);