// no assertion. this method just asserts that no exception is thrown
$this->addToAssertionCount(1);
}
public function getTransFileTests()
{
return array(
array('csv', 'CsvFileLoader'),
array('ini', 'IniFileLoader'),
array('mo', 'MoFileLoader'),
array('po', 'PoFileLoader'),
array('php', 'PhpFileLoader'),
array('ts', 'QtFileLoader'),
array('xlf', 'XliffFileLoader'),
array('yml', 'YamlFileLoader'),
array('json', 'JsonFileLoader'),
);
}
public function getTransTests()
{
return array(
array('Symfony est super !', 'Symfony is great!', 'Symfony est super !', array(), 'fr', ''),
array('Symfony est awesome !', 'Symfony is %what%!', 'Symfony est %what% !', array('%what%' => 'awesome'), 'fr', ''),
array('Symfony est super !', new StringClass('Symfony is great!'), 'Symfony est super !', array(), 'fr', ''),
);
}
public function getFlattenedTransTests()
{
$messages = array(
'symfony' => array(
'is' => array(
'great' => 'Symfony est super!',
),
),
'foo' => array(
'bar' => array(
'baz' => 'Foo Bar Baz',
),
'baz' => 'Foo Baz',
),
);
return array(
array('Symfony est super!', $messages, 'symfony.is.great'),
array('Foo Bar Baz', $messages, 'foo.bar.baz'),
array('Foo Baz', $messages, 'foo.baz'),
);
}
public function getTransChoiceTests()
{
return array(
array('Il y a 0 pomme', '{0} There are no appless|{1} There is one apple|]1,Inf] There is %count% apples', '[0,1] Il y a %count% pomme|]1,Inf] Il y a %count% pommes', 0, array(), 'fr', ''),
array('Il y a 1 pomme', '{0} There are no appless|{1} There is one apple|]1,Inf] There is %count% apples', '[0,1] Il y a %count% pomme|]1,Inf] Il y a %count% pommes', 1, array(), 'fr', ''),
array('Il y a 10 pommes', '{0} There are no appless|{1} There is one apple|]1,Inf] There is %count% apples', '[0,1] Il y a %count% pomme|]1,Inf] Il y a %count% pommes', 10, array(), 'fr', ''),
array('Il y a 0 pomme', 'There is one apple|There is %count% apples', 'Il y a %count% pomme|Il y a %count% pommes', 0, array(), 'fr', ''),
array('Il y a 1 pomme', 'There is one apple|There is %count% apples', 'Il y a %count% pomme|Il y a %count% pommes', 1, array(), 'fr', ''),
array('Il y a 10 pommes', 'There is one apple|There is %count% apples', 'Il y a %count% pomme|Il y a %count% pommes', 10, array(), 'fr', ''),
array('Il y a 0 pomme', 'one: There is one apple|more: There is %count% apples', 'one: Il y a %count% pomme|more: Il y a %count% pommes', 0, array(), 'fr', ''),
array('Il y a 1 pomme', 'one: There is one apple|more: There is %count% apples', 'one: Il y a %count% pomme|more: Il y a %count% pommes', 1, array(), 'fr', ''),
array('Il y a 10 pommes', 'one: There is one apple|more: There is %count% apples', 'one: Il y a %count% pomme|more: Il y a %count% pommes', 10, array(), 'fr', ''),
array('Il n\'y a aucune pomme', '{0} There are no apples|one: There is one apple|more: There is %count% apples', '{0} Il n\'y a aucune pomme|one: Il y a %count% pomme|more: Il y a %count% pommes', 0, array(), 'fr', ''),
array('Il y a 1 pomme', '{0} There are no apples|one: There is one apple|more: There is %count% apples', '{0} Il n\'y a aucune pomme|one: Il y a %count% pomme|more: Il y a %count% pommes', 1, array(), 'fr', ''),
array('Il y a 10 pommes', '{0} There are no apples|one: There is one apple|more: There is %count% apples', '{0} Il n\'y a aucune pomme|one: Il y a %count% pomme|more: Il y a %count% pommes', 10, array(), 'fr', ''),
array('Il y a 0 pomme', new StringClass('{0} There are no appless|{1} There is one apple|]1,Inf] There is %count% apples'), '[0,1] Il y a %count% pomme|]1,Inf] Il y a %count% pommes', 0, array(), 'fr', ''),
// Override %count% with a custom value
array('Il y a quelques pommes', 'one: There is one apple|more: There are %count% apples', 'one: Il y a %count% pomme|more: Il y a %count% pommes', 2, array('%count%' => 'quelques'), 'fr', ''),
);
}
public function getInvalidLocalesTests()
{
return array(
array('fr FR'),
array('français'),
array('fr+en'),
array('utf#8'),
array('fr&en'),
array('fr~FR'),
array(' fr'),
array('fr '),
array('fr*'),
array('fr/FR'),
array('fr\\FR'),
);
}
public function getValidLocalesTests()
{
return array(
array(''),
array(null),
array('fr'),
array('francais'),
array('FR'),
array('frFR'),
array('fr-FR'),
array('fr_FR'),
array('fr.FR'),
array('fr-FR.UTF8'),
array('sr@latin'),
);
}
public function testTransChoiceFallback()
{
$translator = new Translator('ru');
$translator->setFallbackLocales(array('en'));
$translator->addLoader('array', new ArrayLoader());