Skip to content

Commit 8fe42e1

Browse files
committed
Merge branch '2.8' into 3.0
* 2.8: fixed test [Request] Ignore invalid IP addresses sent by proxies [EventDispatcher] TraceableEventDispatcher resets listener priorities Throw for missing container extensions [TwigBridge] add missing unit tests (AppVariable) Able to load big xml files with DomCrawler fixed typo [Form] Fix constraints could be null if not set [Finder] Check PHP version before applying a workaround for a PHP bug fixed CS add defaultNull to version sort bundles in config:dump-reference command Fixer findings. Profiler CSS position conflicts with JS detection [Translation][Writer] avoid calling setBackup if the dumper is not an instance of FileDumper. [FrameworkBundle] Compute the kernel root hash only one time
2 parents 4056cfb + 923b069 commit 8fe42e1

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed
Lines 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 <[email protected]>
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(array()), '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+
}

Writer/TranslationWriter.php

Lines 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)