Added a ConcreteDumper

This commit is contained in:
florianv 2014-01-25 21:22:12 +01:00
parent 84f09024b4
commit 623d149cad
2 changed files with 19 additions and 44 deletions

View File

@ -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';
}
}

View File

@ -11,15 +11,15 @@
namespace Symfony\Component\Translation\Tests\Dumper;
use Symfony\Component\Translation\Dumper\NullFileDumper;
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()
{
$tempDir = sys_get_temp_dir();
$file = $tempDir.'/messages.en.null';
$file = $tempDir.'/messages.en.concrete';
$backupFile = $file.'~';
@touch($file);
@ -27,7 +27,7 @@ class NullFileDumperTest extends \PHPUnit_Framework_TestCase
$catalogue = new MessageCatalogue('en');
$catalogue->add(array('foo' => 'bar'));
$dumper = new NullFileDumper();
$dumper = new ConcreteFileDumper();
$dumper->dump($catalogue, array('path' => $tempDir));
$this->assertTrue(file_exists($backupFile));
@ -40,12 +40,12 @@ class NullFileDumperTest extends \PHPUnit_Framework_TestCase
{
$tempDir = sys_get_temp_dir();
$translationsDir = $tempDir.'/test/translations';
$file = $translationsDir.'/messages.en.null';
$file = $translationsDir.'/messages.en.concrete';
$catalogue = new MessageCatalogue('en');
$catalogue->add(array('foo' => 'bar'));
$dumper = new NullFileDumper();
$dumper = new ConcreteFileDumper();
$dumper->setRelativePathTemplate('test/translations/{domain}.{locale}.{extension}');
$dumper->dump($catalogue, array('path' => $tempDir));
@ -55,3 +55,16 @@ class NullFileDumperTest extends \PHPUnit_Framework_TestCase
@rmdir($translationsDir);
}
}
class ConcreteFileDumper extends FileDumper
{
protected function format(MessageCatalogue $messages, $domain)
{
return '';
}
protected function getExtension()
{
return 'concrete';
}
}