save default search options (#2445)
* set default times for daterange objects * allow to show order and order by fields * move search to modal * more options for page size * save export visibility in cookie
This commit is contained in:
@@ -182,10 +182,12 @@ class InvoiceCreateCommandTest extends KernelTestCase
|
||||
$commandTester = $this->createInvoice(['--user' => UserFixtures::USERNAME_SUPER_ADMIN, '--set-exported' => null, '--customer' => 1, '--template' => 'Invoice', '--start' => '2020-01-01', '--end' => '2020-03-01']);
|
||||
|
||||
$output = $commandTester->getDisplay();
|
||||
$this->assertStringContainsString('+----+----------+-------+------------- Created 1 invoice(s) --------------------------------------+', $output);
|
||||
$this->assertStringContainsString('| ID | Customer | Total | Filename |', $output);
|
||||
$this->assertStringContainsString('+----+----------+-------+-------------------------------------------------------------------------+', $output);
|
||||
$this->assertStringContainsString('| Test | 0 EUR | /', $output);
|
||||
$this->assertStringContainsString('Created 1 invoice(s)', $output);
|
||||
$this->assertStringContainsString('| ID', $output);
|
||||
$this->assertStringContainsString('| Customer', $output);
|
||||
$this->assertStringContainsString('| Total', $output);
|
||||
$this->assertStringContainsString('| Filename', $output);
|
||||
$this->assertStringContainsString('0 EUR', $output);
|
||||
$this->assertStringContainsString('/tests/_data/invoices/' . ((new \DateTime())->format('Y')) . '-001-Test.html |', $output);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ class ThemeConfigurationTest extends TestCase
|
||||
'company' => null,
|
||||
'title' => null,
|
||||
],
|
||||
'auto_reload_datatable' => false,
|
||||
'tags_create' => true,
|
||||
];
|
||||
}
|
||||
@@ -61,7 +60,6 @@ class ThemeConfigurationTest extends TestCase
|
||||
public function testConfigs()
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings(), []);
|
||||
$this->assertFalse($sut->isAutoReloadDatatable());
|
||||
$this->assertTrue($sut->isAllowTagCreation());
|
||||
$this->assertNull($sut->getTitle());
|
||||
}
|
||||
@@ -73,5 +71,6 @@ class ThemeConfigurationTest extends TestCase
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings(), []);
|
||||
$this->assertEquals('', $sut->getSelectPicker());
|
||||
$this->assertFalse($sut->isAutoReloadDatatable());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class ActivityControllerTest extends ControllerBaseTest
|
||||
|
||||
$this->assertAccessIsGranted($client, '/admin/activity/');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$client->submit($form, [
|
||||
'searchTerm' => 'feature:timetracking foo',
|
||||
'visibility' => 1,
|
||||
@@ -102,7 +102,7 @@ class ActivityControllerTest extends ControllerBaseTest
|
||||
|
||||
$this->assertAccessIsGranted($client, '/admin/activity/');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$form->getFormNode()->setAttribute('action', $this->createUrl('/admin/activity/export'));
|
||||
$client->submit($form, [
|
||||
'searchTerm' => 'feature:timetracking foo',
|
||||
|
||||
@@ -60,7 +60,7 @@ class CustomerControllerTest extends ControllerBaseTest
|
||||
|
||||
$this->assertAccessIsGranted($client, '/admin/customer/');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$client->submit($form, [
|
||||
'searchTerm' => 'feature:timetracking foo',
|
||||
'visibility' => 1,
|
||||
@@ -92,7 +92,7 @@ class CustomerControllerTest extends ControllerBaseTest
|
||||
$this->request($client, '/admin/customer/');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$form->getFormNode()->setAttribute('action', $this->createUrl('/admin/customer/export'));
|
||||
$client->submit($form, [
|
||||
'searchTerm' => 'feature:timetracking foo',
|
||||
|
||||
@@ -66,7 +66,7 @@ class ProjectControllerTest extends ControllerBaseTest
|
||||
|
||||
$this->assertAccessIsGranted($client, '/admin/project/');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$client->submit($form, [
|
||||
'searchTerm' => 'feature:timetracking foo',
|
||||
'visibility' => 1,
|
||||
@@ -108,7 +108,7 @@ class ProjectControllerTest extends ControllerBaseTest
|
||||
|
||||
$this->assertAccessIsGranted($client, '/admin/project/');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$form->getFormNode()->setAttribute('action', $this->createUrl('/admin/project/export'));
|
||||
$client->submit($form, [
|
||||
'searchTerm' => 'feature:timetracking foo',
|
||||
|
||||
@@ -55,7 +55,7 @@ class TagControllerTest extends ControllerBaseTest
|
||||
$this->request($client, '/admin/tags/');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$client->submit($form, [
|
||||
'searchTerm' => 'Support',
|
||||
]);
|
||||
|
||||
@@ -41,7 +41,7 @@ class TeamControllerTest extends ControllerBaseTest
|
||||
|
||||
$this->assertAccessIsGranted($client, '/admin/teams/');
|
||||
$this->assertPageActions($client, [
|
||||
'search search-toggle visible-xs-inline' => '#',
|
||||
'search' => '#',
|
||||
'create' => $this->createUrl('/admin/teams/create'),
|
||||
'help' => 'https://www.kimai.org/documentation/teams.html'
|
||||
]);
|
||||
@@ -62,7 +62,7 @@ class TeamControllerTest extends ControllerBaseTest
|
||||
|
||||
$this->assertAccessIsGranted($client, '/admin/teams/');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$client->submit($form, [
|
||||
'searchTerm' => 'foo',
|
||||
]);
|
||||
|
||||
@@ -39,7 +39,7 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
// there are no records by default in the test database
|
||||
$this->assertHasNoEntriesWithFilter($client);
|
||||
$this->assertPageActions($client, [
|
||||
'search search-toggle visible-xs-inline' => '#',
|
||||
'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'),
|
||||
@@ -67,7 +67,7 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
|
||||
$dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \DateTime('last day of this month'))->format('Y-m-d');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$client->submit($form, [
|
||||
'state' => 1,
|
||||
'pageSize' => 25,
|
||||
@@ -113,7 +113,7 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
|
||||
$dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \DateTime('last day of this month'))->format('Y-m-d');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$client->submit($form, [
|
||||
'searchTerm' => 'location:homeoffice foobar',
|
||||
]);
|
||||
@@ -138,7 +138,7 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
|
||||
$dateRange = (new \DateTime('-10 days'))->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \DateTime())->format('Y-m-d');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$form->getFormNode()->setAttribute('action', $this->createUrl('/timesheet/export/print'));
|
||||
$client->submit($form, [
|
||||
'state' => 1,
|
||||
|
||||
@@ -41,7 +41,7 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
|
||||
$this->assertHasNoEntriesWithFilter($client);
|
||||
|
||||
$this->assertPageActions($client, [
|
||||
'search search-toggle visible-xs-inline' => '#',
|
||||
'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'),
|
||||
@@ -73,7 +73,7 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
|
||||
|
||||
$dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \DateTime('last day of this month'))->format('Y-m-d');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$client->submit($form, [
|
||||
'state' => 1,
|
||||
'users' => [$user->getId()],
|
||||
@@ -119,7 +119,7 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
|
||||
|
||||
$dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \DateTime('last day of this month'))->format('Y-m-d');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$client->submit($form, [
|
||||
'searchTerm' => 'location:homeoffice foobar',
|
||||
]);
|
||||
@@ -150,7 +150,7 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
|
||||
|
||||
$dateRange = (new \DateTime('-10 days'))->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \DateTime())->format('Y-m-d');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$form->getFormNode()->setAttribute('action', $this->createUrl('/team/timesheet/export/print'));
|
||||
$client->submit($form, [
|
||||
'state' => 1,
|
||||
|
||||
@@ -35,7 +35,7 @@ class UserControllerTest extends ControllerBaseTest
|
||||
$this->assertHasDataTable($client);
|
||||
$this->assertDataTableRowCount($client, 'datatable_user_admin', 7);
|
||||
$this->assertPageActions($client, [
|
||||
'search search-toggle visible-xs-inline' => '#',
|
||||
'search' => '#',
|
||||
'visibility' => '#',
|
||||
'download toolbar-action' => $this->createUrl('/admin/user/export'),
|
||||
'create' => $this->createUrl('/admin/user/create'),
|
||||
@@ -50,7 +50,7 @@ class UserControllerTest extends ControllerBaseTest
|
||||
$this->request($client, '/admin/user/');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$client->submit($form, [
|
||||
'searchTerm' => 'hourly_rate:35 tony',
|
||||
'role' => 'ROLE_TEAMLEAD',
|
||||
@@ -83,7 +83,7 @@ class UserControllerTest extends ControllerBaseTest
|
||||
$this->request($client, '/admin/user/');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$form = $client->getCrawler()->filter('form.header-search')->form();
|
||||
$form = $client->getCrawler()->filter('form.searchform')->form();
|
||||
$form->getFormNode()->setAttribute('action', $this->createUrl('/admin/user/export'));
|
||||
$client->submit($form, [
|
||||
'searchTerm' => 'hourly_rate:35 tony',
|
||||
|
||||
@@ -169,7 +169,6 @@ class AppExtensionTest extends TestCase
|
||||
'title' => null,
|
||||
'translation' => null,
|
||||
],
|
||||
'auto_reload_datatable' => false,
|
||||
'autocomplete_chars' => 3,
|
||||
'tags_create' => true,
|
||||
'calendar' => [
|
||||
|
||||
@@ -343,7 +343,6 @@ class ConfigurationTest extends TestCase
|
||||
'active_warning' => 3,
|
||||
'box_color' => 'blue',
|
||||
'select_type' => 'selectpicker',
|
||||
'auto_reload_datatable' => false,
|
||||
'show_about' => true,
|
||||
'chart' => [
|
||||
'background_color' => '#3c8dbc',
|
||||
|
||||
52
tests/Entity/BookmarkTest.php
Normal file
52
tests/Entity/BookmarkTest.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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\Entity;
|
||||
|
||||
use App\Entity\Bookmark;
|
||||
use App\Entity\User;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Entity\Bookmark
|
||||
*/
|
||||
class BookmarkTest extends TestCase
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$sut = new Bookmark();
|
||||
$this->assertNull($sut->getId());
|
||||
$this->assertNull($sut->getName());
|
||||
$this->assertIsArray($sut->getContent());
|
||||
$this->assertEquals([], $sut->getContent());
|
||||
$this->assertNull($sut->getType());
|
||||
$this->assertNull($sut->getUser());
|
||||
}
|
||||
|
||||
public function testSetterAndGetter()
|
||||
{
|
||||
$sut = new Bookmark();
|
||||
$sut->setName('foo-bar');
|
||||
$this->assertEquals('foo-bar', $sut->getName());
|
||||
|
||||
$sut->setContent(['test' => 'foo-bar', 'hello' => 'world']);
|
||||
$this->assertEquals(['test' => 'foo-bar', 'hello' => 'world'], $sut->getContent());
|
||||
|
||||
$sut->setType('sdsdsd');
|
||||
$this->assertEquals('sdsdsd', $sut->getType());
|
||||
|
||||
$user = new User();
|
||||
$sut->setUser($user);
|
||||
$this->assertEquals($user, $sut->getUser());
|
||||
|
||||
$sut2 = clone $sut;
|
||||
$this->assertEquals('sdsdsd', $sut2->getType());
|
||||
$this->assertEquals('foo-bar', $sut2->getName());
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ class PageActionsEventTest extends TestCase
|
||||
$this->assertEquals(8, $sut->countActions());
|
||||
|
||||
$expected = [
|
||||
'search' => ['class' => 'search-toggle visible-xs-inline'],
|
||||
'search' => ['modal' => '#modal_search'],
|
||||
'divider0' => null,
|
||||
'back' => ['url' => 'foo1', 'translation_domain' => 'actions'],
|
||||
'visibility' => ['modal' => '#foo2'],
|
||||
|
||||
40
tests/Form/Model/DateRangeTest.php
Normal file
40
tests/Form/Model/DateRangeTest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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\Form\Model;
|
||||
|
||||
use App\Form\Model\DateRange;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Form\Model\DateRange
|
||||
*/
|
||||
class DateRangeTest extends TestCase
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$sut = new DateRange();
|
||||
self::assertNull($sut->getBegin());
|
||||
self::assertNull($sut->getEnd());
|
||||
}
|
||||
|
||||
public function testSetterAndGetter()
|
||||
{
|
||||
$begin = new \DateTime('now');
|
||||
$end = new \DateTime('2018-11-25 18:45:32');
|
||||
|
||||
$sut = new DateRange();
|
||||
|
||||
self::assertInstanceOf(DateRange::class, $sut->setBegin($begin));
|
||||
self::assertInstanceOf(DateRange::class, $sut->setEnd($end));
|
||||
|
||||
self::assertEquals($begin->format('Y-m-d') . ' 00:00:00', $sut->getBegin()->format('Y-m-d H:i:s'));
|
||||
self::assertEquals('2018-11-25 23:59:59', $sut->getEnd()->format('Y-m-d H:i:s'));
|
||||
}
|
||||
}
|
||||
@@ -61,15 +61,22 @@ class ConfigExtensionTest extends TestCase
|
||||
'company' => null,
|
||||
'title' => null,
|
||||
],
|
||||
'auto_reload_datatable' => false,
|
||||
];
|
||||
}
|
||||
|
||||
public function testPrefix()
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings(), []);
|
||||
self::assertFalse($sut->getThemeConfig('auto_reload_datatable'));
|
||||
self::assertEquals(3, $sut->getThemeConfig('active_warning'));
|
||||
self::assertEquals('green', $sut->getThemeConfig('box_color'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testDeprecation()
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings(), []);
|
||||
self::assertFalse($sut->getThemeConfig('auto_reload_datatable'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user