Split user language (UI translation) from locale (formatted values) (#4595)
This commit is contained in:
@@ -364,6 +364,7 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
'roles' => ['result' => 'array', 'type' => 'string'],
|
||||
'initials' => 'string',
|
||||
'language' => 'string',
|
||||
'locale' => 'string',
|
||||
'timezone' => 'string',
|
||||
'accountNumber' => '@string',
|
||||
'memberships' => ['result' => 'array', 'type' => 'TeamMembership'],
|
||||
|
||||
@@ -17,65 +17,102 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
class LocaleServiceTest extends TestCase
|
||||
{
|
||||
protected function getSut(array $settings)
|
||||
protected function getSut(array $settings): LocaleService
|
||||
{
|
||||
return new LocaleService($settings);
|
||||
}
|
||||
|
||||
protected function getDefaultSettings()
|
||||
/**
|
||||
* @return array<string, array{'date': string, 'time': string, 'rtl': bool, 'translation': bool}>
|
||||
*/
|
||||
protected function getDefaultSettings(): array
|
||||
{
|
||||
return [
|
||||
'de' => [
|
||||
'date' => 'd.m.Y',
|
||||
'duration' => '%h:%m',
|
||||
'time' => 'H:i',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
],
|
||||
'en' => [
|
||||
'date' => 'Y-m-d',
|
||||
'duration' => '%h:%m',
|
||||
'time' => 'H:i:s',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
],
|
||||
'en_AU' => [
|
||||
'date' => 'Y-m-d',
|
||||
'time' => 'H:i:s',
|
||||
'rtl' => false,
|
||||
'translation' => false,
|
||||
],
|
||||
'pt_BR' => [
|
||||
'date' => 'd-m-Y',
|
||||
'duration' => '%h:%m',
|
||||
'time' => 'HH:mm',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
],
|
||||
'it' => [
|
||||
'date' => 'd.m.Y',
|
||||
'duration' => '%h:%m',
|
||||
'time' => 'HH:mm',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
],
|
||||
'fr' => [
|
||||
'date' => 'd/m/Y',
|
||||
'duration' => '%h h %m',
|
||||
'time' => 'HH:mm',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
],
|
||||
'fr_BE' => [
|
||||
'date' => 'd/MM/yy',
|
||||
'time' => 'HH:mm',
|
||||
'rtl' => false,
|
||||
'translation' => false,
|
||||
],
|
||||
'fr_CA' => [
|
||||
'date' => 'y-MM-dd',
|
||||
'time' => 'HH \'h\' mm',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
],
|
||||
'es' => [
|
||||
'date' => 'd.m.Y',
|
||||
'duration' => '%h:%m',
|
||||
'time' => 'HH:mm',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
],
|
||||
'ru' => [
|
||||
'date' => 'd.m.Y',
|
||||
'duration' => '%h:%m',
|
||||
'time' => 'HH:mm',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
],
|
||||
'ar' => [
|
||||
'date' => 'Y-m-d',
|
||||
'duration' => '%h:%m',
|
||||
'time' => 'HH:mm',
|
||||
'rtl' => true,
|
||||
'translation' => true,
|
||||
],
|
||||
'hu' => [
|
||||
'date' => 'Y.m.d.',
|
||||
'duration' => '%h:%m',
|
||||
'time' => 'HH:mm',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function testGetAllLocales()
|
||||
public function testGetAllLocales(): void
|
||||
{
|
||||
$sut = $this->getSut([]);
|
||||
$this->assertEquals([], $sut->getAllLocales());
|
||||
|
||||
$sut = $this->getSut($this->getDefaultSettings());
|
||||
$this->assertEquals(['de', 'en', 'pt_BR', 'it', 'fr', 'es', 'ru', 'ar', 'hu'], $sut->getAllLocales());
|
||||
$this->assertEquals(['de', 'en', 'en_AU', 'pt_BR', 'it', 'fr', 'fr_BE', 'fr_CA', 'es', 'ru', 'ar', 'hu'], $sut->getAllLocales());
|
||||
}
|
||||
|
||||
public function testInvalidLocaleWithGivenLocale()
|
||||
public function testInvalidLocaleWithGivenLocale(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Unknown locale given: xx');
|
||||
@@ -84,28 +121,54 @@ class LocaleServiceTest extends TestCase
|
||||
$sut->getDateFormat('xx');
|
||||
}
|
||||
|
||||
public function testGetDurationFormat()
|
||||
public function testGetDurationFormat(): void
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings());
|
||||
$this->assertEquals('%h:%m', $sut->getDurationFormat('de'));
|
||||
}
|
||||
|
||||
public function testGetDateFormat()
|
||||
public function testGetDateFormat(): void
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings());
|
||||
$this->assertEquals('d.m.Y', $sut->getDateFormat('de'));
|
||||
}
|
||||
|
||||
public function testGetDateTimeFormat()
|
||||
public function testGetDateTimeFormat(): void
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings());
|
||||
$this->assertEquals('d.m.Y H:i', $sut->getDateTimeFormat('de'));
|
||||
}
|
||||
|
||||
public function testGetTimeFormat()
|
||||
public function testGetTimeFormat(): void
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings());
|
||||
$this->assertEquals('H:i', $sut->getTimeFormat('de'));
|
||||
$this->assertEquals('H:i:s', $sut->getTimeFormat('en'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getNearestTranslationLocaleData
|
||||
*/
|
||||
public function testGetNearestTranslationLocale(string $locale, string $expected): void
|
||||
{
|
||||
$sut = $this->getSut($this->getDefaultSettings());
|
||||
$actual = $sut->getNearestTranslationLocale($locale);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<int, string>>
|
||||
*/
|
||||
public function getNearestTranslationLocaleData(): array
|
||||
{
|
||||
return [
|
||||
['de', 'de'], // registered and translated: use it
|
||||
['pt_BR', 'pt_BR'], // registered and translated: use it
|
||||
['fr_CA', 'fr_CA'], // registered and translated: use it
|
||||
['fr_BE', 'fr'], // not translated, fallback to base locale
|
||||
['fr_DZ', 'fr'], // not registered region locale, but fallback to base locale
|
||||
['en_AU', 'en'], // not translated, fallback to base locale
|
||||
['uk_UA', 'en'], // not registered locales fallback to en
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,7 +422,8 @@ class ProfileControllerTest extends ControllerBaseTest
|
||||
|
||||
$data = [
|
||||
UserPreference::TIMEZONE => ['value' => 'America/Creston'],
|
||||
UserPreference::LOCALE => ['value' => 'ar'],
|
||||
UserPreference::LANGUAGE => ['value' => 'ar'],
|
||||
UserPreference::LOCALE => ['value' => 'ru'],
|
||||
UserPreference::FIRST_WEEKDAY => ['value' => 'sunday'],
|
||||
UserPreference::SKIN => ['value' => 'dark'],
|
||||
];
|
||||
@@ -453,9 +454,10 @@ class ProfileControllerTest extends ControllerBaseTest
|
||||
$this->assertEquals($expectedInternalRate, $user->getPreferenceValue(UserPreference::INTERNAL_RATE));
|
||||
$this->assertEquals('America/Creston', $user->getPreferenceValue(UserPreference::TIMEZONE));
|
||||
$this->assertEquals('America/Creston', $user->getTimezone());
|
||||
$this->assertEquals('ar', $user->getPreferenceValue(UserPreference::LOCALE));
|
||||
$this->assertEquals('ar', $user->getPreferenceValue(UserPreference::LANGUAGE));
|
||||
$this->assertEquals('ru', $user->getPreferenceValue(UserPreference::LOCALE));
|
||||
$this->assertEquals('ru', $user->getLocale());
|
||||
$this->assertEquals('ar', $user->getLanguage());
|
||||
$this->assertEquals('ar', $user->getLocale());
|
||||
$this->assertEquals('dark', $user->getPreferenceValue(UserPreference::SKIN));
|
||||
$this->assertEquals('sunday', $user->getPreferenceValue(UserPreference::FIRST_WEEKDAY));
|
||||
$this->assertEquals('sunday', $user->getFirstDayOfWeek());
|
||||
|
||||
@@ -71,26 +71,31 @@ class AppExtensionTest extends TestCase
|
||||
'date' => 'M/d/yy',
|
||||
'time' => 'h:mm a',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
],
|
||||
'de' => [
|
||||
'date' => 'dd.MM.yy',
|
||||
'time' => 'HH:mm',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
],
|
||||
'he' => [
|
||||
'date' => 'd.M.y',
|
||||
'time' => 'H:mm',
|
||||
'rtl' => true,
|
||||
'translation' => true,
|
||||
],
|
||||
'tr' => [
|
||||
'date' => 'd.MM.y',
|
||||
'time' => 'HH:mm',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
],
|
||||
'zh_CN' => [
|
||||
'date' => 'y/M/d',
|
||||
'time' => 'HH:mm',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
],
|
||||
],
|
||||
'kimai.invoice.documents' => [
|
||||
|
||||
@@ -43,6 +43,7 @@ class UserTest extends TestCase
|
||||
self::assertNull($user->getPasswordRequestedAt());
|
||||
self::assertFalse($user->hasTotpSecret());
|
||||
self::assertNull($user->getTotpSecret());
|
||||
self::assertEquals(User::DEFAULT_LANGUAGE, $user->getLanguage());
|
||||
self::assertEquals(User::DEFAULT_LANGUAGE, $user->getLocale());
|
||||
self::assertFalse($user->hasTeamAssignment());
|
||||
self::assertFalse($user->canSeeAllData());
|
||||
@@ -288,13 +289,20 @@ class UserTest extends TestCase
|
||||
|
||||
public function testGetLocale(): void
|
||||
{
|
||||
$sut = new User();
|
||||
self::assertEquals(User::DEFAULT_LANGUAGE, $sut->getLocale());
|
||||
$user = new User();
|
||||
self::assertEquals(User::DEFAULT_LANGUAGE, $user->getLocale());
|
||||
|
||||
$language = new UserPreference(UserPreference::LOCALE, 'fr');
|
||||
$sut->addPreference($language);
|
||||
|
||||
self::assertEquals('fr', $sut->getLocale());
|
||||
self::assertEquals('en', $user->getLanguage());
|
||||
self::assertEquals('en', $user->getLocale());
|
||||
$user->setLanguage('it');
|
||||
self::assertEquals('it', $user->getLanguage());
|
||||
self::assertEquals('it', $user->getLocale());
|
||||
$user->setLocale('de');
|
||||
self::assertEquals('it', $user->getLanguage());
|
||||
self::assertEquals('de', $user->getLocale());
|
||||
$user->setPreferenceValue(UserPreference::LOCALE, 'hu');
|
||||
self::assertEquals('it', $user->getLanguage());
|
||||
self::assertEquals('hu', $user->getLocale());
|
||||
}
|
||||
|
||||
public function testTeams(): void
|
||||
|
||||
@@ -22,10 +22,10 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
*/
|
||||
class RedirectToLocaleSubscriberTest extends TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
public function testConstruct(): void
|
||||
{
|
||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||
$sut = new RedirectToLocaleSubscriber($urlGenerator, new LocaleService(['de', 'en']));
|
||||
$sut = new RedirectToLocaleSubscriber($urlGenerator, new LocaleService(['de' => LocaleService::DEFAULT_SETTINGS, 'en' => LocaleService::DEFAULT_SETTINGS]));
|
||||
|
||||
self::assertEquals([KernelEvents::REQUEST => ['onKernelRequest']], RedirectToLocaleSubscriber::getSubscribedEvents());
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ class UserPreferenceSubscriberTest extends TestCase
|
||||
'internal_rate',
|
||||
'timezone',
|
||||
'language',
|
||||
'locale',
|
||||
'first_weekday',
|
||||
'skin',
|
||||
'update_browser_title',
|
||||
|
||||
@@ -45,11 +45,7 @@ abstract class AbstractRendererTest extends KernelTestCase
|
||||
protected function getAbstractRenderer(string $classname)
|
||||
{
|
||||
$languages = [
|
||||
'en' => [
|
||||
'date' => 'Y.m.d',
|
||||
'duration' => '%h:%m',
|
||||
'time' => 'H:i',
|
||||
]
|
||||
'en' => LocaleService::DEFAULT_SETTINGS
|
||||
];
|
||||
|
||||
$security = $this->createMock(Security::class);
|
||||
|
||||
@@ -44,11 +44,7 @@ abstract class AbstractRendererTest extends KernelTestCase
|
||||
protected function getAbstractRenderer(string $classname)
|
||||
{
|
||||
$languages = [
|
||||
'en' => [
|
||||
'date' => 'Y.m.d',
|
||||
'duration' => '%h:%m',
|
||||
'time' => 'H:i',
|
||||
]
|
||||
'en' => LocaleService::DEFAULT_SETTINGS
|
||||
];
|
||||
|
||||
$user = new User();
|
||||
|
||||
@@ -26,9 +26,10 @@ class ProjectHelperTest extends TestCase
|
||||
{
|
||||
$config = SystemConfigurationFactory::createStub(['project.choice_pattern' => $format]);
|
||||
|
||||
$localeService = new LocaleService(['en_US' => ['date' => 'dd.MM.y']]);
|
||||
$localeService = new LocaleService(['en_US' => LocaleService::DEFAULT_SETTINGS]);
|
||||
$translator = $this->createMock(TranslatorInterface::class);
|
||||
$translator->method('trans')->willReturn('dating');
|
||||
|
||||
$helper = new ProjectHelper($config, $localeService, $translator);
|
||||
$helper->setLocale('en_US');
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ trait RendererTestTrait
|
||||
'date' => 'yy.MM.dd',
|
||||
'time' => 'H:i',
|
||||
'rtl' => false,
|
||||
'translation' => true,
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
@@ -38,11 +38,7 @@ class ServiceInvoiceTest extends TestCase
|
||||
private function getSut(array $paths): ServiceInvoice
|
||||
{
|
||||
$languages = [
|
||||
'en' => [
|
||||
'date' => 'Y.m.d',
|
||||
'duration' => '%h:%m',
|
||||
'time' => 'H:i',
|
||||
]
|
||||
'en' => LocaleService::DEFAULT_SETTINGS
|
||||
];
|
||||
|
||||
$formattings = new LocaleService($languages);
|
||||
|
||||
@@ -48,27 +48,18 @@ class LocaleFormatExtensionsTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $locale
|
||||
* @param array|string $dateSettings
|
||||
* @return LocaleFormatExtensions
|
||||
* @param array<string, array{'date': string, 'time': string, 'rtl': bool, 'translation': bool}> $languageSettings
|
||||
*/
|
||||
protected function getSut($locale, $dateSettings, ?User $user = null)
|
||||
private function getSut(string $locale, array $languageSettings): LocaleFormatExtensions
|
||||
{
|
||||
$language = $locale;
|
||||
if (\is_array($locale)) {
|
||||
$language = $dateSettings;
|
||||
$dateSettings = $locale;
|
||||
}
|
||||
$user = new User();
|
||||
$user->setTimezone('Europe/Vienna');
|
||||
|
||||
if ($user === null) {
|
||||
$user = new User();
|
||||
$user->setTimezone('Europe/Vienna');
|
||||
}
|
||||
$security = $this->createMock(Security::class);
|
||||
$security->expects($this->any())->method('getUser')->willReturn($user);
|
||||
|
||||
$sut = new LocaleFormatExtensions(new LocaleService($dateSettings), $security);
|
||||
$sut->setLocale($language);
|
||||
$sut = new LocaleFormatExtensions(new LocaleService($languageSettings), $security);
|
||||
$sut->setLocale($locale);
|
||||
|
||||
return $sut;
|
||||
}
|
||||
@@ -143,9 +134,9 @@ class LocaleFormatExtensionsTest extends TestCase
|
||||
public function testDateShort(string $locale, \DateTime|string|null $date, string $expected): void
|
||||
{
|
||||
$sut = $this->getSut($locale, [
|
||||
'de' => ['date' => 'dd.MM.Y'],
|
||||
'en' => ['date' => 'Y-MM-dd'],
|
||||
'ru' => ['date' => 'dd.MM.Y'],
|
||||
'de' => array_merge(LocaleService::DEFAULT_SETTINGS, ['date' => 'dd.MM.Y']),
|
||||
'en' => array_merge(LocaleService::DEFAULT_SETTINGS, ['date' => 'Y-MM-dd']),
|
||||
'ru' => array_merge(LocaleService::DEFAULT_SETTINGS, ['date' => 'dd.MM.Y']),
|
||||
]);
|
||||
$this->assertEquals($expected, $sut->dateShort($date));
|
||||
}
|
||||
@@ -175,8 +166,8 @@ class LocaleFormatExtensionsTest extends TestCase
|
||||
public function testDateTime(string $locale, \DateTime|string|null $date, string $expected): void
|
||||
{
|
||||
$sut = $this->getSut($locale, [
|
||||
'de' => ['date' => 'dd.MM.Y', 'time' => 'HH:mm:s'],
|
||||
'en' => ['date' => 'Y-MM-dd', 'time' => 'h:mm a'],
|
||||
'de' => array_merge(LocaleService::DEFAULT_SETTINGS, ['date' => 'dd.MM.Y', 'time' => 'HH:mm:s']),
|
||||
'en' => array_merge(LocaleService::DEFAULT_SETTINGS, ['date' => 'Y-MM-dd', 'time' => 'h:mm a']),
|
||||
]);
|
||||
$this->assertEquals($expected, $sut->dateTime($date));
|
||||
}
|
||||
@@ -265,7 +256,7 @@ class LocaleFormatExtensionsTest extends TestCase
|
||||
$time = new \DateTime('2016-06-23');
|
||||
$time->setTime(17, 53, 23);
|
||||
|
||||
$sut = $this->getSut('en', ['en' => ['time' => 'HH:mm']]);
|
||||
$sut = $this->getSut('en', ['en' => array_merge(LocaleService::DEFAULT_SETTINGS, ['time' => 'HH:mm'])]);
|
||||
$this->assertEquals('17:53', $sut->time($time));
|
||||
$this->assertEquals('17:53', $sut->time('2016-06-23 17:53'));
|
||||
}
|
||||
@@ -289,10 +280,10 @@ class LocaleFormatExtensionsTest extends TestCase
|
||||
|
||||
public function testMoneyWithoutCurrency(): void
|
||||
{
|
||||
$sut = $this->getSut($this->localeEn, 'en');
|
||||
$sut = $this->getSut('en', $this->localeEn);
|
||||
$this->assertEquals('123.75', $sut->money(123.75));
|
||||
|
||||
$sut = $this->getSut($this->localeEn, 'de');
|
||||
$sut = $this->getSut('de', $this->localeEn);
|
||||
$this->assertEquals('123.234,76', $sut->money(123234.7554, null, true));
|
||||
$this->assertEquals('123.234,76', $sut->money(123234.7554, null, false));
|
||||
$this->assertEquals('123.234,76', $sut->money(123234.7554, 'EUR', false));
|
||||
@@ -303,7 +294,7 @@ class LocaleFormatExtensionsTest extends TestCase
|
||||
*/
|
||||
public function testMoneyNoCurrency($result, $amount, $currency, $locale): void
|
||||
{
|
||||
$sut = $this->getSut($this->localeEn, $locale);
|
||||
$sut = $this->getSut($locale, $this->localeEn);
|
||||
$this->assertEquals($result, $sut->money($amount, $currency, false));
|
||||
}
|
||||
|
||||
@@ -338,7 +329,7 @@ class LocaleFormatExtensionsTest extends TestCase
|
||||
*/
|
||||
public function testMoney(string $result, float|int|null $amount, string $currency, string $locale): void
|
||||
{
|
||||
$sut = $this->getSut($this->localeEn, $locale);
|
||||
$sut = $this->getSut($locale, $this->localeEn);
|
||||
$this->assertEquals($result, $sut->money($amount, $currency));
|
||||
}
|
||||
|
||||
@@ -370,9 +361,9 @@ class LocaleFormatExtensionsTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getAmountData
|
||||
*/
|
||||
public function testAmount($result, $amount, $locale): void
|
||||
public function testAmount(string $result, null|int|float|string $amount, string $locale): void
|
||||
{
|
||||
$sut = $this->getSut($this->localeEn, $locale);
|
||||
$sut = $this->getSut($locale, $this->localeEn);
|
||||
$this->assertEquals($result, $sut->amount($amount));
|
||||
}
|
||||
|
||||
@@ -391,6 +382,7 @@ class LocaleFormatExtensionsTest extends TestCase
|
||||
['2.345,009', 2345.009, 'de'],
|
||||
['13.75', 13.75, 'en'],
|
||||
['13,75', 13.75, 'de'],
|
||||
['13,75', '13.75', 'de'],
|
||||
["13\u{a0}933,49", 13933.49, 'ru'],
|
||||
['1.234.567,891', 1234567.891234567890000, 'de'],
|
||||
];
|
||||
@@ -399,11 +391,11 @@ class LocaleFormatExtensionsTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getMoneyData62_1
|
||||
*/
|
||||
public function testMoney62_1($result, $amount, $currency, $locale): void
|
||||
public function testMoney62_1(string $result, null|int|float $amount, string $currency, string $locale): void
|
||||
{
|
||||
IntlTestHelper::requireFullIntl($this, '62.1');
|
||||
|
||||
$sut = $this->getSut($this->localeEn, $locale);
|
||||
$sut = $this->getSut($locale, $this->localeEn);
|
||||
$this->assertEquals($result, $sut->money($amount, $currency));
|
||||
}
|
||||
|
||||
@@ -432,11 +424,11 @@ class LocaleFormatExtensionsTest extends TestCase
|
||||
$this->assertEquals('2.62', $sut->duration($record, true));
|
||||
|
||||
// test extended format
|
||||
$sut = $this->getSut($this->localeFake, 'XX');
|
||||
$sut = $this->getSut('XX', $this->localeFake);
|
||||
$this->assertEquals('2:37', $sut->duration($record->getDuration()));
|
||||
|
||||
// test negative duration
|
||||
$sut = $this->getSut($this->localeEn, 'en');
|
||||
$sut = $this->getSut('en', $this->localeEn);
|
||||
$this->assertEquals('0:00', $sut->duration(0));
|
||||
$this->assertEquals('0:00', $sut->duration(-1));
|
||||
$this->assertEquals('0:00', $sut->duration(-59));
|
||||
@@ -444,10 +436,10 @@ class LocaleFormatExtensionsTest extends TestCase
|
||||
$this->assertEquals('-1:36', $sut->duration(-5786));
|
||||
|
||||
// test zero duration
|
||||
$sut = $this->getSut($this->localeEn, 'en');
|
||||
$sut = $this->getSut('en', $this->localeEn);
|
||||
$this->assertEquals('0:00', $sut->duration(0));
|
||||
|
||||
$sut = $this->getSut($this->localeEn, 'en');
|
||||
$sut = $this->getSut('en', $this->localeEn);
|
||||
|
||||
$this->assertEquals('0:00', $sut->duration(null));
|
||||
$this->assertEquals('0.00', $sut->duration(null, true));
|
||||
@@ -499,31 +491,31 @@ class LocaleFormatExtensionsTest extends TestCase
|
||||
$this->assertEquals('2.62', $sut->durationDecimal($record));
|
||||
|
||||
// test extended format
|
||||
$sut = $this->getSut($this->localeDe, 'de');
|
||||
$sut = $this->getSut('de', $this->localeDe);
|
||||
$this->assertEquals('2,62', $sut->durationDecimal($record->getDuration()));
|
||||
|
||||
// test negative duration
|
||||
$sut = $this->getSut($this->localeEn, 'en');
|
||||
$sut = $this->getSut('en', $this->localeEn);
|
||||
$this->assertEquals('-0.00', $sut->durationDecimal(-1));
|
||||
|
||||
// test negative duration
|
||||
$sut = $this->getSut($this->localeEn, 'en');
|
||||
$sut = $this->getSut('en', $this->localeEn);
|
||||
$this->assertEquals('-0.01', $sut->durationDecimal(-40));
|
||||
$this->assertEquals('-0.01', $sut->durationDecimal(-50));
|
||||
|
||||
// test negative duration - with rounding issue
|
||||
$sut = $this->getSut($this->localeEn, 'en');
|
||||
$sut = $this->getSut('en', $this->localeEn);
|
||||
$this->assertEquals('-0.02', $sut->durationDecimal(-60));
|
||||
|
||||
// test zero duration
|
||||
$sut = $this->getSut($this->localeEn, 'en');
|
||||
$sut = $this->getSut('en', $this->localeEn);
|
||||
$this->assertEquals('0.00', $sut->durationDecimal(-0));
|
||||
$this->assertEquals('0.00', $sut->durationDecimal(0));
|
||||
|
||||
$sut = $this->getSut($this->localeEn, 'en');
|
||||
$sut = $this->getSut('en', $this->localeEn);
|
||||
$this->assertEquals('0.00', $sut->durationDecimal(-0));
|
||||
|
||||
$sut = $this->getSut($this->localeEn, 'en');
|
||||
$sut = $this->getSut('en', $this->localeEn);
|
||||
|
||||
$this->assertEquals('0.00', $sut->durationDecimal(null));
|
||||
}
|
||||
|
||||
@@ -1567,51 +1567,11 @@ parameters:
|
||||
count: 1
|
||||
path: Configuration/LdapConfigurationTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Configuration\\\\LocaleServiceTest\\:\\:getDefaultSettings\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: Configuration/LocaleServiceTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Configuration\\\\LocaleServiceTest\\:\\:getSut\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: Configuration/LocaleServiceTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Configuration\\\\LocaleServiceTest\\:\\:getSut\\(\\) has parameter \\$settings with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
path: Configuration/LocaleServiceTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Configuration\\\\LocaleServiceTest\\:\\:testGetAllLocales\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: Configuration/LocaleServiceTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Configuration\\\\LocaleServiceTest\\:\\:testGetDateFormat\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: Configuration/LocaleServiceTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Configuration\\\\LocaleServiceTest\\:\\:testGetDateTimeFormat\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: Configuration/LocaleServiceTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Configuration\\\\LocaleServiceTest\\:\\:testGetDurationFormat\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: Configuration/LocaleServiceTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Configuration\\\\LocaleServiceTest\\:\\:testGetTimeFormat\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: Configuration/LocaleServiceTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Configuration\\\\LocaleServiceTest\\:\\:testInvalidLocaleWithGivenLocale\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: Configuration/LocaleServiceTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Configuration\\\\MailConfigurationTest\\:\\:testGetFromAddress\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
@@ -4527,11 +4487,6 @@ parameters:
|
||||
count: 1
|
||||
path: EventSubscriber/ProfileSubscriberTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\EventSubscriber\\\\RedirectToLocaleSubscriberTest\\:\\:testConstruct\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: EventSubscriber/RedirectToLocaleSubscriberTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\EventSubscriber\\\\UserDetailsSubscriberTest\\:\\:testGetSubscribedEvents\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
@@ -8157,56 +8112,11 @@ parameters:
|
||||
count: 1
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Twig\\\\LocaleFormatExtensionsTest\\:\\:getSut\\(\\) has parameter \\$dateSettings with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Twig\\\\LocaleFormatExtensionsTest\\:\\:getSut\\(\\) has parameter \\$locale with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Twig\\\\LocaleFormatExtensionsTest\\:\\:getTimesheet\\(\\) has parameter \\$seconds with no type specified\\.$#"
|
||||
count: 1
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Twig\\\\LocaleFormatExtensionsTest\\:\\:testAmount\\(\\) has parameter \\$amount with no type specified\\.$#"
|
||||
count: 1
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Twig\\\\LocaleFormatExtensionsTest\\:\\:testAmount\\(\\) has parameter \\$locale with no type specified\\.$#"
|
||||
count: 1
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Twig\\\\LocaleFormatExtensionsTest\\:\\:testAmount\\(\\) has parameter \\$result with no type specified\\.$#"
|
||||
count: 1
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Twig\\\\LocaleFormatExtensionsTest\\:\\:testMoney62_1\\(\\) has parameter \\$amount with no type specified\\.$#"
|
||||
count: 1
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Twig\\\\LocaleFormatExtensionsTest\\:\\:testMoney62_1\\(\\) has parameter \\$currency with no type specified\\.$#"
|
||||
count: 1
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Twig\\\\LocaleFormatExtensionsTest\\:\\:testMoney62_1\\(\\) has parameter \\$locale with no type specified\\.$#"
|
||||
count: 1
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Twig\\\\LocaleFormatExtensionsTest\\:\\:testMoney62_1\\(\\) has parameter \\$result with no type specified\\.$#"
|
||||
count: 1
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Twig\\\\LocaleFormatExtensionsTest\\:\\:testMoneyNoCurrency\\(\\) has parameter \\$amount with no type specified\\.$#"
|
||||
count: 1
|
||||
@@ -8232,16 +8142,6 @@ parameters:
|
||||
count: 5
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$languageSettings of class App\\\\Configuration\\\\LocaleService constructor expects array, array\\|string given\\.$#"
|
||||
count: 1
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$locale of method App\\\\Twig\\\\LocaleFormatExtensions\\:\\:setLocale\\(\\) expects string, array\\|string given\\.$#"
|
||||
count: 1
|
||||
path: Twig/LocaleFormatExtensionsTest.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$timezoneId of function date_default_timezone_set expects string, string\\|null given\\.$#"
|
||||
count: 1
|
||||
|
||||
Reference in New Issue
Block a user