added begin, end and export filter for API timesheets (#639)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Configuration\LanguageFormattings;
|
||||
use App\Utils\LocaleSettings;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -16,6 +17,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\LocaleSettings
|
||||
* @covers \App\Configuration\LanguageFormattings
|
||||
*/
|
||||
class LocaleSettingsTest extends TestCase
|
||||
{
|
||||
@@ -31,7 +33,7 @@ class LocaleSettingsTest extends TestCase
|
||||
|
||||
protected function getSut(string $locale, array $settings)
|
||||
{
|
||||
return new LocaleSettings($this->getRequestStack($locale), $settings);
|
||||
return new LocaleSettings($this->getRequestStack($locale), new LanguageFormattings($settings));
|
||||
}
|
||||
|
||||
protected function getDefaultSettings()
|
||||
@@ -45,6 +47,8 @@ class LocaleSettingsTest extends TestCase
|
||||
'date' => 'd.m.Y',
|
||||
'date_time' => 'd.m. H:i',
|
||||
'duration' => '%h:%m h',
|
||||
'time' => 'H:i',
|
||||
'24_hours' => true,
|
||||
],
|
||||
'en' => [
|
||||
'date_time_type' => 'yyyy-MM-dd HH:mm',
|
||||
@@ -54,6 +58,8 @@ class LocaleSettingsTest extends TestCase
|
||||
'date' => 'Y-m-d',
|
||||
'date_time' => 'm-d H:i',
|
||||
'duration' => '%h:%m h',
|
||||
'time' => 'H:i:s',
|
||||
'24_hours' => false,
|
||||
],
|
||||
'pt_BR' => [
|
||||
'date_time_type' => 'dd-MM-yyyy HH:mm',
|
||||
@@ -146,57 +152,62 @@ class LocaleSettingsTest extends TestCase
|
||||
*/
|
||||
public function testInvalidLocaleWithGivenLocale()
|
||||
{
|
||||
$sut = $this->getSut('en', $this->getDefaultSettings());
|
||||
$sut->getDateFormat('xx');
|
||||
$sut = $this->getSut('xx', $this->getDefaultSettings());
|
||||
$sut->getDateFormat();
|
||||
}
|
||||
|
||||
public function testGetDurationFormat()
|
||||
{
|
||||
$sut = $this->getSut('en', $this->getDefaultSettings());
|
||||
$this->assertEquals('%h:%m h', $sut->getDurationFormat());
|
||||
$this->assertEquals('%h:%m h', $sut->getDurationFormat('de'));
|
||||
}
|
||||
|
||||
public function testGetDateFormat()
|
||||
{
|
||||
$sut = $this->getSut('en', $this->getDefaultSettings());
|
||||
$this->assertEquals('Y-m-d', $sut->getDateFormat());
|
||||
$this->assertEquals('d.m.Y', $sut->getDateFormat('de'));
|
||||
$sut = $this->getSut('de', $this->getDefaultSettings());
|
||||
$this->assertEquals('d.m.Y', $sut->getDateFormat());
|
||||
}
|
||||
|
||||
public function testGetDateTimeFormat()
|
||||
{
|
||||
$sut = $this->getSut('en', $this->getDefaultSettings());
|
||||
$this->assertEquals('m-d H:i', $sut->getDateTimeFormat());
|
||||
$this->assertEquals('d.m. H:i', $sut->getDateTimeFormat('de'));
|
||||
}
|
||||
|
||||
public function testGetDateTypeFormat()
|
||||
{
|
||||
$sut = $this->getSut('en', $this->getDefaultSettings());
|
||||
$this->assertEquals('yyyy-MM-dd', $sut->getDateTypeFormat());
|
||||
$this->assertEquals('dd.MM.yyyy', $sut->getDateTypeFormat('de'));
|
||||
$sut = $this->getSut('de', $this->getDefaultSettings());
|
||||
$this->assertEquals('dd.MM.yyyy', $sut->getDateTypeFormat());
|
||||
}
|
||||
|
||||
public function testGetDatePickerFormat()
|
||||
{
|
||||
$sut = $this->getSut('en', $this->getDefaultSettings());
|
||||
$this->assertEquals('YYYY-MM-DD', $sut->getDatePickerFormat());
|
||||
$this->assertEquals('DD.MM.YYYY', $sut->getDatePickerFormat('de'));
|
||||
}
|
||||
|
||||
public function testGetDateTimeTypeFormat()
|
||||
{
|
||||
$sut = $this->getSut('en', $this->getDefaultSettings());
|
||||
$this->assertEquals('yyyy-MM-dd HH:mm', $sut->getDateTimeTypeFormat());
|
||||
$this->assertEquals('dd.MM.yyyy HH:mm', $sut->getDateTimeTypeFormat('de'));
|
||||
}
|
||||
|
||||
public function testGetDateTimePickerFormat()
|
||||
{
|
||||
$sut = $this->getSut('en', $this->getDefaultSettings());
|
||||
$this->assertEquals('YYYY-MM-DD HH:mm', $sut->getDateTimePickerFormat());
|
||||
$this->assertEquals('DD.MM.YYYY HH:mm', $sut->getDateTimePickerFormat('de'));
|
||||
}
|
||||
|
||||
public function testIs24Hours()
|
||||
{
|
||||
$sut = $this->getSut('en', $this->getDefaultSettings());
|
||||
$this->assertFalse($sut->isTwentyFourHours());
|
||||
}
|
||||
|
||||
public function testGetTimeFormat()
|
||||
{
|
||||
$sut = $this->getSut('en', $this->getDefaultSettings());
|
||||
$this->assertEquals('H:i:s', $sut->getTimeFormat());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,6 +219,6 @@ class LocaleSettingsTest extends TestCase
|
||||
$sut = $this->getSut('en', ['en' => [
|
||||
'xxx' => 'dd.MM.yyyy HH:mm',
|
||||
]]);
|
||||
$sut->getDateTimePickerFormat('en');
|
||||
$sut->getDateTimePickerFormat();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user