|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Tests\Component\Translation\Loader; |
| 13 | + |
| 14 | +use Symfony\Component\Translation\Loader\MoFileLoader; |
| 15 | +use Symfony\Component\Config\Resource\FileResource; |
| 16 | + |
| 17 | +class MoFileLoaderTest extends \PHPUnit_Framework_TestCase |
| 18 | +{ |
| 19 | + public function testLoad() |
| 20 | + { |
| 21 | + $loader = new MoFileLoader(); |
| 22 | + $resource = __DIR__.'/../fixtures/resources.mo'; |
| 23 | + $catalogue = $loader->load($resource, 'en', 'domain1'); |
| 24 | + |
| 25 | + $this->assertEquals(array('foo' => 'bar'), $catalogue->all('domain1')); |
| 26 | + $this->assertEquals('en', $catalogue->getLocale()); |
| 27 | + $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); |
| 28 | + } |
| 29 | + |
| 30 | + public function testLoadDoesNothingIfEmpty() |
| 31 | + { |
| 32 | + $loader = new MoFileLoader(); |
| 33 | + $resource = __DIR__.'/../fixtures/empty.mo'; |
| 34 | + $catalogue = $loader->load($resource, 'en', 'domain1'); |
| 35 | + |
| 36 | + $this->assertEquals(array(), $catalogue->all('domain1')); |
| 37 | + $this->assertEquals('en', $catalogue->getLocale()); |
| 38 | + $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); |
| 39 | + } |
| 40 | +} |
0 commit comments