8000 [Translation] add Mo loader tests · symfony/symfony@9c2a26d · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c2a26d

Browse files
committed
[Translation] add Mo loader tests
1 parent 9af2342 commit 9c2a26d

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
}

tests/Symfony/Tests/Component/Translation/fixtures/empty.mo

Whitespace-only changes.
Binary file not shown.

0 commit comments

Comments
 (0)
0