added search modal for timesheet export (#2728)

This commit is contained in:
Kevin Papst
2021-08-24 19:01:48 +02:00
committed by GitHub
parent f6a82ba119
commit f743503705
40 changed files with 526 additions and 186 deletions

View File

@@ -41,11 +41,8 @@ class TimesheetControllerTest extends ControllerBaseTest
$this->assertHasNoEntriesWithFilter($client);
$this->assertPageActions($client, [
'search' => '#',
'toolbar-action exporter-csv' => $this->createUrl('/timesheet/export/csv'),
'toolbar-action exporter-print' => $this->createUrl('/timesheet/export/print'),
'toolbar-action exporter-pdf' => $this->createUrl('/timesheet/export/pdf'),
'toolbar-action exporter-xlsx' => $this->createUrl('/timesheet/export/xlsx'),
'visibility' => '#',
'download toolbar-action modal-ajax-form' => $this->createUrl('/timesheet/export/'),
'create modal-ajax-form' => $this->createUrl('/timesheet/create'),
'help' => 'https://www.kimai.org/documentation/timesheet.html'
]);
@@ -134,18 +131,17 @@ class TimesheetControllerTest extends ControllerBaseTest
$fixture->setStartDate(new \DateTime('-10 days'));
$this->importFixture($fixture);
$this->request($client, '/timesheet/');
$this->request($client, '/timesheet/export/');
$this->assertTrue($client->getResponse()->isSuccessful());
$dateRange = (new \DateTime('-10 days'))->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \DateTime())->format('Y-m-d');
$form = $client->getCrawler()->filter('form.searchform')->form();
$form->getFormNode()->setAttribute('action', $this->createUrl('/timesheet/export/print'));
$client->submit($form, [
'state' => 1,
'pageSize' => 25,
'daterange' => $dateRange,
'customers' => [],
$client->submitForm('export-btn-print', [
'export' => [
'state' => 1,
'daterange' => $dateRange,
'customers' => [],
]
]);
$this->assertTrue($client->getResponse()->isSuccessful());

View File

@@ -43,11 +43,8 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
$this->assertPageActions($client, [
'search' => '#',
'toolbar-action exporter-csv' => $this->createUrl('/team/timesheet/export/csv'),
'toolbar-action exporter-print' => $this->createUrl('/team/timesheet/export/print'),
'toolbar-action exporter-pdf' => $this->createUrl('/team/timesheet/export/pdf'),
'toolbar-action exporter-xlsx' => $this->createUrl('/team/timesheet/export/xlsx'),
'visibility' => '#',
'download toolbar-action modal-ajax-form' => $this->createUrl('/team/timesheet/export/'),
'create-ts modal-ajax-form' => $this->createUrl('/team/timesheet/create'),
'create-ts-mu modal-ajax-form' => $this->createUrl('/team/timesheet/create_mu'),
'help' => 'https://www.kimai.org/documentation/timesheet.html'
@@ -146,18 +143,17 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
$fixture->setStartDate(new \DateTime('-10 days'));
$this->importFixture($fixture);
$this->request($client, '/team/timesheet/');
$this->request($client, '/team/timesheet/export/');
$this->assertTrue($client->getResponse()->isSuccessful());
$dateRange = (new \DateTime('-10 days'))->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \DateTime())->format('Y-m-d');
$form = $client->getCrawler()->filter('form.searchform')->form();
$form->getFormNode()->setAttribute('action', $this->createUrl('/team/timesheet/export/print'));
$client->submit($form, [
'state' => 1,
'pageSize' => 25,
'daterange' => $dateRange,
'customers' => [],
$client->submitForm('export-btn-print', [
'export' => [
'state' => 1,
'daterange' => $dateRange,
'customers' => [],
]
]);
$this->assertTrue($client->getResponse()->isSuccessful());

View File

@@ -13,7 +13,6 @@ use App\EventSubscriber\Actions\TimesheetsSubscriber;
/**
* @covers \App\EventSubscriber\Actions\AbstractActionsSubscriber
* @covers \App\EventSubscriber\Actions\AbstractTimesheetsSubscriber
* @covers \App\EventSubscriber\Actions\TimesheetsSubscriber
*/
class TimesheetsSubscriberTest extends AbstractActionsSubscriberTest

View File

@@ -13,7 +13,6 @@ use App\EventSubscriber\Actions\TimesheetsTeamSubscriber;
/**
* @covers \App\EventSubscriber\Actions\AbstractActionsSubscriber
* @covers \App\EventSubscriber\Actions\AbstractTimesheetsSubscriber
* @covers \App\EventSubscriber\Actions\TimesheetsTeamSubscriber
*/
class TimesheetsTeamSubscriberTest extends AbstractActionsSubscriberTest

View File

@@ -34,7 +34,7 @@ class CsvRendererTest extends AbstractRendererTest
public function getTestModel()
{
return [
['400', '2437.12', ' EUR 1,947.99 ', 7, 5, 1, 2, 2]
['400', '2437.12', ' EUR 1,947.99 ', 6, 5, 1, 2, 2]
];
}
@@ -55,8 +55,6 @@ class CsvRendererTest extends AbstractRendererTest
$this->assertTrue(file_exists($file->getRealPath()));
$content = file_get_contents($file->getRealPath());
$this->assertStringContainsString('"' . $totalDuration . '"', $content);
$this->assertStringContainsString('"' . $totalRate . '"', $content);
$this->assertStringContainsString('"' . $expectedRate . '"', $content);
$this->assertEquals($expectedRows, substr_count($content, PHP_EOL));
$this->assertEquals($expectedDescriptions, substr_count($content, 'activity description'));
@@ -108,7 +106,7 @@ class CsvRendererTest extends AbstractRendererTest
27 => 'ORDER-123',
];
self::assertEquals(7, \count($all));
self::assertEquals(6, \count($all));
self::assertEquals($expected, $all[5]);
self::assertEquals(\count($expected), \count($all[0]));
self::assertEquals('foo', $all[4][14]);

View File

@@ -31,7 +31,7 @@ class CsvRendererTest extends AbstractRendererTest
public function getTestModel()
{
return [
['400', '2437.12', ' EUR 1,947.99 ', 7, 5, 1, 2, 2]
['400', '2437.12', ' EUR 1,947.99 ', 6, 5, 1, 2, 2]
];
}
@@ -52,8 +52,6 @@ class CsvRendererTest extends AbstractRendererTest
$this->assertTrue(file_exists($file->getRealPath()));
$content = file_get_contents($file->getRealPath());
$this->assertStringContainsString('"' . $totalDuration . '"', $content);
$this->assertStringContainsString('"' . $totalRate . '"', $content);
$this->assertStringContainsString('"' . $expectedRate . '"', $content);
$this->assertEquals($expectedRows, substr_count($content, PHP_EOL));
$this->assertEquals($expectedDescriptions, substr_count($content, 'activity description'));
@@ -105,7 +103,7 @@ class CsvRendererTest extends AbstractRendererTest
27 => 'ORDER-123',
];
self::assertEquals(7, \count($all));
self::assertEquals(6, \count($all));
self::assertEquals($expected, $all[5]);
self::assertEquals(\count($expected), \count($all[0]));
self::assertEquals('foo', $all[4][14]);

View File

@@ -0,0 +1,26 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Repository\Result;
use App\Repository\Result\TimesheetResultStatistic;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Repository\Result\TimesheetResultStatistic
*/
class TimesheetResultStatisticTest extends TestCase
{
public function testConstruct()
{
$sut = new TimesheetResultStatistic(13, 7705);
self::assertSame(13, $sut->getCount());
self::assertSame(7705, $sut->getDuration());
}
}