feature #15786 [Translation][File dumper] allow get file content without writing in file. (aitboudad)
This PR was merged into the 2.8 branch. Discussion ---------- [Translation][File dumper] allow get file content without writing in file. | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Fixed tickets | #14881 | Tests pass? | yes | License | MIT Commits -------805acc9
fixed typo.9b877cf
[Translation][File dumper] allow get file content without writing in file.
This commit is contained in:
commit
2e718c1f31
@ -6,6 +6,7 @@ CHANGELOG
|
||||
|
||||
* deprecated FileDumper::format(), overwrite FileDumper::formatCatalogue() instead.
|
||||
* deprecated Translator::getMessages(), rely on TranslatorBagInterface::getCatalogue() instead.
|
||||
* added `FileDumper::formatCatalogue` which allows format the catalogue without dumping it into file.
|
||||
* added option `json_encoding` to JsonFileDumper
|
||||
* added options `as_tree`, `inline` to YamlFileDumper
|
||||
* added support for XLIFF 2.0.
|
||||
|
@ -36,7 +36,7 @@ class CsvFileDumper extends FileDumper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$handle = fopen('php://memory', 'rb+');
|
||||
|
||||
|
@ -97,9 +97,9 @@ abstract class FileDumper implements DumperInterface
|
||||
*
|
||||
* @return string representation
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
@trigger_error('The '.__METHOD__.' method will replace the format method in 3.0. You should overwritten it instead of overwriting format instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('The '.__METHOD__.' method will replace the format method in 3.0. You should overwrite it instead of overwriting format instead.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->format($messages, $domain);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class IcuResFileDumper extends FileDumper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$data = $indexes = $resources = '';
|
||||
|
||||
|
@ -33,7 +33,7 @@ class IniFileDumper extends FileDumper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$output = '';
|
||||
|
||||
|
@ -33,7 +33,7 @@ class JsonFileDumper extends FileDumper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
if (isset($options['json_encoding'])) {
|
||||
$flags = $options['json_encoding'];
|
||||
|
@ -34,7 +34,7 @@ class MoFileDumper extends FileDumper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$output = $sources = $targets = $sourceOffsets = $targetOffsets = '';
|
||||
$offsets = array();
|
||||
|
@ -33,7 +33,7 @@ class PhpFileDumper extends FileDumper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$output = "<?php\n\nreturn ".var_export($messages->all($domain), true).";\n";
|
||||
|
||||
|
@ -33,7 +33,7 @@ class PoFileDumper extends FileDumper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$output = 'msgid ""'."\n";
|
||||
$output .= 'msgstr ""'."\n";
|
||||
|
@ -33,7 +33,7 @@ class QtFileDumper extends FileDumper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$dom = new \DOMDocument('1.0', 'utf-8');
|
||||
$dom->formatOutput = true;
|
||||
|
@ -23,7 +23,7 @@ class XliffFileDumper extends FileDumper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$xliffVersion = '1.2';
|
||||
if (array_key_exists('xliff_version', $options)) {
|
||||
|
@ -25,7 +25,7 @@ class YamlFileDumper extends FileDumper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
if (!class_exists('Symfony\Component\Yaml\Yaml')) {
|
||||
throw new \LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.');
|
||||
|
@ -16,18 +16,14 @@ use Symfony\Component\Translation\Dumper\CsvFileDumper;
|
||||
|
||||
class CsvFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testDump()
|
||||
public function testFormatCatalogue()
|
||||
{
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
$catalogue->add(array('foo' => 'bar', 'bar' => 'foo
|
||||
foo', 'foo;foo' => 'bar'));
|
||||
|
||||
$tempDir = sys_get_temp_dir();
|
||||
$dumper = new CsvFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $tempDir));
|
||||
|
||||
$this->assertEquals(file_get_contents(__DIR__.'/../fixtures/valid.csv'), file_get_contents($tempDir.'/messages.en.csv'));
|
||||
|
||||
unlink($tempDir.'/messages.en.csv');
|
||||
$this->assertStringEqualsFile(__DIR__.'/../fixtures/valid.csv', $dumper->formatCatalogue($catalogue, 'messages'));
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,19 @@ use Symfony\Component\Translation\Dumper\FileDumper;
|
||||
|
||||
class FileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testDump()
|
||||
{
|
||||
$tempDir = sys_get_temp_dir();
|
||||
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
$catalogue->add(array('foo' => 'bar'));
|
||||
|
||||
$dumper = new ConcreteFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $tempDir));
|
||||
|
||||
$this->assertTrue(file_exists($tempDir.'/messages.en.concrete'));
|
||||
}
|
||||
|
||||
public function testDumpBackupsFileIfExisting()
|
||||
{
|
||||
$tempDir = sys_get_temp_dir();
|
||||
@ -58,7 +71,7 @@ class FileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
class ConcreteFileDumper extends FileDumper
|
||||
{
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ use Symfony\Component\Translation\Dumper\IcuResFileDumper;
|
||||
|
||||
class IcuResFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testDump()
|
||||
public function testFormatCatalogue()
|
||||
{
|
||||
if (!function_exists('mb_convert_encoding')) {
|
||||
$this->markTestSkipped('This test requires mbstring to work.');
|
||||
@ -25,14 +25,8 @@ class IcuResFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
$catalogue->add(array('foo' => 'bar'));
|
||||
|
||||
$tempDir = sys_get_temp_dir().'/IcuResFileDumperTest';
|
||||
$dumper = new IcuResFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $tempDir));
|
||||
|
||||
$this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resourcebundle/res/en.res'), file_get_contents($tempDir.'/messages/en.res'));
|
||||
|
||||
@unlink($tempDir.'/messages/en.res');
|
||||
@rmdir($tempDir.'/messages');
|
||||
@rmdir($tempDir);
|
||||
$this->assertStringEqualsFile(__DIR__.'/../fixtures/resourcebundle/res/en.res', $dumper->formatCatalogue($catalogue, 'messages'));
|
||||
}
|
||||
}
|
||||
|
@ -16,17 +16,13 @@ use Symfony\Component\Translation\Dumper\IniFileDumper;
|
||||
|
||||
class IniFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testDump()
|
||||
public function testFormatCatalogue()
|
||||
{
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
$catalogue->add(array('foo' => 'bar'));
|
||||
|
||||
$tempDir = sys_get_temp_dir();
|
||||
$dumper = new IniFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $tempDir));
|
||||
|
||||
$this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.ini'), file_get_contents($tempDir.'/messages.en.ini'));
|
||||
|
||||
unlink($tempDir.'/messages.en.ini');
|
||||
$this->assertStringEqualsFile(__DIR__.'/../fixtures/resources.ini', $dumper->formatCatalogue($catalogue, 'messages'));
|
||||
}
|
||||
}
|
||||
|
@ -16,19 +16,7 @@ use Symfony\Component\Translation\Dumper\JsonFileDumper;
|
||||
|
||||
class JsonFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $tempDir;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->tempDir = sys_get_temp_dir();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
unlink($this->tempDir.'/messages.en.json');
|
||||
}
|
||||
|
||||
public function testDump()
|
||||
public function testFormatCatalogue()
|
||||
{
|
||||
if (PHP_VERSION_ID < 50400) {
|
||||
$this->markTestIncomplete('PHP below 5.4 doesn\'t support JSON pretty printing');
|
||||
@ -38,9 +26,8 @@ class JsonFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
$catalogue->add(array('foo' => 'bar'));
|
||||
|
||||
$dumper = new JsonFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $this->tempDir));
|
||||
|
||||
$this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.json'), file_get_contents($this->tempDir.'/messages.en.json'));
|
||||
$this->assertStringEqualsFile(__DIR__.'/../fixtures/resources.json', $dumper->formatCatalogue($catalogue, 'messages'));
|
||||
}
|
||||
|
||||
public function testDumpWithCustomEncoding()
|
||||
@ -49,8 +36,7 @@ class JsonFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
$catalogue->add(array('foo' => '"bar"'));
|
||||
|
||||
$dumper = new JsonFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $this->tempDir, 'json_encoding' => JSON_HEX_QUOT));
|
||||
|
||||
$this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.dump.json'), file_get_contents($this->tempDir.'/messages.en.json'));
|
||||
$this->assertStringEqualsFile(__DIR__.'/../fixtures/resources.dump.json', $dumper->formatCatalogue($catalogue, 'messages', array('json_encoding' => JSON_HEX_QUOT)));
|
||||
}
|
||||
}
|
||||
|
@ -16,16 +16,13 @@ use Symfony\Component\Translation\Dumper\MoFileDumper;
|
||||
|
||||
class MoFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testDump()
|
||||
public function testFormatCatalogue()
|
||||
{
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
$catalogue->add(array('foo' => 'bar'));
|
||||
|
||||
$tempDir = sys_get_temp_dir();
|
||||
$dumper = new MoFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $tempDir));
|
||||
$this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.mo'), file_get_contents($tempDir.'/messages.en.mo'));
|
||||
|
||||
unlink($tempDir.'/messages.en.mo');
|
||||
$this->assertStringEqualsFile(__DIR__.'/../fixtures/resources.mo', $dumper->formatCatalogue($catalogue, 'messages'));
|
||||
}
|
||||
}
|
||||
|
@ -16,17 +16,13 @@ use Symfony\Component\Translation\Dumper\PhpFileDumper;
|
||||
|
||||
class PhpFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testDump()
|
||||
public function testFormatCatalogue()
|
||||
{
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
$catalogue->add(array('foo' => 'bar'));
|
||||
|
||||
$tempDir = sys_get_temp_dir();
|
||||
$dumper = new PhpFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $tempDir));
|
||||
|
||||
$this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.php'), file_get_contents($tempDir.'/messages.en.php'));
|
||||
|
||||
unlink($tempDir.'/messages.en.php');
|
||||
$this->assertStringEqualsFile(__DIR__.'/../fixtures/resources.php', $dumper->formatCatalogue($catalogue, 'messages'));
|
||||
}
|
||||
}
|
||||
|
@ -16,16 +16,13 @@ use Symfony\Component\Translation\Dumper\PoFileDumper;
|
||||
|
||||
class PoFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testDump()
|
||||
public function testFormatCatalogue()
|
||||
{
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
$catalogue->add(array('foo' => 'bar'));
|
||||
|
||||
$tempDir = sys_get_temp_dir();
|
||||
$dumper = new PoFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $tempDir));
|
||||
$this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.po'), file_get_contents($tempDir.'/messages.en.po'));
|
||||
|
||||
unlink($tempDir.'/messages.en.po');
|
||||
$this->assertStringEqualsFile(__DIR__.'/../fixtures/resources.po', $dumper->formatCatalogue($catalogue, 'messages'));
|
||||
}
|
||||
}
|
||||
|
@ -16,17 +16,13 @@ use Symfony\Component\Translation\Dumper\QtFileDumper;
|
||||
|
||||
class QtFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testDump()
|
||||
public function testFormatCatalogue()
|
||||
{
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
$catalogue->add(array('foo' => 'bar'), 'resources');
|
||||
|
||||
$tempDir = sys_get_temp_dir();
|
||||
$dumper = new QtFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $tempDir));
|
||||
|
||||
$this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.ts'), file_get_contents($tempDir.'/resources.en.ts'));
|
||||
|
||||
unlink($tempDir.'/resources.en.ts');
|
||||
$this->assertStringEqualsFile(__DIR__.'/../fixtures/resources.ts', $dumper->formatCatalogue($catalogue, 'resources'));
|
||||
}
|
||||
}
|
||||
|
@ -16,14 +16,7 @@ use Symfony\Component\Translation\Dumper\XliffFileDumper;
|
||||
|
||||
class XliffFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $tempDir;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->tempDir = sys_get_temp_dir();
|
||||
}
|
||||
|
||||
public function testDump()
|
||||
public function testFormatCatalogue()
|
||||
{
|
||||
$catalogue = new MessageCatalogue('en_US');
|
||||
$catalogue->add(array(
|
||||
@ -35,17 +28,14 @@ class XliffFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
$catalogue->setMetadata('key', array('notes' => array(array('content' => 'baz'), array('content' => 'qux'))));
|
||||
|
||||
$dumper = new XliffFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $this->tempDir, 'default_locale' => 'fr_FR'));
|
||||
|
||||
$this->assertEquals(
|
||||
file_get_contents(__DIR__.'/../fixtures/resources-clean.xlf'),
|
||||
file_get_contents($this->tempDir.'/messages.en_US.xlf')
|
||||
$this->assertStringEqualsFile(
|
||||
__DIR__.'/../fixtures/resources-clean.xlf',
|
||||
$dumper->formatCatalogue($catalogue, 'messages', array('default_locale' => 'fr_FR'))
|
||||
);
|
||||
|
||||
unlink($this->tempDir.'/messages.en_US.xlf');
|
||||
}
|
||||
|
||||
public function testDumpXliff2()
|
||||
public function testFormatCatalogueXliff2()
|
||||
{
|
||||
$catalogue = new MessageCatalogue('en_US');
|
||||
$catalogue->add(array(
|
||||
@ -56,20 +46,16 @@ class XliffFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
$catalogue->setMetadata('key', array('target-attributes' => array('order' => 1)));
|
||||
|
||||
$dumper = new XliffFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $this->tempDir, 'default_locale' => 'fr_FR', 'xliff_version' => '2.0'));
|
||||
|
||||
$this->assertEquals(
|
||||
file_get_contents(__DIR__.'/../fixtures/resources-2.0-clean.xlf'),
|
||||
file_get_contents($this->tempDir.'/messages.en_US.xlf')
|
||||
$this->assertStringEqualsFile(
|
||||
__DIR__.'/../fixtures/resources-2.0-clean.xlf',
|
||||
$dumper->formatCatalogue($catalogue, 'messages', array('default_locale' => 'fr_FR', 'xliff_version' => '2.0'))
|
||||
);
|
||||
|
||||
unlink($this->tempDir.'/messages.en_US.xlf');
|
||||
}
|
||||
|
||||
public function testDumpWithCustomToolInfo()
|
||||
public function testFormatCatalogueWithCustomToolInfo()
|
||||
{
|
||||
$options = array(
|
||||
'path' => $this->tempDir,
|
||||
'default_locale' => 'en_US',
|
||||
'tool_info' => array('tool-id' => 'foo', 'tool-name' => 'foo', 'tool-version' => '0.0', 'tool-company' => 'Foo'),
|
||||
);
|
||||
@ -78,17 +64,14 @@ class XliffFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
$catalogue->add(array('foo' => 'bar'));
|
||||
|
||||
$dumper = new XliffFileDumper();
|
||||
$dumper->dump($catalogue, $options);
|
||||
|
||||
$this->assertEquals(
|
||||
file_get_contents(__DIR__.'/../fixtures/resources-tool-info.xlf'),
|
||||
file_get_contents($this->tempDir.'/messages.en_US.xlf')
|
||||
$this->assertStringEqualsFile(
|
||||
__DIR__.'/../fixtures/resources-tool-info.xlf',
|
||||
$dumper->formatCatalogue($catalogue, 'messages', $options)
|
||||
);
|
||||
|
||||
unlink($this->tempDir.'/messages.en_US.xlf');
|
||||
}
|
||||
|
||||
public function testDumpWithTargetAttributesMetadata()
|
||||
public function testFormatCatalogueWithTargetAttributesMetadata()
|
||||
{
|
||||
$catalogue = new MessageCatalogue('en_US');
|
||||
$catalogue->add(array(
|
||||
@ -96,15 +79,11 @@ class XliffFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
));
|
||||
$catalogue->setMetadata('foo', array('target-attributes' => array('state' => 'needs-translation')));
|
||||
|
||||
$this->tempDir = sys_get_temp_dir();
|
||||
$dumper = new XliffFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $this->tempDir, 'default_locale' => 'fr_FR'));
|
||||
|
||||
$this->assertEquals(
|
||||
file_get_contents(__DIR__.'/../fixtures/resources-target-attributes.xlf'),
|
||||
file_get_contents($this->tempDir.'/messages.en_US.xlf')
|
||||
$this->assertStringEqualsFile(
|
||||
__DIR__.'/../fixtures/resources-target-attributes.xlf',
|
||||
$dumper->formatCatalogue($catalogue, 'messages', array('default_locale' => 'fr_FR'))
|
||||
);
|
||||
|
||||
unlink($this->tempDir.'/messages.en_US.xlf');
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ use Symfony\Component\Translation\Dumper\YamlFileDumper;
|
||||
|
||||
class YamlFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testTreeDump()
|
||||
public function testTreeFormatCatalogue()
|
||||
{
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
$catalogue->add(
|
||||
@ -25,16 +25,12 @@ class YamlFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
'foo.bar2' => 'value2',
|
||||
));
|
||||
|
||||
$tempDir = sys_get_temp_dir();
|
||||
$dumper = new YamlFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $tempDir, 'as_tree' => true, 'inline' => 999));
|
||||
|
||||
$this->assertEquals(file_get_contents(__DIR__.'/../fixtures/messages.yml'), file_get_contents($tempDir.'/messages.en.yml'));
|
||||
|
||||
unlink($tempDir.'/messages.en.yml');
|
||||
$this->assertStringEqualsFile(__DIR__.'/../fixtures/messages.yml', $dumper->formatCatalogue($catalogue, 'messages', array('as_tree' => true, 'inline' => 999)));
|
||||
}
|
||||
|
||||
public function testLinearDump()
|
||||
public function testLinearFormatCatalogue()
|
||||
{
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
$catalogue->add(
|
||||
@ -43,12 +39,8 @@ class YamlFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
'foo.bar2' => 'value2',
|
||||
));
|
||||
|
||||
$tempDir = sys_get_temp_dir();
|
||||
$dumper = new YamlFileDumper();
|
||||
$dumper->dump($catalogue, array('path' => $tempDir));
|
||||
|
||||
$this->assertEquals(file_get_contents(__DIR__.'/../fixtures/messages_linear.yml'), file_get_contents($tempDir.'/messages.en.yml'));
|
||||
|
||||
unlink($tempDir.'/messages.en.yml');
|
||||
$this->assertStringEqualsFile(__DIR__.'/../fixtures/messages_linear.yml', $dumper->formatCatalogue($catalogue, 'messages'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user