* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Translation\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Translation\IdentityTranslator; class IdentityTranslatorTest extends TestCase { /** * @dataProvider getTransTests */ public function testTrans($expected, $id, $parameters) { $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 array( array('Symfony is great!', 'Symfony is great!', array()), array('Symfony is awesome!', 'Symfony is %what%!', array('%what%' => 'awesome')), ); } public function getTransChoiceTests() { return array( array('There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0, array('%count%' => 0)), array('There is one apple', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 1, array('%count%' => 1)), array('There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 10, array('%count%' => 10)), array('There are 0 apples', 'There is 1 apple|There are %count% apples', 0, array('%count%' => 0)), array('There is 1 apple', 'There is 1 apple|There are %count% apples', 1, array('%count%' => 1)), array('There are 10 apples', 'There is 1 apple|There are %count% apples', 10, array('%count%' => 10)), // custom validation messages may be coded with a fixed value array('There are 2 apples', 'There are 2 apples', 2, array('%count%' => 2)), ); } } __halt_compiler();----SIGNATURE:----qML82BZxvw61s9h2Ifuh2dXm6GMmYNgfimEc64hfrOKyhO9IJeLpu7UhfUqxekPG68S1e9pLaDhca/NxhF5y7zmLWDHLhl2ZytiXpiWw0mx9o5Mw4oqTNnGJbyGzP/3uFIOJnSbd94iwpiP/yzFQJIOHf4pbLNbcspyRHRGMs7gHFjgpktSlj1+Xg/15BPCbOWUcmIQMFXTzB48Cyn3corCfYimBNGS9w06zUYigiU+ALzYHHX/kPNo0uHvskfef9ZRbJB1dsJ2YiLX/Crcgpueye0uYnIsEOiGKvW8CzblG3SAfuYSNr2pd7tHW6lMh2oKfp+tda2wrv6ZTGfhD2idLfjEzDjq7ShGVDrXhjEyeqxEaMWEkJI0+Xl7gnuIVRE4/Aug9J080EwdiavQtb8hP+ADMTuWaUQrr1QR+gwkFdJlTXCo84A4VF5biVG/W3vL6mn8OOw6VNHEE9MU2s6Au7atf12Tuv2DdUNpBBwyWDVFvn8KFnNTgegJ40z2EizVPiwh7SHrG3Vf+ugANmwRcYCJPpFVdyFZXIZPOcZ7x3PpTamJzPG+n//1nsEqUpCOfrL/0JCMbsuGK4Gj49ZIFkFJ2D7QueDqfykyU1b4nSsIfLpkkROzDW8TDD8BFcW+QaAv9ydOsZV40o+JFPFZOpoYHvhao1xPXjZJCFeM=----ATTACHMENT:----ODQzNjkxNzg0NDYyMjA0MCAzMDMwMzY4MDY2MzUyMDY2IDU0NzM4MzQzNjQ4MjQxOTA=