PHP 8.2.31
Preview: MoFileLoaderTest.php Size: 1.96 KB
/opt/alt/php53/usr/share/pear/test/Translation/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php

<?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\Component\Translation\Tests\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 testLoadPlurals()
    {
        $loader = new MoFileLoader();
        $resource = __DIR__.'/../fixtures/plurals.mo';
        $catalogue = $loader->load($resource, 'en', 'domain1');

        $this->assertEquals(array('foo' => 'bar', 'foos' => '{0} bar|{1} bars'), $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 MoFileLoader();
        $resource = __DIR__.'/../fixtures/non-existing.mo';
        $loader->load($resource, 'en', 'domain1');
    }

    /**
     * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
     */
    public function testLoadInvalidResource()
    {
        $loader = new MoFileLoader();
        $resource = __DIR__.'/../fixtures/empty.mo';
        $loader->load($resource, 'en', 'domain1');
    }
}

Directory Contents

Dirs: 0 × Files: 12

Name Size Perms Modified Actions
1.93 KB lrw-r--r-- 2019-12-18 11:20:43
Edit Download
2.48 KB lrw-r--r-- 2019-12-18 11:20:43
Edit Download
1.70 KB lrw-r--r-- 2019-12-18 11:20:43
Edit Download
1.63 KB lrw-r--r-- 2019-12-18 11:20:43
Edit Download
2.23 KB lrw-r--r-- 2019-12-18 11:20:43
Edit Download
537 B lrw-r--r-- 2019-12-18 11:20:43
Edit Download
1.96 KB lrw-r--r-- 2019-12-18 11:20:43
Edit Download
1.52 KB lrw-r--r-- 2019-12-18 11:20:43
Edit Download
2.52 KB lrw-r--r-- 2019-12-18 11:20:43
Edit Download
2.16 KB lrw-r--r-- 2019-12-18 11:20:43
Edit Download
3.88 KB lrw-r--r-- 2019-12-18 11:20:43
Edit Download
2.28 KB lrw-r--r-- 2019-12-18 11:20:43
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).