Skip to content

Commit

Permalink
Merge branch '3.0'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nicolas-grekas committed Feb 4, 2016
2 parents 6e0a9d8 + 2de0b6f commit 74893d6
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 4 deletions.
4 changes: 1 addition & 3 deletions Dumper/PhpFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ class PhpFileDumper extends FileDumper
*/
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
{
$output = "<?php\n\nreturn ".var_export($messages->all($domain), true).";\n";

return $output;
return "<?php\n\nreturn ".var_export($messages->all($domain), true).";\n";
}

/**
Expand Down
20 changes: 20 additions & 0 deletions Tests/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,26 @@ public function testWhenAResourceHasNoRegisteredLoader()
$translator->trans('foo');
}

public function testFallbackCatalogueResources()
{
$translator = new Translator('en_GB', new MessageSelector());
$translator->addLoader('yml', new \Symfony\Component\Translation\Loader\YamlFileLoader());
$translator->addResource('yml', __DIR__.'/fixtures/empty.yml', 'en_GB');
$translator->addResource('yml', __DIR__.'/fixtures/resources.yml', 'en');

// force catalogue loading
$this->assertEquals('bar', $translator->trans('foo', array()));

$resources = $translator->getCatalogue('en')->getResources();
$this->assertCount(1, $resources);
$this->assertContains( __DIR__.DIRECTORY_SEPARATOR.'fixtures'.DIRECTORY_SEPARATOR.'resources.yml', $resources);

$resources = $translator->getCatalogue('en_GB')->getResources();
$this->assertCount(2, $resources);
$this->assertContains( __DIR__.DIRECTORY_SEPARATOR.'fixtures'.DIRECTORY_SEPARATOR.'empty.yml', $resources);
$this->assertContains( __DIR__.DIRECTORY_SEPARATOR.'fixtures'.DIRECTORY_SEPARATOR.'resources.yml', $resources);
}

/**
* @dataProvider getTransTests
*/
Expand Down
47 changes: 47 additions & 0 deletions Tests/Writer/TranslationWriterTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?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\Tests\Writer;

use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\Writer\TranslationWriter;

class TranslationWriterTest extends \PHPUnit_Framework_TestCase
{
public function testWriteTranslations()
{
$dumper = $this->getMock('Symfony\Component\Translation\Dumper\DumperInterface');
$dumper
->expects($this->once())
->method('dump');

$writer = new TranslationWriter();
$writer->addDumper('test', $dumper);
$writer->writeTranslations(new MessageCatalogue(array()), 'test');
}

public function testDisableBackup()
{
$dumper = $this->getMock('Symfony\Component\Translation\Dumper\DumperInterface');
$dumper
->expects($this->never())
->method('setBackup');
$phpDumper = $this->getMock('Symfony\Component\Translation\Dumper\PhpFileDumper');
$phpDumper
->expects($this->once())
->method('setBackup');

$writer = new TranslationWriter();
$writer->addDumper('test', $dumper);
$writer->addDumper('php', $phpDumper);
$writer->disableBackup();
}
}
3 changes: 3 additions & 0 deletions Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ private function loadFallbackCatalogues($locale)
}

$fallbackCatalogue = new MessageCatalogue($fallback, $this->catalogues[$fallback]->all());
foreach ($this->catalogues[$fallback]->getResources() as $resource) {
$fallbackCatalogue->addResource($resource);
}
$current->addFallbackCatalogue($fallbackCatalogue);
$current = $fallbackCatalogue;
}
Expand Down
4 changes: 3 additions & 1 deletion Writer/TranslationWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public function addDumper($format, DumperInterface $dumper)
public function disableBackup()
{
foreach ($this->dumpers as $dumper) {
$dumper->setBackup(false);
if (method_exists($dumper, 'setBackup')) {
$dumper->setBackup(false);
}
}
}

Expand Down

0 comments on commit 74893d6

Please sign in to comment.