|
@@ -74,6 +74,18 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->assertEquals($expected, $translator->trans($id, $parameters, $domain, $locale));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @dataProvider getFlattenedTransTests
|
|
|
+ */
|
|
|
+ public function testFlattenedTrans($expected, $messages, $id)
|
|
|
+ {
|
|
|
+ $translator = new Translator('en', new MessageSelector());
|
|
|
+ $translator->addLoader('array', new ArrayLoader());
|
|
|
+ $translator->addResource('array', $messages, 'fr', '');
|
|
|
+
|
|
|
+ $this->assertEquals($expected, $translator->trans($id, array(), '', 'fr'));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @dataProvider getTransChoiceTests
|
|
|
*/
|
|
@@ -94,6 +106,29 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ public function getFlattenedTransTests()
|
|
|
+ {
|
|
|
+ $messages = array(
|
|
|
+ 'symfony2' => array(
|
|
|
+ 'is' => array(
|
|
|
+ 'great' => 'Symfony2 est super!'
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ 'foo' => array(
|
|
|
+ 'bar' => array(
|
|
|
+ 'baz' => 'Foo Bar Baz'
|
|
|
+ ),
|
|
|
+ 'baz' => 'Foo Baz',
|
|
|
+ ),
|
|
|
+ );
|
|
|
+
|
|
|
+ return array(
|
|
|
+ array('Symfony2 est super!', $messages, 'symfony2.is.great'),
|
|
|
+ array('Foo Bar Baz', $messages, 'foo.bar.baz'),
|
|
|
+ array('Foo Baz', $messages, 'foo.baz'),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
public function getTransChoiceTests()
|
|
|
{
|
|
|
return array(
|