timesheet export (#317)
* remove autocomplete for begin and end * fix minute display in timesheet-edit form * toolbar form label in separate row * added export action
This commit is contained in:
@@ -30,6 +30,76 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
$this->request($client, '/timesheet/');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
$this->assertHasDataTable($client);
|
||||
|
||||
$result = $client->getCrawler()->filter('div.breadcrumb div.box-tools div.btn-group a.btn');
|
||||
$this->assertEquals(5, count($result));
|
||||
|
||||
foreach ($result as $item) {
|
||||
$this->assertEquals('btn btn-default', $item->getAttribute('class'));
|
||||
$this->assertEquals('i', $item->firstChild->tagName);
|
||||
}
|
||||
}
|
||||
|
||||
public function testIndexActionWithQuery()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser();
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setAmount(5);
|
||||
$fixture->setUser($this->getUserByRole($em, User::ROLE_USER));
|
||||
$fixture->setStartDate(new \DateTime('-10 days'));
|
||||
$this->importFixture($em, $fixture);
|
||||
|
||||
$this->request($client, '/timesheet/');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$form = $client->getCrawler()->filter('form.navbar-form')->form();
|
||||
$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());
|
||||
$this->assertHasDataTable($client);
|
||||
|
||||
// TODO more assertions
|
||||
}
|
||||
|
||||
public function testExportAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser();
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setAmount(5);
|
||||
$fixture->setUser($this->getUserByRole($em, User::ROLE_USER));
|
||||
$fixture->setStartDate(new \DateTime('-10 days'));
|
||||
$this->importFixture($em, $fixture);
|
||||
|
||||
$this->request($client, '/timesheet/');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$form = $client->getCrawler()->filter('form.navbar-form')->form();
|
||||
$form->getFormNode()->setAttribute('action', $this->createUrl('/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(5, count($result));
|
||||
}
|
||||
|
||||
public function testCreateAction()
|
||||
@@ -61,6 +131,30 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
$this->assertNull($timesheet->getFixedRate());
|
||||
}
|
||||
|
||||
public function testDeleteAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setAmount(10);
|
||||
$fixture->setUser($this->getUserByRole($em, User::ROLE_USER));
|
||||
$fixture->setStartDate('2017-05-01');
|
||||
$this->importFixture($em, $fixture);
|
||||
|
||||
$this->request($client, '/timesheet/1/edit');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$this->request($client, '/timesheet/1/delete');
|
||||
$this->assertIsRedirect($client, $this->createUrl('/timesheet/page/1'));
|
||||
$client->followRedirect();
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
$this->assertHasFlashSuccess($client);
|
||||
|
||||
$this->request($client, '/timesheet/1/edit');
|
||||
$this->assertFalse($client->getResponse()->isSuccessful());
|
||||
}
|
||||
|
||||
public function testStartAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser();
|
||||
@@ -184,15 +278,15 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
$this->request($client, '/timesheet/1/edit');
|
||||
|
||||
$response = $client->getResponse();
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
|
||||
$docuUrl = $this->createUrl('/help/timesheet');
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
$this->assertContains(
|
||||
'<a href="' . $docuUrl . '"><i class="far fa-question-circle"></i></a>',
|
||||
$response->getContent(),
|
||||
'Could not find link to documentation'
|
||||
);
|
||||
|
||||
// TODO more tests
|
||||
// TODO more assertions
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user