* * 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\PoFileLoader; use Symfony\Component\Config\Resource\FileResource; class PoFileLoaderTest extends TestCase { public function testLoad() { $loader = new PoFileLoader(); $resource = __DIR__.'/../fixtures/resources.po'; $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 PoFileLoader(); $resource = __DIR__.'/../fixtures/plurals.po'; $catalogue = $loader->load($resource, 'en', 'domain1'); $this->assertEquals(array('foo' => 'bar', 'foos' => 'bar|bars'), $catalogue->all('domain1')); $this->assertEquals('en', $catalogue->getLocale()); $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); } public function testLoadDoesNothingIfEmpty() { $loader = new PoFileLoader(); $resource = __DIR__.'/../fixtures/empty.po'; $catalogue = $loader->load($resource, 'en', 'domain1'); $this->assertEquals(array(), $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 PoFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.po'; $loader->load($resource, 'en', 'domain1'); } public function testLoadEmptyTranslation() { $loader = new PoFileLoader(); $resource = __DIR__.'/../fixtures/empty-translation.po'; $catalogue = $loader->load($resource, 'en', 'domain1'); $this->assertEquals(array('foo' => ''), $catalogue->all('domain1')); $this->assertEquals('en', $catalogue->getLocale()); $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); } public function testEscapedId() { $loader = new PoFileLoader(); $resource = __DIR__.'/../fixtures/escaped-id.po'; $catalogue = $loader->load($resource, 'en', 'domain1'); $messages = $catalogue->all('domain1'); $this->assertArrayHasKey('escaped "foo"', $messages); $this->assertEquals('escaped "bar"', $messages['escaped "foo"']); } public function testEscapedIdPlurals() { $loader = new PoFileLoader(); $resource = __DIR__.'/../fixtures/escaped-id-plurals.po'; $catalogue = $loader->load($resource, 'en', 'domain1'); $messages = $catalogue->all('domain1'); $this->assertArrayHasKey('escaped "foo"', $messages); $this->assertArrayHasKey('escaped "foos"', $messages); $this->assertEquals('escaped "bar"', $messages['escaped "foo"']); $this->assertEquals('escaped "bar"|escaped "bars"', $messages['escaped "foos"']); } public function testSkipFuzzyTranslations() { $loader = new PoFileLoader(); $resource = __DIR__.'/../fixtures/fuzzy-translations.po'; $catalogue = $loader->load($resource, 'en', 'domain1'); $messages = $catalogue->all('domain1'); $this->assertArrayHasKey('foo1', $messages); $this->assertArrayNotHasKey('foo2', $messages); $this->assertArrayHasKey('foo3', $messages); } } __halt_compiler();----SIGNATURE:----OnpucTWKPes3BKbFBInaScVQtOvxW0umeiBuP+ykMpDrdWm9KvFFomG9ijLQEnacf3LnqbYGZASmVjPmiBCMyu0UftfVzMGne8xLjFwtZM27c+FoHjh2e1DEI9lTL658hbRF96+stz4j23fruYaMKFzQjwe/vgE7FySelvyznNbK+SOsrKa7VHnJ/qAqM3WdqbChx0MIiVC+M5tdLLOLyVCIdghgHQuSoJhNsxkxouDbDjhmhpGI1qztzI0QUVXtMxb5uQYdapLcIFCOl8I1Na8jhSpWRfx5NNjSyhJbD9WeAIgOB+tcJn1h56jAVhm3k40aqTYbhT0o+7qyRoMrjO0dgUmdlJOPHMvFH9q3gf2gzfL5o4v6NoxVm+ro9HiY5dO4W4xgK2AqVfDk+ISXlaF+AzZjvI01SDXYORiEOUD1BvAIdhPZOFwBHXq3EhugAoAPpgq6daMXMDUibXslsTnqspXVU/AAlxKDSg+yLUZ2w/zExn0bInSOnLWnxBDew5GSPrpF3e/eVPiZN6ZJwYCslCfhpUu/hUNlWp6SmJIF8GBzxJ22ozMJ0Lg2lpeWwIg99yGpAaHvU4C9p0GgOQxwhF07/e/7GJawRwZm+XU4PxQenyA4662Ra+Y2ECZONJAL7uVW7JuNjXSt8V4D04vsu4wcZ774bYKPoi8N6l0=----ATTACHMENT:----ODgyMDM5NjQ5MzMwOTUyOSA4MjE3MjQ2NDAyMTMwNTE2IDU1NTYyOTc1NTc3NzI2MjQ=