Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9d882e8

Browse filesBrowse files
committed
Merge branch '3.4' into 4.3
* 3.4: ensure compatibility with type resolver 0.5 Call AssertEquals with proper parameters [Twig] Fix Twig config extra keys fix tests depending on other components' tests
2 parents 9072ba8 + 47fb090 commit 9d882e8
Copy full SHA for 9d882e8

File tree

17 files changed

+593
-504
lines changed
Filter options

17 files changed

+593
-504
lines changed

‎src/Symfony/Bridge/Doctrine/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"symfony/stopwatch": "~3.4|~4.0",
2828
"symfony/config": "^4.2",
2929
"symfony/dependency-injection": "~3.4|~4.0",
30-
"symfony/form": "~4.3",
30+
"symfony/form": "^4.3.5",
3131
"symfony/http-kernel": "~3.4|~4.0",
3232
"symfony/messenger": "~4.3",
3333
"symfony/property-access": "~3.4|~4.0",

‎src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
2121
use Symfony\Component\DependencyInjection\ContainerInterface;
2222
use Symfony\Component\HttpFoundation\Request;
23-
use Symfony\Component\HttpKernel\Tests\Controller\ContainerControllerResolverTest;
23+
use Symfony\Component\HttpKernel\Test\Controller\ContainerControllerResolverTestCase;
2424

25-
class ControllerResolverTest extends ContainerControllerResolverTest
25+
class ControllerResolverTest extends ContainerControllerResolverTestCase
2626
{
2727
public function testGetControllerOnContainerAware()
2828
{

‎src/Symfony/Bundle/FrameworkBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"symfony/debug": "~4.0",
2424
"symfony/dependency-injection": "^4.3",
2525
"symfony/http-foundation": "^4.3",
26-
"symfony/http-kernel": "^4.3.4",
26+
"symfony/http-kernel": "^4.3.5",
2727
"symfony/polyfill-mbstring": "~1.0",
2828
"symfony/filesystem": "~3.4|~4.0",
2929
"symfony/finder": "~3.4|~4.0",

‎src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php
+10-8Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,20 @@ public function load(array $configs, ContainerBuilder $container)
145145
}
146146
}
147147

148-
unset(
149-
$config['form'],
150-
$config['globals'],
151-
$config['extensions']
152-
);
153-
154148
if (isset($config['autoescape_service']) && isset($config['autoescape_service_method'])) {
155149
$config['autoescape'] = [new Reference($config['autoescape_service']), $config['autoescape_service_method']];
156150
}
157-
unset($config['autoescape_service'], $config['autoescape_service_method']);
158151

159-
$container->getDefinition('twig')->replaceArgument(1, $config);
152+
$container->getDefinition('twig')->replaceArgument(1, array_intersect_key($config, [
153+
'debug' => true,
154+
'charset' => true,
155+
'base_template_class' => true,
156+
'strict_variables' => true,
157+
'autoescape' => true,
158+
'cache' => true,
159+
'auto_reload' => true,
160+
'optimizations' => true,
161+
]));
160162

161163
$container->registerForAutoconfiguration(\Twig_ExtensionInterface::class)->addTag('twig.extension');
162164
$container->registerForAutoconfiguration(\Twig_LoaderInterface::class)->addTag('twig.loader');

‎src/Symfony/Component/Form/Test/FormPerformanceTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Test/FormPerformanceTestCase.php
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Form\Test;
1313

