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);
|
||||
|
||||
Reference in New Issue
Block a user