improved duration and minute selector (#2264)
* do not close modal if form is dirty * deprecated TimesheetConfiguration * inject timezone in form types * cleanup usage of UserDateTimeFactory * allow to configure increment steps for minutes * use 15 minutes step for datetimepicker in project edit form * use rounding rules for increments in minute select for begin and end * allow duration in multi user and admin timesheet forms * make dropdown values configurable
This commit is contained in:
@@ -10,11 +10,11 @@
|
||||
namespace App\Tests\Configuration;
|
||||
|
||||
use App\Configuration\CalendarConfiguration;
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Configuration\CalendarConfiguration
|
||||
* @covers \App\Configuration\StringAccessibleConfigTrait
|
||||
* @group legacy
|
||||
*/
|
||||
class CalendarConfigurationTest extends TestCase
|
||||
@@ -28,7 +28,7 @@ class CalendarConfigurationTest extends TestCase
|
||||
{
|
||||
$loader = new TestConfigLoader($loaderSettings);
|
||||
|
||||
return new CalendarConfiguration($loader, $settings);
|
||||
return new CalendarConfiguration(new SystemConfiguration($loader, ['calendar' => $settings]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,4 +90,11 @@ class CalendarConfigurationTest extends TestCase
|
||||
self::assertEquals('09:00', $sut->getTimeframeBegin());
|
||||
self::assertEquals('21:34', $sut->getTimeframeEnd());
|
||||
}
|
||||
|
||||
public function testFindByKey()
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings(), []);
|
||||
$this->assertFalse($sut->find('week_numbers'));
|
||||
$this->assertFalse($sut->find('calendar.week_numbers'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
namespace App\Tests\Configuration;
|
||||
|
||||
use App\Configuration\FormConfiguration;
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Entity\Configuration;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Configuration\FormConfiguration
|
||||
* @covers \App\Configuration\StringAccessibleConfigTrait
|
||||
* @group legacy
|
||||
*/
|
||||
class FormConfigurationTest extends TestCase
|
||||
@@ -24,7 +24,7 @@ class FormConfigurationTest extends TestCase
|
||||
{
|
||||
$loader = new TestConfigLoader($loaderSettings);
|
||||
|
||||
return new FormConfiguration($loader, $settings);
|
||||
return new FormConfiguration(new SystemConfiguration($loader, ['defaults' => $settings]));
|
||||
}
|
||||
|
||||
protected function getDefaultSettings()
|
||||
@@ -83,7 +83,7 @@ class FormConfigurationTest extends TestCase
|
||||
$this->assertEquals('RU', $sut->getUserDefaultLanguage());
|
||||
$this->assertEquals('black', $sut->getUserDefaultTheme());
|
||||
$this->assertEquals('Russia/Moscov', $sut->getUserDefaultTimezone());
|
||||
$this->assertEquals('Russia/Moscov', $sut->offsetGet('defaults.user.timezone'));
|
||||
$this->assertEquals('Russia/Moscov', $sut->find('defaults.user.timezone'));
|
||||
}
|
||||
|
||||
public function testDefaultWithMixedConfigs()
|
||||
@@ -109,8 +109,6 @@ class FormConfigurationTest extends TestCase
|
||||
$sut = $this->getSut($this->getDefaultSettings(), [
|
||||
(new Configuration())->setName('defaults.customer.foobar')->setValue('hello'),
|
||||
]);
|
||||
$this->assertTrue($sut->has('customer.foobar'));
|
||||
$this->assertFalse($sut->has('xxxx.foobar'));
|
||||
$this->assertEquals('hello', $sut->find('customer.foobar'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ class SystemConfigurationTest extends TestCase
|
||||
'timesheet' => [
|
||||
'rules' => [
|
||||
'allow_future_times' => false,
|
||||
'lockdown_period_start' => null,
|
||||
'lockdown_period_end' => null,
|
||||
'lockdown_grace_period' => null,
|
||||
],
|
||||
'mode' => 'duration_only',
|
||||
'markdown_content' => false,
|
||||
@@ -44,6 +47,9 @@ class SystemConfigurationTest extends TestCase
|
||||
'hard_limit' => 99,
|
||||
'soft_limit' => 15,
|
||||
],
|
||||
'default_begin' => 'now',
|
||||
'duration_increment' => 10,
|
||||
'time_increment' => 5,
|
||||
],
|
||||
'defaults' => [
|
||||
'customer' => [
|
||||
@@ -94,12 +100,16 @@ class SystemConfigurationTest extends TestCase
|
||||
return [
|
||||
(new Configuration())->setName('defaults.customer.timezone')->setValue('Russia/Moscov'),
|
||||
(new Configuration())->setName('defaults.customer.currency')->setValue('RUB'),
|
||||
(new Configuration())->setName('calendar.slot_duration')->setValue('00:30:00'),
|
||||
(new Configuration())->setName('timesheet.rules.allow_future_times')->setValue('1'),
|
||||
(new Configuration())->setName('timesheet.rules.lockdown_period_start')->setValue('first day of last month'),
|
||||
(new Configuration())->setName('timesheet.rules.lockdown_period_end')->setValue('last day of last month'),
|
||||
(new Configuration())->setName('timesheet.rules.lockdown_grace_period')->setValue('+5 days'),
|
||||
(new Configuration())->setName('timesheet.mode')->setValue('default'),
|
||||
(new Configuration())->setName('timesheet.markdown_content')->setValue('1'),
|
||||
(new Configuration())->setName('timesheet.default_begin')->setValue('07:00'),
|
||||
(new Configuration())->setName('timesheet.active_entries.hard_limit')->setValue('7'),
|
||||
(new Configuration())->setName('timesheet.active_entries.soft_limit')->setValue('3'),
|
||||
(new Configuration())->setName('calendar.slot_duration')->setValue('00:30:00'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -114,7 +124,7 @@ class SystemConfigurationTest extends TestCase
|
||||
$sut = $this->getSut($this->getDefaultSettings(), []);
|
||||
$this->assertEquals('Europe/London', $sut->find('defaults.customer.timezone'));
|
||||
$this->assertEquals('GBP', $sut->find('defaults.customer.currency'));
|
||||
$this->assertEquals(false, $sut->find('timesheet.rules.allow_future_times'));
|
||||
$this->assertFalse($sut->find('timesheet.rules.allow_future_times'));
|
||||
$this->assertEquals(99, $sut->find('timesheet.active_entries.hard_limit'));
|
||||
}
|
||||
|
||||
@@ -123,7 +133,7 @@ class SystemConfigurationTest extends TestCase
|
||||
$sut = $this->getSut($this->getDefaultSettings(), $this->getDefaultLoaderSettings());
|
||||
$this->assertEquals('Russia/Moscov', $sut->find('defaults.customer.timezone'));
|
||||
$this->assertEquals('RUB', $sut->find('defaults.customer.currency'));
|
||||
$this->assertEquals(true, $sut->find('timesheet.rules.allow_future_times'));
|
||||
$this->assertTrue($sut->find('timesheet.rules.allow_future_times'));
|
||||
$this->assertEquals(7, $sut->find('timesheet.active_entries.hard_limit'));
|
||||
}
|
||||
|
||||
@@ -132,7 +142,7 @@ class SystemConfigurationTest extends TestCase
|
||||
$sut = $this->getSut($this->getDefaultSettings(), [
|
||||
(new Configuration())->setName('timesheet.rules.allow_future_times')->setValue(''),
|
||||
]);
|
||||
$this->assertEquals(false, $sut->find('timesheet.rules.allow_future_times'));
|
||||
$this->assertFalse($sut->find('timesheet.rules.allow_future_times'));
|
||||
}
|
||||
|
||||
public function testUnknownConfigs()
|
||||
@@ -194,4 +204,52 @@ class SystemConfigurationTest extends TestCase
|
||||
$this->assertEquals('IT', $sut->getUserDefaultLanguage());
|
||||
$this->assertEquals('USD', $sut->getUserDefaultCurrency());
|
||||
}
|
||||
|
||||
public function testTimesheetWithoutLoader()
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings(), []);
|
||||
$this->assertEquals(99, $sut->getTimesheetActiveEntriesHardLimit());
|
||||
$this->assertEquals(15, $sut->getTimesheetActiveEntriesSoftLimit());
|
||||
$this->assertFalse($sut->isTimesheetAllowFutureTimes());
|
||||
$this->assertFalse($sut->isTimesheetMarkdownEnabled());
|
||||
$this->assertEquals('duration_only', $sut->getTimesheetTrackingMode());
|
||||
$this->assertEquals('now', $sut->getTimesheetDefaultBeginTime());
|
||||
$this->assertFalse($sut->isTimesheetLockdownActive());
|
||||
$this->assertEquals('', $sut->getTimesheetLockdownPeriodStart());
|
||||
$this->assertEquals('', $sut->getTimesheetLockdownPeriodEnd());
|
||||
$this->assertEquals('', $sut->getTimesheetLockdownGracePeriod());
|
||||
$this->assertEquals('', $sut->isTimesheetAllowOverlappingRecords());
|
||||
$this->assertEquals('', $sut->getTimesheetDefaultRoundingDays());
|
||||
$this->assertEquals('', $sut->getTimesheetDefaultRoundingMode());
|
||||
$this->assertEquals(0, $sut->getTimesheetDefaultRoundingDuration());
|
||||
$this->assertEquals(0, $sut->getTimesheetDefaultRoundingEnd());
|
||||
$this->assertEquals(0, $sut->getTimesheetDefaultRoundingBegin());
|
||||
$this->assertEquals(10, $sut->getTimesheetIncrementDuration());
|
||||
$this->assertEquals(5, $sut->getTimesheetIncrementBegin());
|
||||
$this->assertEquals(5, $sut->getTimesheetIncrementEnd());
|
||||
}
|
||||
|
||||
public function testTimesheetWithLoader()
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings(), $this->getDefaultLoaderSettings());
|
||||
$this->assertEquals(7, $sut->getTimesheetActiveEntriesHardLimit());
|
||||
$this->assertEquals(3, $sut->getTimesheetActiveEntriesSoftLimit());
|
||||
$this->assertTrue($sut->isTimesheetAllowFutureTimes());
|
||||
$this->assertTrue($sut->isTimesheetMarkdownEnabled());
|
||||
$this->assertEquals('default', $sut->getTimesheetTrackingMode());
|
||||
$this->assertEquals('07:00', $sut->getTimesheetDefaultBeginTime());
|
||||
$this->assertTrue($sut->isTimesheetLockdownActive());
|
||||
$this->assertEquals('first day of last month', $sut->getTimesheetLockdownPeriodStart());
|
||||
$this->assertEquals('last day of last month', $sut->getTimesheetLockdownPeriodEnd());
|
||||
$this->assertEquals('+5 days', $sut->getTimesheetLockdownGracePeriod());
|
||||
$this->assertEquals('', $sut->isTimesheetAllowOverlappingRecords());
|
||||
$this->assertEquals('', $sut->getTimesheetDefaultRoundingDays());
|
||||
$this->assertEquals('', $sut->getTimesheetDefaultRoundingMode());
|
||||
$this->assertEquals(0, $sut->getTimesheetDefaultRoundingDuration());
|
||||
$this->assertEquals(0, $sut->getTimesheetDefaultRoundingEnd());
|
||||
$this->assertEquals(0, $sut->getTimesheetDefaultRoundingBegin());
|
||||
$this->assertEquals(10, $sut->getTimesheetIncrementDuration());
|
||||
$this->assertEquals(5, $sut->getTimesheetIncrementBegin());
|
||||
$this->assertEquals(5, $sut->getTimesheetIncrementEnd());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,14 @@
|
||||
|
||||
namespace App\Tests\Configuration;
|
||||
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Configuration\TimesheetConfiguration;
|
||||
use App\Entity\Configuration;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Configuration\TimesheetConfiguration
|
||||
* @covers \App\Configuration\StringAccessibleConfigTrait
|
||||
* @group legacy
|
||||
*/
|
||||
class TimesheetConfigurationTest extends TestCase
|
||||
{
|
||||
@@ -28,7 +29,9 @@ class TimesheetConfigurationTest extends TestCase
|
||||
{
|
||||
$loader = new TestConfigLoader($loaderSettings);
|
||||
|
||||
return new TimesheetConfiguration($loader, $settings);
|
||||
$config = new SystemConfiguration($loader, ['timesheet' => $settings]);
|
||||
|
||||
return new TimesheetConfiguration($config);
|
||||
}
|
||||
|
||||
protected function getDefaultSettings()
|
||||
@@ -74,6 +77,7 @@ class TimesheetConfigurationTest extends TestCase
|
||||
public function testDefaultWithoutLoader()
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings(), []);
|
||||
|
||||
$this->assertEquals(99, $sut->getActiveEntriesHardLimit());
|
||||
$this->assertEquals(15, $sut->getActiveEntriesSoftLimit());
|
||||
$this->assertFalse($sut->isAllowFutureTimes());
|
||||
@@ -84,6 +88,12 @@ class TimesheetConfigurationTest extends TestCase
|
||||
$this->assertEquals('', $sut->getLockdownPeriodStart());
|
||||
$this->assertEquals('', $sut->getLockdownPeriodEnd());
|
||||
$this->assertEquals('', $sut->getLockdownGracePeriod());
|
||||
$this->assertEquals('', $sut->isAllowOverlappingRecords());
|
||||
$this->assertEquals('', $sut->getDefaultRoundingDays());
|
||||
$this->assertEquals('', $sut->getDefaultRoundingMode());
|
||||
$this->assertEquals(0, $sut->getDefaultRoundingBegin());
|
||||
$this->assertEquals(0, $sut->getDefaultRoundingEnd());
|
||||
$this->assertEquals(0, $sut->getDefaultRoundingDuration());
|
||||
}
|
||||
|
||||
public function testDefaultWithLoader()
|
||||
@@ -91,8 +101,8 @@ class TimesheetConfigurationTest extends TestCase
|
||||
$sut = $this->getSut($this->getDefaultSettings(), $this->getDefaultLoaderSettings());
|
||||
$this->assertEquals(7, $sut->getActiveEntriesHardLimit());
|
||||
$this->assertEquals(3, $sut->getActiveEntriesSoftLimit());
|
||||
$this->assertEquals(true, $sut->isAllowFutureTimes());
|
||||
$this->assertEquals(true, $sut->isMarkdownEnabled());
|
||||
$this->assertTrue($sut->isAllowFutureTimes());
|
||||
$this->assertTrue($sut->isMarkdownEnabled());
|
||||
$this->assertEquals('default', $sut->getTrackingMode());
|
||||
$this->assertEquals('07:00', $sut->getDefaultBeginTime());
|
||||
$this->assertTrue($sut->isLockdownActive());
|
||||
@@ -112,8 +122,8 @@ class TimesheetConfigurationTest extends TestCase
|
||||
public function testFindByKey()
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings(), []);
|
||||
$this->assertEquals(false, $sut->find('rules.allow_future_times'));
|
||||
$this->assertEquals(false, $sut->find('timesheet.rules.allow_future_times'));
|
||||
$this->assertFalse($sut->find('rules.allow_future_times'));
|
||||
$this->assertFalse($sut->find('timesheet.rules.allow_future_times'));
|
||||
}
|
||||
|
||||
public function testUnknownConfigAreImported()
|
||||
@@ -121,7 +131,6 @@ class TimesheetConfigurationTest extends TestCase
|
||||
$sut = $this->getSut($this->getDefaultSettings(), [
|
||||
(new Configuration())->setName('timesheet.foo')->setValue('hello'),
|
||||
]);
|
||||
$this->assertTrue($sut->has('foo'));
|
||||
$this->assertEquals('hello', $sut->find('foo'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user