Skip to content

Commit 6121dd0

Browse files
Merge branch '4.3' into 4.4
* 4.3: [Messenger] add tests to FailedMessagesShowCommand Fix the translation commands when a template contains a syntax error [Security] Fix clearing remember-me cookie after deauthentication [Validator] Update Slovenian translations [Config][ReflectionClassResource] Handle parameters with undefined constant as their default values fix dumping number-like string parameters Fix CI [Console] Fix autocomplete multibyte input support [Config] don't break on virtual stack frames in ClassExistenceResource more robust initialization from request
2 parents d36e85e + 29a701d commit 6121dd0

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

Tests/Translation/TwigExtractorTest.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\Translation\MessageCatalogue;
1818
use Symfony\Contracts\Translation\TranslatorInterface;
1919
use Twig\Environment;
20-
use Twig\Error\Error;
2120
use Twig\Loader\ArrayLoader;
2221

2322
class TwigExtractorTest extends TestCase
@@ -101,31 +100,23 @@ public function getLegacyExtractData()
101100
/**
102101
* @dataProvider resourcesWithSyntaxErrorsProvider
103102
*/
104-
public function testExtractSyntaxError($resources)
103+
public function testExtractSyntaxError($resources, array $messages)
105104
{
106-
$this->expectException('Twig\Error\Error');
107105
$twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock());
108106
$twig->addExtension(new TranslationExtension($this->getMockBuilder(TranslatorInterface::class)->getMock()));
109107

110108
$extractor = new TwigExtractor($twig);
111-
112-
try {
113-
$extractor->extract($resources, new MessageCatalogue('en'));
114-
} catch (Error $e) {
115-
$this->assertSame(\dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', \DIRECTORY_SEPARATOR), $e->getFile());
116-
$this->assertSame(1, $e->getLine());
117-
$this->assertSame('Unclosed "block".', $e->getMessage());
118-
119-
throw $e;
120-
}
109+
$catalogue = new MessageCatalogue('en');
110+
$extractor->extract($resources, $catalogue);
111+
$this->assertSame($messages, $catalogue->all());
121112
}
122113

123114
public function resourcesWithSyntaxErrorsProvider(): array
124115
{
125116
return [
126-
[__DIR__.'/../Fixtures'],
127-
[__DIR__.'/../Fixtures/extractor/syntax_error.twig'],
128-
[new \SplFileInfo(__DIR__.'/../Fixtures/extractor/syntax_error.twig')],
117+
[__DIR__.'/../Fixtures', ['messages' => ['Hi!' => 'Hi!']]],
118+
[__DIR__.'/../Fixtures/extractor/syntax_error.twig', []],
119+
[new \SplFileInfo(__DIR__.'/../Fixtures/extractor/syntax_error.twig'), []],
129120
];
130121
}
131122

Translation/TwigExtractor.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bridge\Twig\Translation;
1313

1414
use Symfony\Component\Finder\Finder;
15-
use Symfony\Component\Finder\SplFileInfo;
1615
use Symfony\Component\Translation\Extractor\AbstractFileExtractor;
1716
use Symfony\Component\Translation\Extractor\ExtractorInterface;
1817
use Symfony\Component\Translation\MessageCatalogue;
@@ -58,13 +57,7 @@ public function extract($resource, MessageCatalogue $catalogue)
5857
try {
5958
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
6059
} catch (Error $e) {
61-
if ($file instanceof \SplFileInfo) {
62-
$path = $file->getRealPath() ?: $file->getPathname();
63-
$name = $file instanceof SplFileInfo ? $file->getRelativePathname() : $path;
64-
$e->setSourceContext(new Source('', $name, $path));
65-
}
66-
67-
throw $e;
60+
// ignore errors, these should be fixed by using the linter
6861
}
6962
}
7063
}

0 commit comments

Comments
 (0)