Merge branch '4.4'
* 4.4: [HttpKernel] fixed class having a leading \ in a route controller [HttpKernel] trim the leading backslash in the controller init Bump minimal requirements Use PHPUnit 8.3 on Travis when possible
This commit is contained in:
commit
547b9b8fc3
|
@ -29,9 +29,6 @@ matrix:
|
|||
env: deps=high
|
||||
- php: 7.3
|
||||
env: deps=low
|
||||
- php: 7.4snapshot
|
||||
allow_failures:
|
||||
- php: 7.4snapshot
|
||||
fast_finish: true
|
||||
|
||||
cache:
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
"psr/http-client": "^1.0",
|
||||
"psr/simple-cache": "^1.0",
|
||||
"egulias/email-validator": "~1.2,>=1.2.8|~2.0",
|
||||
"symfony/phpunit-bridge": "^3.4.19|^4.1.8|~5.0",
|
||||
"symfony/phpunit-bridge": "^3.4.31|^4.3.4|~5.0",
|
||||
"symfony/security-acl": "~2.8|~3.0",
|
||||
"phpdocumentor/reflection-docblock": "^3.0|^4.0"
|
||||
},
|
||||
|
|
4
phpunit
4
phpunit
|
@ -8,8 +8,8 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
|
|||
exit(1);
|
||||
}
|
||||
if (!getenv('SYMFONY_PHPUNIT_VERSION')) {
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
putenv('SYMFONY_PHPUNIT_VERSION=8.2');
|
||||
if (\PHP_VERSION_ID >= 70200) {
|
||||
putenv('SYMFONY_PHPUNIT_VERSION=8.3');
|
||||
} elseif (\PHP_VERSION_ID >= 70000) {
|
||||
putenv('SYMFONY_PHPUNIT_VERSION=6.5');
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class LegacyRouteLoaderContainerTest extends TestCase
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->container = new Container();
|
||||
$this->container->set('foo', new \stdClass());
|
||||
|
|
|
@ -47,6 +47,8 @@ class ContainerControllerResolver extends ControllerResolver
|
|||
*/
|
||||
protected function instantiateController(string $class)
|
||||
{
|
||||
$class = ltrim($class, '\\');
|
||||
|
||||
if ($this->container->has($class)) {
|
||||
return $this->container->get($class);
|
||||
}
|
||||
|
|
|
@ -119,6 +119,36 @@ class ContainerControllerResolverTest extends ControllerResolverTest
|
|||
$this->assertSame($service, $controller);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getControllers
|
||||
*/
|
||||
public function testInstantiateControllerWhenControllerStartsWithABackslash($controller)
|
||||
{
|
||||
$service = new ControllerTestService('foo');
|
||||
$class = ControllerTestService::class;
|
||||
|
||||
$container = $this->createMockContainer();
|
||||
$container->expects($this->once())->method('has')->with($class)->willReturn(true);
|
||||
$container->expects($this->once())->method('get')->with($class)->willReturn($service);
|
||||
|
||||
$resolver = $this->createControllerResolver(null, $container);
|
||||
$request = Request::create('/');
|
||||
$request->attributes->set('_controller', $controller);
|
||||
|
||||
$controller = $resolver->getController($request);
|
||||
|
||||
$this->assertInstanceOf(ControllerTestService::class, $controller[0]);
|
||||
$this->assertSame('action', $controller[1]);
|
||||
}
|
||||
|
||||
public function getControllers()
|
||||
{
|
||||
return [
|
||||
['\\'.ControllerTestService::class.'::action'],
|
||||
['\\'.ControllerTestService::class.':action'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testExceptionWhenUsingRemovedControllerServiceWithClassNameAsName()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
|
|
Reference in New Issue