14-
use Symfony\Component\Form\Tests\VersionAwareTest;
15-
1614
/**
1715
* Base class for performance tests.
1816
*

‎src/Symfony/Component/Form/Tests/VersionAwareTest.php renamed to ‎src/Symfony/Component/Form/Test/VersionAwareTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Test/VersionAwareTest.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Form\Tests;
12+
namespace Symfony\Component\Form\Test;
1313

14+
/**
15+
* @internal
16+
*/
1417
trait VersionAwareTest
1518
{
1619
protected static $supportedFeatureSetVersion = 304;

‎src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Form\FormError;
1818
use Symfony\Component\Form\FormView;
1919
use Symfony\Component\Form\Test\FormIntegrationTestCase;
20+
use Symfony\Component\Form\Test\VersionAwareTest;
2021

2122
abstract class AbstractLayoutTest extends FormIntegrationTestCase
2223
{

‎src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\Test\TypeTestCase;
15-
use Symfony\Component\Form\Tests\VersionAwareTest;
15+
use Symfony\Component\Form\Test\VersionAwareTest;
1616

1717
/**
1818
* @author Bernhard Schussek <bschussek@gmail.com>

‎src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testConstructorWithSimpleTypes()
4343
$this->assertSame('0', $response->getContent());
4444

4545
$response = new JsonResponse(0.1);
46-
$this->assertEquals('0.1', $response->getContent());
46+
$this->assertEquals(0.1, $response->getContent());
4747
$this->assertIsString($response->getContent());
4848

4949
$response = new JsonResponse(true);
@@ -132,7 +132,7 @@ public function testStaticCreateWithSimpleTypes()
132132

133133
$response = JsonResponse::create(0.1);
134134
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
135-
$this->assertEquals('0.1', $response->getContent());
135+
$this->assertEquals(0.1, $response->getContent());
136136
$this->assertIsString($response->getContent());
137137

138138
$response = JsonResponse::create(true);
+263Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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\HttpKernel\Test\Controller;
13+
14+
use Psr\Container\ContainerInterface;
15+
use Psr\Log\LoggerInterface;
16+
use Symfony\Component\Debug\ErrorHandler;
17+
use Symfony\Component\DependencyInjection\Container;
18+
use Symfony\Component\HttpFoundation\Request;
19+
use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver;
20+
21+
/**
22+
* @internal
23+
*/
24+
class ContainerControllerResolverTestCase extends ControllerResolverTestCase
25+
{
26+
public function testGetControllerServiceWithSingleColon()
27+
{
28+
$service = new ControllerTestService('foo');
29+
30+
$container = $this->createMockContainer();
31+
$container->expects($this->once())
32+
->method('has')
33+
->with('foo')
34+
->willReturn(true);
35+
$container->expects($this->once())
36+
->method('get')
37+
->with('foo')
38+
->willReturn($service)
39+
;
40+
41+
$resolver = $this->createControllerResolver(null, $container);
42+
$request = Request::create('/');
43+
$request->attributes->set('_controller', 'foo:action');
44+
45+
$controller = $resolver->getController($request);
46+
47+
$this->assertSame($service, $controller[0]);
48+
$this->assertSame('action', $controller[1]);
49+
}
50+
51+
public function testGetControllerService()
52+
{
53+
$service = new ControllerTestService('foo');
54+
55+
$container = $this->createMockContainer();
56+
$container->expects($this->once())
57+
->method('has')
58+
->with('foo')
59+
->willReturn(true);
60+
$container->expects($this->once())
61+
->method('get')
62+
->with('foo')
63+
->willReturn($service)
64+
;
65+
66+
$resolver = $this->createControllerResolver(null, $container);
67+
$request = Request::create('/');
68+
$request->attributes->set('_controller', 'foo::action');
69+
70+
$controller = $resolver->getController($request);
71+
72+
$this->assertSame($service, $controller[0]);
73+
$this->assertSame('action', $controller[1]);
74+
}
75+
76+
public function testGetControllerInvokableService()
77+
{
78+
$service = new InvokableControllerService('bar');
79+
80+
$container = $this->createMockContainer();
81+
$container->expects($this->once())
82+
->method('has')
83+
->with('foo')
84+
->willReturn(true)
85+
;
86+
$container->expects($this->once())
87+
->method('get')
88+
->with('foo')
89+
->willReturn($service)
90+
;
91+
92+
$resolver = $this->createControllerResolver(null, $container);
93+
$request = Request::create('/');
94+
$request->attributes->set('_controller', 'foo');
95+
96+
$controller = $resolver->getController($request);
97+
98+
$this->assertSame($service, $controller);
99+
}
100+
101+
public function testGetControllerInvokableServiceWithClassNameAsName()
102+
{
103+
$service = new InvokableControllerService('bar');
104+
105+
$container = $this->createMockContainer();
106+
$container->expects($this->once())
107+
->method('has')
108+
->with(InvokableControllerService::class)
109+
->willReturn(true)
110+
;
111+
$container->expects($this->once())
112+
->method('get')
113+
->with(InvokableControllerService::class)
114+
->willReturn($service)
115+
;
116+
117+
$resolver = $this->createControllerResolver(null, $container);
118+
$request = Request::create('/');
119+
$request->attributes->set('_controller', InvokableControllerService::class);
120+
121+
$controller = $resolver->getController($request);
122+
123+
$this->assertSame($service, $controller);
124+
}
125+
126+
/**
127+
* @dataProvider getControllers
128+
*/
129+
public function testInstantiateControllerWhenControllerStartsWithABackslash($controller)
130+
{
131+
$service = new ControllerTestService('foo');
132+
$class = ControllerTestService::class;
133+
134+
$container = $this->createMockContainer();
135+
$container->expects($this->once())->method('has')->with($class)->willReturn(true);
136+
$container->expects($this->once())->method('get')->with($class)->willReturn($service);
137+
138+
$resolver = $this->createControllerResolver(null, $container);
139+
$request = Request::create('/');
140+
$request->attributes->set('_controller', $controller);
141+
142+
$controller = $resolver->getController($request);
143+
144+
$this->assertInstanceOf(ControllerTestService::class, $controller[0]);
145+
$this->assertSame('action', $controller[1]);
146+
}
147+
148+
public function getControllers()
149+
{
150+
return [
151+
['\\'.ControllerTestService::class.'::action'],
152+
['\\'.ControllerTestService::class.':action'],
153+
];
154+
}
155+
156+
public function testExceptionWhenUsingRemovedControllerServiceWithClassNameAsName()
157+
{
158+
$this->expectException('InvalidArgumentException');
159+
$this->expectExceptionMessage('Controller "Symfony\Component\HttpKernel\Test\Controller\ControllerTestService" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?');
160+
$container = $this->getMockBuilder(Container::class)->getMock();
161+
$container->expects($this->once())
162+
->method('has')
163+
->with(ControllerTestService::class)
164+
->willReturn(false)
165+
;
166+
167+
$container->expects($this->atLeastOnce())
168+
->method('getRemovedIds')
169+
->with()
170+
->willReturn([ControllerTestService::class => true])
171+
;
172+
173+
$resolver = $this->createControllerResolver(null, $container);
174+
$request = Request::create('/');
175+
$request->attributes->set('_controller', [ControllerTestService::class, 'action']);
176+
177+
$resolver->getController($request);
178+
}
179+
180+
public function testExceptionWhenUsingRemovedControllerService()
181+
{
182+
$this->expectException('InvalidArgumentException');
183+
$this->expectExceptionMessage('Controller "app.my_controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?');
184+
$container = $this->getMockBuilder(Container::class)->getMock();
185+
$container->expects($this->once())
186+
->method('has')
187+
->with('app.my_controller')
188+
->willReturn(false)
189+
;
190+
191+
$container->expects($this->atLeastOnce())
192+
->method('getRemovedIds')
193+
->with()
194+
->willReturn(['app.my_controller' => true])
195+
;
196+
197+
$resolver = $this->createControllerResolver(null, $container);
198+
199+
$request = Request::create('/');
200+
$request->attributes->set('_controller', 'app.my_controller');
201+
$resolver->getController($request);
202+
}
203+
204+
public function getUndefinedControllers()
205+
{
206+
$tests = parent::getUndefinedControllers();
207+
$tests[0] = ['foo', \InvalidArgumentException::class, 'Controller "foo" does neither exist as service nor as class'];
208+
$tests[1] = ['oof::bar', \InvalidArgumentException::class, 'Controller "oof" does neither exist as service nor as class'];
209+
$tests[2] = [['oof', 'bar'], \InvalidArgumentException::class, 'Controller "oof" does neither exist as service nor as class'];
210+
$tests[] = [
211+
[ControllerTestService::class, 'action'],
212+
\InvalidArgumentException::class,
213+
'Controller "Symfony\Component\HttpKernel\Test\Controller\ControllerTestService" has required constructor arguments and does not exist in the container. Did you forget to define such a service?',
214+
];
215+
$tests[] = [
216+
ControllerTestService::class.'::action',
217+
\InvalidArgumentException::class, 'Controller "Symfony\Component\HttpKernel\Test\Controller\ControllerTestService" has required constructor arguments and does not exist in the container. Did you forget to define such a service?',
218+
];
219+
$tests[] = [
220+
InvokableControllerService::class,
221+
\InvalidArgumentException::class,
222+
'Controller "Symfony\Component\HttpKernel\Test\Controller\InvokableControllerService" has required constructor arguments and does not exist in the container. Did you forget to define such a service?',
223+
];
224+
225+
return $tests;
226+
}
227+
228+
protected function createControllerResolver(LoggerInterface $logger = null, ContainerInterface $container = null)
229+
{
230+
if (!$container) {
231+
$container = $this->createMockContainer();
232+
}
233+
234+
return new ContainerControllerResolver($container, $logger);
235+
}
236+
237+
protected function createMockContainer()
238+
{
239+
return $this->getMockBuilder(ContainerInterface::class)->getMock();
240+
}
241+
}
242+
243+
class InvokableControllerService
244+
{
245+
public function __construct($bar) // mandatory argument to prevent automatic instantiation
246+
{
247+
}
248+
249+
public function __invoke()
250+
{
251+
}
252+
}
253+
254+
class ControllerTestService
255+
{
256+
public function __construct($foo)
257+
{
258+
}
259+
260+
public function action()
261+
{
262+
}
263+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.