export team timesheets (#508)
This commit is contained in:
@@ -44,12 +44,20 @@ class ActivityControllerTest extends ControllerBaseTest
|
||||
$this->assertNull($form->get('activity_edit_form[create_more]')->getValue());
|
||||
$client->submit($form, [
|
||||
'activity_edit_form' => [
|
||||
'name' => 'Test 2',
|
||||
'name' => 'An AcTiVitY Name',
|
||||
'project' => '1',
|
||||
]
|
||||
]);
|
||||
$this->assertIsRedirect($client, $this->createUrl('/admin/activity/'));
|
||||
$client->followRedirect();
|
||||
$this->assertHasDataTable($client);
|
||||
|
||||
$this->request($client, '/admin/activity/2/edit');
|
||||
$editForm = $client->getCrawler()->filter('form[name=activity_edit_form]')->form();
|
||||
$this->assertEquals('An AcTiVitY Name', $editForm->get('activity_edit_form[name]')->getValue());
|
||||
// make sure customer and project are pre-selected for none global activities
|
||||
$this->assertEquals('1', $editForm->get('activity_edit_form[project]')->getValue());
|
||||
$this->assertEquals('1', $editForm->get('activity_edit_form[customer]')->getValue());
|
||||
}
|
||||
|
||||
public function testCreateActionWithCreateMore()
|
||||
@@ -101,6 +109,9 @@ class ActivityControllerTest extends ControllerBaseTest
|
||||
$this->request($client, '/admin/activity/1/edit');
|
||||
$editForm = $client->getCrawler()->filter('form[name=activity_edit_form]')->form();
|
||||
$this->assertEquals('Test 2', $editForm->get('activity_edit_form[name]')->getValue());
|
||||
// make sure no customer or project is pre-selected for global activities
|
||||
$this->assertEquals('', $editForm->get('activity_edit_form[customer]')->getValue());
|
||||
$this->assertEquals('', $editForm->get('activity_edit_form[project]')->getValue());
|
||||
}
|
||||
|
||||
public function testDeleteAction()
|
||||
|
||||
@@ -33,7 +33,7 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
$this->assertHasDataTable($client);
|
||||
|
||||
$result = $client->getCrawler()->filter('div.breadcrumb div.box-tools div.btn-group a.btn');
|
||||
$this->assertEquals(3, count($result));
|
||||
$this->assertEquals(4, count($result));
|
||||
|
||||
foreach ($result as $item) {
|
||||
$this->assertEquals('btn btn-default', $item->getAttribute('class'));
|
||||
@@ -71,6 +71,44 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
// TODO more assertions
|
||||
}
|
||||
|
||||
public function testExportAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setAmount(7);
|
||||
$fixture->setUser($this->getUserByRole($em, User::ROLE_USER));
|
||||
$fixture->setStartDate(new \DateTime('-10 days'));
|
||||
$this->importFixture($em, $fixture);
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setAmount(3);
|
||||
$fixture->setUser($this->getUserByRole($em, User::ROLE_TEAMLEAD));
|
||||
$fixture->setStartDate(new \DateTime('-10 days'));
|
||||
$this->importFixture($em, $fixture);
|
||||
|
||||
$this->request($client, '/team/timesheet/');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$form = $client->getCrawler()->filter('form.navbar-form')->form();
|
||||
$form->getFormNode()->setAttribute('action', $this->createUrl('/team/timesheet/export'));
|
||||
$client->submit($form, [
|
||||
'state' => 1,
|
||||
'pageSize' => 25,
|
||||
'begin' => (new \DateTime('-10 days'))->format('Y-m-d'),
|
||||
'end' => (new \DateTime())->format('Y-m-d'),
|
||||
'customer' => null,
|
||||
]);
|
||||
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$node = $client->getCrawler()->filter('body');
|
||||
$this->assertEquals('invoice_print', $node->getNode(0)->getAttribute('class'));
|
||||
|
||||
$result = $node->filter('section.invoice table.table tbody tr');
|
||||
$this->assertEquals(10, count($result));
|
||||
}
|
||||
|
||||
public function testCreateAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);
|
||||
|
||||
@@ -70,7 +70,7 @@ abstract class AbstractVoterTest extends TestCase
|
||||
$invoice = ['view_invoice', 'create_invoice'];
|
||||
$invoiceTemplate = ['view_invoice_template', 'create_invoice_template', 'edit_invoice_template', 'delete_invoice_template'];
|
||||
$timesheet = ['view_own_timesheet', 'start_own_timesheet', 'stop_own_timesheet', 'create_own_timesheet', 'edit_own_timesheet', 'export_own_timesheet', 'delete_own_timesheet'];
|
||||
$timesheetOthers = ['view_other_timesheet', 'start_other_timesheet', 'stop_other_timesheet', 'create_other_timesheet', 'edit_other_timesheet', 'delete_other_timesheet'];
|
||||
$timesheetOthers = ['view_other_timesheet', 'start_other_timesheet', 'stop_other_timesheet', 'create_other_timesheet', 'edit_other_timesheet', 'export_other_timesheet', 'delete_other_timesheet'];
|
||||
$profile = ['view_own_profile', 'edit_own_profile', 'password_own_profile', 'preferences_own_profile', 'api-token_own_profile'];
|
||||
$profileOther = ['view_other_profile', 'edit_other_profile', 'delete_other_profile', 'password_other_profile', 'roles_other_profile', 'preferences_other_profile', 'api-token_other_profile'];
|
||||
$user = ['view_user', 'create_user', 'delete_user'];
|
||||
|
||||
@@ -62,6 +62,7 @@ class TimesheetVoterTest extends AbstractVoterTest
|
||||
yield [$timeEntry[0], $timeEntry[1], 'stop', $result];
|
||||
yield [$timeEntry[0], $timeEntry[1], 'edit', $result];
|
||||
yield [$timeEntry[0], $timeEntry[1], 'delete', $result];
|
||||
yield [$timeEntry[0], $timeEntry[1], 'export', $result];
|
||||
}
|
||||
|
||||
$result = VoterInterface::ACCESS_DENIED;
|
||||
@@ -73,6 +74,7 @@ class TimesheetVoterTest extends AbstractVoterTest
|
||||
yield [$timeEntry[0], $timeEntry[1], 'stop', $result];
|
||||
yield [$timeEntry[0], $timeEntry[1], 'edit', $result];
|
||||
yield [$timeEntry[0], $timeEntry[1], 'delete', $result];
|
||||
yield [$timeEntry[0], $timeEntry[1], 'export', $result];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user