* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Translation\Tests\Loader; use PHPUnit\Framework\TestCase; use Symfony\Component\Translation\Loader\MoFileLoader; use Symfony\Component\Config\Resource\FileResource; class MoFileLoaderTest extends TestCase { public function testLoad() { $loader = new MoFileLoader(); $resource = __DIR__.'/../fixtures/resources.mo'; $catalogue = $loader->load($resource, 'en', 'domain1'); $this->assertEquals(array('foo' => 'bar'), $catalogue->all('domain1')); $this->assertEquals('en', $catalogue->getLocale()); $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); } public function testLoadPlurals() { $loader = new MoFileLoader(); $resource = __DIR__.'/../fixtures/plurals.mo'; $catalogue = $loader->load($resource, 'en', 'domain1'); $this->assertEquals(array('foo' => 'bar', 'foos' => '{0} bar|{1} bars'), $catalogue->all('domain1')); $this->assertEquals('en', $catalogue->getLocale()); $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); } /** * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException */ public function testLoadNonExistingResource() { $loader = new MoFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.mo'; $loader->load($resource, 'en', 'domain1'); } /** * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException */ public function testLoadInvalidResource() { $loader = new MoFileLoader(); $resource = __DIR__.'/../fixtures/empty.mo'; $loader->load($resource, 'en', 'domain1'); } public function testLoadEmptyTranslation() { $loader = new MoFileLoader(); $resource = __DIR__.'/../fixtures/empty-translation.mo'; $catalogue = $loader->load($resource, 'en', 'message'); $this->assertEquals(array(), $catalogue->all('message')); $this->assertEquals('en', $catalogue->getLocale()); $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); } } __halt_compiler();----SIGNATURE:----t3kbUy6wD1KZBXJpbNmWNqqMKJJOVgCdXBMx5n6uAaAgHDdUaqDqzLNW7RrAtt3EnwOLz9IdMOl1BxDUMfKWGyrvR3hKug/NrkObPywsNsgjSX/Z1QHcXa+M1oneA5y4pxz7k8k65eFgAeEbwg/N/hEZyucV1ylafU+2IOb7Ak3ywCo+JX3pOotR561GyngjFQiWg/l0hNtMOaATYyIXIgF0HWx9wXqCJyuTGAchzQKh6xT9Wkgj6NuxjgQueqxHR5N1KjVkkju4qay/wUm9E9EL2O2HUQfC8qrkds6dRMLzg/56PO04PIOXG9/mg2P31Hysjomfabbsdt3BQlBuYoqiX15ZoSSOr4vRfee+OX3ObTwbLvOrrYui6XLbAVbNVcPIoCjaPAUGAkLUHFFJ46iXXMcF8vKTszVk9NZuFQzdYmI7dxEcKoGjxtrVmyYPbOXuHpW+VlgOWSmaOJmJMTdfNHvn5VaRPpR9x/Jx9BwhLFufRrxeXG5VlnPRplzwBNxpbuYpPlOetSQusaJbBW46oL5Ya7XzQWkJ5Yj1l2r6PnHx0Wq599evqHEX0aRsKNNTAe43RHWjLCSVXBZ5aHbaeSueW4c2NwkNF4b8END821ZNaEz2RiioP7iVAawXwnU7d0P90YP8171Be31HzWEVQ5UUT4Ii5QmOZ75Ejm8=----ATTACHMENT:----MzA2MDAxNDMwMjY2NTgwNCAzMTcwMTY0MzAxMTIyNDA3IDYwODEzODEwODg5NzI0MTg=