Skip to content

Commit 83956b6

Browse files
committed
Merge branch '3.4' into 4.4
* 3.4: add validator translation 99 for Italian language stop using the deprecated at() PHPUnit matcher Fix typehint phpdoc
2 parents bbfab80 + 7c3a172 commit 83956b6

File tree

3 files changed

+41
-64
lines changed

3 files changed

+41
-64
lines changed

Tests/Controller/TemplateControllerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Bundle\FrameworkBundle\Controller\TemplateController;
1515
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
1616
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
17+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718

1819
/**
1920
* @author Kévin Dunglas <dunglas@gmail.com>

Tests/Templating/DelegatingEngineTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\HttpFoundation\Response;
1718

1819
/**
@@ -111,14 +112,10 @@ private function getFrameworkEngineMock($template, $supports)
111112

112113
private function getContainerMock($services)
113114
{
114-
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
115+
$container = new ContainerBuilder();
115116

116-
$i = 0;
117117
foreach ($services as $id => $service) {
118-
$container->expects($this->at($i++))
119-
->method('get')
120-
->with($id)
121-
->willReturn($service);
118+
$container->set($id, $service);
122119
}
123120

124121
return $container;

Tests/Translation/TranslatorTest.php

Lines changed: 37 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,18 @@ public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $e
184184

185185
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
186186

187-
$loader->expects($this->at(0))
187+
$loader->expects($this->exactly(2))
188188
->method('load')
189-
/* The "messages.some_locale.loader" is passed via the resource_file option and shall be loaded first */
190-
->with('messages.some_locale.loader', 'some_locale', 'messages')
191-
->willReturn($someCatalogue);
192-
193-
$loader->expects($this->at(1))
194-
->method('load')
195-
/* This resource is added by an addResource() call and shall be loaded after the resource_files */
196-
->with('second_resource.some_locale.loader', 'some_locale', 'messages')
197-
->willReturn($someCatalogue);
189+
->withConsecutive(
190+
/* The "messages.some_locale.loader" is passed via the resource_file option and shall be loaded first */
191+
['messages.some_locale.loader', 'some_locale', 'messages'],
192+
/* This resource is added by an addResource() call and shall be loaded after the resource_files */
193+
['second_resource.some_locale.loader', 'some_locale', 'messages']
194+
)
195+
->willReturnOnConsecutiveCalls(
196+
$someCatalogue,
197+
$someCatalogue
198+
);
198199

199200
$options = [
200201
'resource_files' => ['some_locale' => ['messages.some_locale.loader']],
@@ -301,55 +302,33 @@ protected function getLoader()
301302
{
302303
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
303304
$loader
304-
->expects($this->at(0))
305-
->method('load')
306-
->willReturn($this->getCatalogue('fr', [
307-
'foo' => 'foo (FR)',
308-
]))
309-
;
310-
$loader
311-
->expects($this->at(1))
312-
->method('load')
313-
->willReturn($this->getCatalogue('en', [
314-
'foo' => 'foo (EN)',
315-
'bar' => 'bar (EN)',
316-
'choice' => '{0} choice 0 (EN)|{1} choice 1 (EN)|]1,Inf] choice inf (EN)',
317-
]))
318-
;
319-
$loader
320-
->expects($this->at(2))
321-
->method('load')
322-
->willReturn($this->getCatalogue('es', [
323-
'foobar' => 'foobar (ES)',
324-
]))
325-
;
326-
$loader
327-
->expects($this->at(3))
328-
->method('load')
329-
->willReturn($this->getCatalogue('pt-PT', [
330-
'foobarfoo' => 'foobarfoo (PT-PT)',
331-
]))
332-
;
333-
$loader
334-
->expects($this->at(4))
335-
->method('load')
336-
->willReturn($this->getCatalogue('pt_BR', [
337-
'other choice' => '{0} other choice 0 (PT-BR)|{1} other choice 1 (PT-BR)|]1,Inf] other choice inf (PT-BR)',
338-
]))
339-
;
340-
$loader
341-
->expects($this->at(5))
342-
->method('load')
343-
->willReturn($this->getCatalogue('fr.UTF-8', [
344-
'foobarbaz' => 'foobarbaz (fr.UTF-8)',
345-
]))
346-
;
347-
$loader
348-
->expects($this->at(6))
305+
->expects($this->exactly(7))
349306
->method('load')
350-
->willReturn($this->getCatalogue('sr@latin', [
351-
'foobarbax' => 'foobarbax (sr@latin)',
352-
]))
307+
->willReturnOnConsecutiveCalls(
308+
$this->getCatalogue('fr', [
309+
'foo' => 'foo (FR)',
310+
]),
311+
$this->getCatalogue('en', [
312+
'foo' => 'foo (EN)',
313+
'bar' => 'bar (EN)',
314+
'choice' => '{0} choice 0 (EN)|{1} choice 1 (EN)|]1,Inf] choice inf (EN)',
315+
]),
316+
$this->getCatalogue('es', [
317+
'foobar' => 'foobar (ES)',
318+
]),
319+
$this->getCatalogue('pt-PT', [
320+
'foobarfoo' => 'foobarfoo (PT-PT)',
321+
]),
322+
$this->getCatalogue('pt_BR', [
323+
'other choice' => '{0} other choice 0 (PT-BR)|{1} other choice 1 (PT-BR)|]1,Inf] other choice inf (PT-BR)',
324+
]),
325+
$this->getCatalogue('fr.UTF-8', [
326+
'foobarbaz' => 'foobarbaz (fr.UTF-8)',
327+
]),
328+
$this->getCatalogue('sr@latin', [
329+
'foobarbax' => 'foobarbax (sr@latin)',
330+
])
331+
)
353332
;
354333

355334
return $loader;

0 commit comments

Comments
 (0)