[Translation] add Mo loader tests
This commit is contained in:
parent
9af2342076
commit
9c2a26db12
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* 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());
|
||||
}
|
||||
}
|
BIN
tests/Symfony/Tests/Component/Translation/fixtures/resources.mo
Normal file
BIN
tests/Symfony/Tests/Component/Translation/fixtures/resources.mo
Normal file
Binary file not shown.
Reference in New Issue
Block a user