You are here

public function TranslatorTest::testLegacyGetMessages in Plug 7

@group legacy @dataProvider dataProviderGetMessages

File

lib/Symfony/translation/Tests/TranslatorTest.php, line 503

Class

TranslatorTest

Namespace

Symfony\Component\Translation\Tests

Code

public function testLegacyGetMessages($resources, $locale, $expected) {
  $locales = array_keys($resources);
  $_locale = !is_null($locale) ? $locale : reset($locales);
  $locales = array_slice($locales, 0, array_search($_locale, $locales));
  $translator = new Translator($_locale, new MessageSelector());
  $translator
    ->setFallbackLocales(array_reverse($locales));
  $translator
    ->addLoader('array', new ArrayLoader());
  foreach ($resources as $_locale => $domainMessages) {
    foreach ($domainMessages as $domain => $messages) {
      $translator
        ->addResource('array', $messages, $_locale, $domain);
    }
  }
  $result = $translator
    ->getMessages($locale);
  $this
    ->assertEquals($expected, $result);
}