mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-02 21:19:58 +09:00
Update to laravel 7
This commit is contained in:
@@ -30,6 +30,22 @@ use Symfony\Contracts\Translation\TranslatorTrait;
|
||||
*/
|
||||
class TranslatorTest extends TestCase
|
||||
{
|
||||
private $defaultLocale;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->defaultLocale = \Locale::getDefault();
|
||||
\Locale::setDefault('en');
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
\Locale::setDefault($this->defaultLocale);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TranslatorInterface
|
||||
*/
|
||||
public function getTranslator()
|
||||
{
|
||||
return new class() implements TranslatorInterface {
|
||||
@@ -53,7 +69,18 @@ class TranslatorTest extends TestCase
|
||||
public function testTransChoiceWithExplicitLocale($expected, $id, $number)
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
$translator->setLocale('en');
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($id, ['%count%' => $number]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension intl
|
||||
*
|
||||
* @dataProvider getTransChoiceTests
|
||||
*/
|
||||
public function testTransChoiceWithDefaultLocale($expected, $id, $number)
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($id, ['%count%' => $number]));
|
||||
}
|
||||
@@ -61,11 +88,10 @@ class TranslatorTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getTransChoiceTests
|
||||
*/
|
||||
public function testTransChoiceWithDefaultLocale($expected, $id, $number)
|
||||
public function testTransChoiceWithEnUsPosix($expected, $id, $number)
|
||||
{
|
||||
\Locale::setDefault('en');
|
||||
|
||||
$translator = $this->getTranslator();
|
||||
$translator->setLocale('en_US_POSIX');
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($id, ['%count%' => $number]));
|
||||
}
|
||||
@@ -73,7 +99,6 @@ class TranslatorTest extends TestCase
|
||||
public function testGetSetLocale()
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
$translator->setLocale('en');
|
||||
|
||||
$this->assertEquals('en', $translator->getLocale());
|
||||
}
|
||||
@@ -142,11 +167,11 @@ class TranslatorTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getChooseTests
|
||||
*/
|
||||
public function testChoose($expected, $id, $number)
|
||||
public function testChoose($expected, $id, $number, $locale = null)
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($id, ['%count%' => $number]));
|
||||
$this->assertEquals($expected, $translator->trans($id, ['%count%' => $number], null, $locale));
|
||||
}
|
||||
|
||||
public function testReturnMessageIfExactlyOneStandardRuleIsGiven()
|
||||
@@ -158,10 +183,10 @@ class TranslatorTest extends TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider getNonMatchingMessages
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testThrowExceptionIfMatchingMessageCannotBeFound($id, $number)
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$translator->trans($id, ['%count%' => $number]);
|
||||
@@ -255,6 +280,18 @@ class TranslatorTest extends TestCase
|
||||
['', '|', 1],
|
||||
// Empty plural set (3 plural forms) from a .PO file
|
||||
['', '||', 1],
|
||||
|
||||
// Floating values
|
||||
['1.5 liters', '%count% liter|%count% liters', 1.5],
|
||||
['1.5 litre', '%count% litre|%count% litres', 1.5, 'fr'],
|
||||
|
||||
// Negative values
|
||||
['-1 degree', '%count% degree|%count% degrees', -1],
|
||||
['-1 degré', '%count% degré|%count% degrés', -1],
|
||||
['-1.5 degrees', '%count% degree|%count% degrees', -1.5],
|
||||
['-1.5 degré', '%count% degré|%count% degrés', -1.5, 'fr'],
|
||||
['-2 degrees', '%count% degree|%count% degrees', -2],
|
||||
['-2 degrés', '%count% degré|%count% degrés', -2],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -287,7 +324,7 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
return [
|
||||
['1', ['ay', 'bo', 'cgg', 'dz', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky']],
|
||||
['2', ['nl', 'fr', 'en', 'de', 'de_GE', 'hy', 'hy_AM']],
|
||||
['2', ['nl', 'fr', 'en', 'de', 'de_GE', 'hy', 'hy_AM', 'en_US_POSIX']],
|
||||
['3', ['be', 'bs', 'cs', 'hr']],
|
||||
['4', ['cy', 'mt', 'sl']],
|
||||
['6', ['ar']],
|
||||
|
||||
Reference in New Issue
Block a user