Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+6 -79
View File
@@ -11,102 +11,29 @@
namespace Symfony\Component\Translation\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Intl\Util\IntlTestHelper;
use Symfony\Component\Translation\IdentityTranslator;
use Symfony\Contracts\Translation\Test\TranslatorTest;
class IdentityTranslatorTest extends TestCase
class IdentityTranslatorTest extends TranslatorTest
{
private $defaultLocale;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->defaultLocale = \Locale::getDefault();
}
protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
\Locale::setDefault($this->defaultLocale);
}
/**
* @dataProvider getTransTests
*/
public function testTrans($expected, $id, $parameters)
public function getTranslator()
{
$translator = new IdentityTranslator();
$this->assertEquals($expected, $translator->trans($id, $parameters));
}
/**
* @dataProvider getTransChoiceTests
*/
public function testTransChoiceWithExplicitLocale($expected, $id, $number, $parameters)
{
$translator = new IdentityTranslator();
$translator->setLocale('en');
$this->assertEquals($expected, $translator->transChoice($id, $number, $parameters));
}
/**
* @dataProvider getTransChoiceTests
*/
public function testTransChoiceWithDefaultLocale($expected, $id, $number, $parameters)
{
\Locale::setDefault('en');
$translator = new IdentityTranslator();
$this->assertEquals($expected, $translator->transChoice($id, $number, $parameters));
}
public function testGetSetLocale()
{
$translator = new IdentityTranslator();
$translator->setLocale('en');
$this->assertEquals('en', $translator->getLocale());
}
public function testGetLocaleReturnsDefaultLocaleIfNotSet()
{
// in order to test with "pt_BR"
IntlTestHelper::requireFullIntl($this, false);
$translator = new IdentityTranslator();
\Locale::setDefault('en');
$this->assertEquals('en', $translator->getLocale());
\Locale::setDefault('pt_BR');
$this->assertEquals('pt_BR', $translator->getLocale());
}
public function getTransTests()
{
return [
['Symfony is great!', 'Symfony is great!', []],
['Symfony is awesome!', 'Symfony is %what%!', ['%what%' => 'awesome']],
];
}
public function getTransChoiceTests()
{
return [
['There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0, ['%count%' => 0]],
['There is one apple', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 1, ['%count%' => 1]],
['There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 10, ['%count%' => 10]],
['There are 0 apples', 'There is 1 apple|There are %count% apples', 0, ['%count%' => 0]],
['There is 1 apple', 'There is 1 apple|There are %count% apples', 1, ['%count%' => 1]],
['There are 10 apples', 'There is 1 apple|There are %count% apples', 10, ['%count%' => 10]],
// custom validation messages may be coded with a fixed value
['There are 2 apples', 'There are 2 apples', 2, ['%count%' => 2]],
];
return new IdentityTranslator();
}
}