Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6c43dc0

Browse filesBrowse files
committed
[Translation][Writer] avoid calling setBackup if the dumper is not an instance of FileDumper.
1 parent f253d62 commit 6c43dc0
Copy full SHA for 6c43dc0

File tree

2 files changed

+50
-1
lines changed
Filter options

2 files changed

+50
-1
lines changed
+47Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Translation\Tests\Writer;
13+
14+
use Symfony\Component\Translation\MessageCatalogue;
15+
use Symfony\Component\Translation\Writer\TranslationWriter;
16+
17+
class TranslationWriterTest extends \PHPUnit_Framework_TestCase
18+
{
19+
public function testWriteTranslations()
20+
{
21+
$dumper = $this->getMock('Symfony\Component\Translation\Dumper\DumperInterface');
22+
$dumper
23+
->expects($this->once())
24+
->method('dump');
25+
26+
$writer = new TranslationWriter();
27+
$writer->addDumper('test', $dumper);
28+
$writer->writeTranslations(new MessageCatalogue([]), 'test');
29+
}
30+
31+
public function testDisableBackup()
32+
{
33+
$dumper = $this->getMock('Symfony\Component\Translation\Dumper\DumperInterface');
34+
$dumper
35+
->expects($this->never())
36+
->method('setBackup');
37+
$phpDumper = $this->getMock('Symfony\Component\Translation\Dumper\PhpFileDumper');
38+
$phpDumper
39+
->expects($this->once())
40+
->method('setBackup');
41+
42+
$writer = new TranslationWriter();
43+
$writer->addDumper('test', $dumper);
44+
$writer->addDumper('php', $phpDumper);
45+
$writer->disableBackup();
46+
}
47+
}

‎src/Symfony/Component/Translation/Writer/TranslationWriter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Writer/TranslationWriter.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public function addDumper($format, DumperInterface $dumper)
4545
public function disableBackup()
4646
{
4747
foreach ($this->dumpers as $dumper) {
48-
$dumper->setBackup(false);
48+
if (method_exists($dumper, 'setBackup')) {
49+
$dumper->setBackup(false);
50+
}
4951
}
5052
}
5153

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.