[HttpKernel] fixed class having a leading \ in a route controller
This commit is contained in:
parent
6fdf2527d6
commit
3c8d395d0d
@ -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');
|
||||
|
@ -38,18 +38,6 @@ class ControllerResolverTest extends TestCase
|
||||
$this->assertSame($lambda, $controller);
|
||||
}
|
||||
|
||||
public function testGetControllerWithStartingBackslash()
|
||||
{
|
||||
$resolver = $this->createControllerResolver();
|
||||
|
||||
$request = Request::create('/');
|
||||
$request->attributes->set('_controller', '\\'.ControllerTest::class.'::publicAction');
|
||||
$controller = $resolver->getController($request);
|
||||
|
||||
$this->assertInstanceOf(ControllerTest::class, $controller[0]);
|
||||
$this->assertSame('publicAction', $controller[1]);
|
||||
}
|
||||
|
||||
public function testGetControllerWithObjectAndInvokeMethod()
|
||||
{
|
||||
$resolver = $this->createControllerResolver();
|
||||
@ -83,17 +71,6 @@ class ControllerResolverTest extends TestCase
|
||||
$this->assertSame('publicAction', $controller[1]);
|
||||
}
|
||||
|
||||
public function testGetControllerWithClassAndMethodAsArrayWithBackslash()
|
||||
{
|
||||
$resolver = $this->createControllerResolver();
|
||||
|
||||
$request = Request::create('/');
|
||||
$request->attributes->set('_controller', ['\\'.ControllerTest::class, 'publicAction']);
|
||||
$controller = $resolver->getController($request);
|
||||
$this->assertInstanceOf(ControllerTest::class, $controller[0]);
|
||||
$this->assertSame('publicAction', $controller[1]);
|
||||
}
|
||||
|
||||
public function testGetControllerWithClassAndMethodAsString()
|
||||
{
|
||||
$resolver = $this->createControllerResolver();
|
||||
|
Reference in New Issue
Block a user