* * 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:----ojLRp5rNWryucvKzu34dWrdMswhJ+ZJAyJxC5N1hotLrngDiuKRAITXO19QVd6Oyex//4X7UX40SLDFub1jcol2wMmmTQa3qFQ6hkhy4HrdeIFKudc5R4UXVQY2LMSJOFHIPpCkL+ntr4Bvm8wMpvVcSLg715pHjWGbQtDNOuRJecSTCQbvhzon0TwI9dBF2tZWDkvks0qnQp2mP4m4tg1Tm1YMcZkK0BnhnAF5bSuAuFeHKk6KNTC96N7qDn+o+znAqhTzzJuUTx6FnNmovcR643YIO+vh/h5wz+DPXECgW1GWBLX7FbqoT2LxUzoAibbHgvG0HqgKR/0cSvvl1t/0IkopTXIC8Y5TWP8bmmbjeKx5mn/Z02cNihJTj8JxrmSjJ0jwmDQ6pSPVM+oHPortmIk8aCM+MbMNWc4zggO6yfBW77iQqPyYGAB4Z4NpSpCoQkIcJtduPgW1tWBorxxEp3U9p1T6PTMpmQBBFVYm2kFfNPB5bo0gQhmb3qdyCpdCpv6TTGBgpZSV07FU7u1127Zhg9wwrp6w+I9YGDky6RluK36vzpybJCBBDTbJE6s7Hhh783BV5+KmUaGXgnGhlJGmeb5oegUF/ewBKNtO0dbOb/+tp011RluqyKPwVDl3VcutZvNSDqD3FNNmBnyvrlZnQ37GaHev0/WRnVRU=----ATTACHMENT:----MTY0MzAxNzg4OTMyNDI1MiAyNTQyOTE3NjQzODQzMTA5IDYzNTY1OTA5NzI2MDQ4OTE=