From 9c2a26db12d6f5a488c4e22e2cb134e4039d30d5 Mon Sep 17 00:00:00 2001 From: stealth35 Date: Wed, 9 Nov 2011 10:13:06 +0100 Subject: [PATCH] [Translation] add Mo loader tests --- .../Translation/Loader/MoFileLoaderTest.php | 40 ++++++++++++++++++ .../Component/Translation/fixtures/empty.mo | 0 .../Translation/fixtures/resources.mo | Bin 0 -> 52 bytes 3 files changed, 40 insertions(+) create mode 100644 tests/Symfony/Tests/Component/Translation/Loader/MoFileLoaderTest.php create mode 100644 tests/Symfony/Tests/Component/Translation/fixtures/empty.mo create mode 100644 tests/Symfony/Tests/Component/Translation/fixtures/resources.mo diff --git a/tests/Symfony/Tests/Component/Translation/Loader/MoFileLoaderTest.php b/tests/Symfony/Tests/Component/Translation/Loader/MoFileLoaderTest.php new file mode 100644 index 0000000000000..cb1579f3db5b9 --- /dev/null +++ b/tests/Symfony/Tests/Component/Translation/Loader/MoFileLoaderTest.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Component\Translation\Loader; + +use Symfony\Component\Translation\Loader\MoFileLoader; +use Symfony\Component\Config\Resource\FileResource; + +class MoFileLoaderTest extends \PHPUnit_Framework_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 testLoadDoesNothingIfEmpty() + { + $loader = new MoFileLoader(); + $resource = __DIR__.'/../fixtures/empty.mo'; + $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()); + } +} diff --git a/tests/Symfony/Tests/Component/Translation/fixtures/empty.mo b/tests/Symfony/Tests/Component/Translation/fixtures/empty.mo new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/tests/Symfony/Tests/Component/Translation/fixtures/resources.mo b/tests/Symfony/Tests/Component/Translation/fixtures/resources.mo new file mode 100644 index 0000000000000000000000000000000000000000..0a9660257c07afef243a011d9806d6217e4f1379 GIT binary patch literal 52 pcmca7#4?ou2pEA_28dNa93apEVrC%Lh0=yVnjtMepCKu+2mox%1k?Zk literal 0 HcmV?d00001