* * 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:----HPf7IXuRo9/ZM596pPceHkE2IpLbmMfjEzRIqJFkLCPtvQjIY9x4UCLKeeQsY/Spm9H7jmMxsIiY/gz7KjdvcpUBGSUgSP3QwMRuldGauTS2W+hMk/BLK9QN1MW/2irQtvyRy+FA/a6sN+ilqQtM7aGSMCDvJn+Jfyi2OcRy7u3eSRjPni5jrodroUZSt+S+iHYXu15Ipx2EgzUCfB1KkI6tn5SI8UijiSnUWKvVYXxj33mPf9ncrcxuZu941Y/NPRoSXwDgMk0JOHnwYg8BHpXtrRcNviHn7EkxwIL2GRdtUx758nelr3UhTdHFgQuSV10YnVp93gOUgWtqggM7O1I66OAZZbM0IM6iD966qYVjeuq3IswXxKg9ur6sNB6sKjP1sbBI6+5MGDEDUvZgw0g6AviJUbT42vJpRfW0v1o/99xR31JZkc4i3AZhvBOyH0tQzrSasv52Wnuz8CJUJ974H5nLWRk8PhYQsjOL4lTh80HQgRsl3vrp7rQh9+miW5+h1xnhlyYN7R9tq8NPG/zNXuCsozxNkGPI/pMF9J/iocckyGSH0yNA2aMsMIm+ZBz6MHQ3+g0hcPMv2jopwvvr4CfxAeIj3bHqRCi+DtztapGnaFDSdQFfS900QaqYXAISOnN7ydDeQBo//GC9wBYCO7KYfKpfr7ClmGyFPo4=----ATTACHMENT:----NDQ0NjExMzQ2MjgyNjM2OSA5NDg3ODAyMDQ4NjM0MDAzIDEwMTYyOTI5MTkxNzI4MDI=