Added a ConcreteDumper
This commit is contained in:
parent
84f09024b4
commit
623d149cad
@ -1,38 +0,0 @@
|
|||||||
<?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\Dumper;
|
|
||||||
|
|
||||||
use Symfony\Component\Translation\MessageCatalogue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Null file dumper used for testing purposes.
|
|
||||||
*
|
|
||||||
* @author Florian Voutzinos <florian@voutzinos.com>
|
|
||||||
*/
|
|
||||||
class NullFileDumper extends FileDumper
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function format(MessageCatalogue $messages, $domain)
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function getExtension()
|
|
||||||
{
|
|
||||||
return 'null';
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,15 +11,15 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Translation\Tests\Dumper;
|
namespace Symfony\Component\Translation\Tests\Dumper;
|
||||||
|
|
||||||
use Symfony\Component\Translation\Dumper\NullFileDumper;
|
|
||||||
use Symfony\Component\Translation\MessageCatalogue;
|
use Symfony\Component\Translation\MessageCatalogue;
|
||||||
|
use Symfony\Component\Translation\Dumper\FileDumper;
|
||||||
|
|
||||||
class NullFileDumperTest extends \PHPUnit_Framework_TestCase
|
class FileDumperTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testDumpBackupsFileIfExisting()
|
public function testDumpBackupsFileIfExisting()
|
||||||
{
|
{
|
||||||
$tempDir = sys_get_temp_dir();
|
$tempDir = sys_get_temp_dir();
|
||||||
$file = $tempDir.'/messages.en.null';
|
$file = $tempDir.'/messages.en.concrete';
|
||||||
$backupFile = $file.'~';
|
$backupFile = $file.'~';
|
||||||
|
|
||||||
@touch($file);
|
@touch($file);
|
||||||
@ -27,7 +27,7 @@ class NullFileDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
$catalogue = new MessageCatalogue('en');
|
$catalogue = new MessageCatalogue('en');
|
||||||
$catalogue->add(array('foo' => 'bar'));
|
$catalogue->add(array('foo' => 'bar'));
|
||||||
|
|
||||||
$dumper = new NullFileDumper();
|
$dumper = new ConcreteFileDumper();
|
||||||
$dumper->dump($catalogue, array('path' => $tempDir));
|
$dumper->dump($catalogue, array('path' => $tempDir));
|
||||||
|
|
||||||
$this->assertTrue(file_exists($backupFile));
|
$this->assertTrue(file_exists($backupFile));
|
||||||
@ -40,12 +40,12 @@ class NullFileDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$tempDir = sys_get_temp_dir();
|
$tempDir = sys_get_temp_dir();
|
||||||
$translationsDir = $tempDir.'/test/translations';
|
$translationsDir = $tempDir.'/test/translations';
|
||||||
$file = $translationsDir.'/messages.en.null';
|
$file = $translationsDir.'/messages.en.concrete';
|
||||||
|
|
||||||
$catalogue = new MessageCatalogue('en');
|
$catalogue = new MessageCatalogue('en');
|
||||||
$catalogue->add(array('foo' => 'bar'));
|
$catalogue->add(array('foo' => 'bar'));
|
||||||
|
|
||||||
$dumper = new NullFileDumper();
|
$dumper = new ConcreteFileDumper();
|
||||||
$dumper->setRelativePathTemplate('test/translations/{domain}.{locale}.{extension}');
|
$dumper->setRelativePathTemplate('test/translations/{domain}.{locale}.{extension}');
|
||||||
$dumper->dump($catalogue, array('path' => $tempDir));
|
$dumper->dump($catalogue, array('path' => $tempDir));
|
||||||
|
|
||||||
@ -55,3 +55,16 @@ class NullFileDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
@rmdir($translationsDir);
|
@rmdir($translationsDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ConcreteFileDumper extends FileDumper
|
||||||
|
{
|
||||||
|
protected function format(MessageCatalogue $messages, $domain)
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getExtension()
|
||||||
|
{
|
||||||
|
return 'concrete';
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user