Skip to content

Commit 74893d6

Browse files
Merge branch '3.0'
* 3.0: (105 commits) [Console] remove readline support bumped Symfony version to 3.0.3 updated VERSION for 3.0.2 updated CHANGELOG for 3.0.2 [Routing] added a suggestion to add the HttpFoundation component. [FrameworkBundle] fix assets and templating tests [ClassLoader] fix ApcClassLoader tests on HHVM [travis] Add some comments changed operator from and to && [DependencyInjection] Remove unused parameter [Process] Fix transient tests for incremental outputs [Console] Add missing `@require` annotation in test Fix merge [appveyor] Fix failure reporting [#17634] move DebugBundle license file Limit Ldap component version for the 3.0 branch backport GlobTest from 2.7 branch Move licenses according to new best practices [FrameworkBundle] Remove unused code in test [2.3] Fixed an undefined variable in Glob::toRegex ... Conflicts: .travis.yml composer.json src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets.xml src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig src/Symfony/Component/Console/CHANGELOG.md src/Symfony/Component/HttpKernel/Kernel.php src/Symfony/Component/PropertyInfo/Tests/PropertyInfoExtractorTest.php src/Symfony/Component/Yaml/Tests/ParserTest.php
2 parents 6e0a9d8 + 2de0b6f commit 74893d6

File tree

5 files changed

+74
-4
lines changed

5 files changed

+74
-4
lines changed

Dumper/PhpFileDumper.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ class PhpFileDumper extends FileDumper
2525
*/
2626
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
2727
{
28-
$output = "<?php\n\nreturn ".var_export($messages->all($domain), true).";\n";
29-
30-
return $output;
28+
return "<?php\n\nreturn ".var_export($messages->all($domain), true).";\n";
3129
}
3230

3331
/**

Tests/TranslatorTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,26 @@ public function testWhenAResourceHasNoRegisteredLoader()
273273
$translator->trans('foo');
274274
}
275275

276+
public function testFallbackCatalogueResources()
277+
{
278+
$translator = new Translator('en_GB', new MessageSelector());
279+
$translator->addLoader('yml', new \Symfony\Component\Translation\Loader\YamlFileLoader());
280+
$translator->addResource('yml', __DIR__.'/fixtures/empty.yml', 'en_GB');
281+
$translator->addResource('yml', __DIR__.'/fixtures/resources.yml', 'en');
282+
283+
// force catalogue loading
284+
$this->assertEquals('bar', $translator->trans('foo', array()));
285+
286+
$resources = $translator->getCatalogue('en')->getResources();
287+
$this->assertCount(1, $resources);
288+
$this->assertContains( __DIR__.DIRECTORY_SEPARATOR.'fixtures'.DIRECTORY_SEPARATOR.'resources.yml', $resources);
289+
290+
$resources = $translator->getCatalogue('en_GB')->getResources();
291+
$this->assertCount(2, $resources);
292+
$this->assertContains( __DIR__.DIRECTORY_SEPARATOR.'fixtures'.DIRECTORY_SEPARATOR.'empty.yml', $resources);
293+
$this->assertContains( __DIR__.DIRECTORY_SEPARATOR.'fixtures'.DIRECTORY_SEPARATOR.'resources.yml', $resources);
294+
}
295+
276296
/**
277297
* @dataProvider getTransTests
278298
*/
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+
}

Translator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ private function loadFallbackCatalogues($locale)
384384
}
385385

386386
$fallbackCatalogue = new MessageCatalogue($fallback, $this->catalogues[$fallback]->all());
387+
foreach ($this->catalogues[$fallback]->getResources() as $resource) {
388+
$fallbackCatalogue->addResource($resource);
389+
}
387390
$current->addFallbackCatalogue($fallbackCatalogue);
388391
$current = $fallbackCatalogue;
389392
}

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)