8000 Insert correct parameter_bag service in AbstractController by curry684 · Pull Request #27415 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Psr\Container\ContainerInterface;
use Doctrine\Common\Persistence\ManagerRegistry;
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RequestStack;
Expand Down Expand Up @@ -84,7 +85,7 @@ public static function getSubscribedServices()
'form.factory' => '?'.FormFactoryInterface::class,
'security.token_storage' => '?'.TokenStorageInterface::class,
'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class,
'parameter_bag' => '?'.ContainerInterface::class,
'parameter_bag' => '?'.ContainerBagInterface::class,
'message_bus' => '?'.MessageBusInterface::class,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,32 @@ protected function createController()
return new TestAbstractController();
}

/**
* This test protects the default subscribed core services against accidental modification.
*/
public function testSubscribedServices()
{
$subscribed = AbstractController::getSubscribedServices();
$expectedServices = array(
'router' => '?Symfony\\Component\\Routing\\RouterInterface',
'request_stack' => '?Symfony\\Component\\HttpFoundation\\RequestStack',
'http_kernel' => '?Symfony\\Component\\HttpKernel\\HttpKernelInterface',
'serializer' => '?Symfony\\Component\\Serializer\\SerializerInterface',
'session' => '?Symfony\\Component\\HttpFoundation\\Session\\SessionInterface',
'security.authorization_checker' => '?Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface',
'templating' => '?Symfony\\Component\\Templating\\EngineInterface',
'twig' => '?Twig\\Environment',
'doctrine' => '?Doctrine\\Common\\Persistence\\ManagerRegistry',
'form.factory' => '?Symfony\\Component\\Form\\FormFactoryInterface',
'parameter_bag' => '?Symfony\\Component\\DependencyInjection\\ParameterBag\\ContainerBagInterface',
'message_bus' => '?Symfony\\Component\\Messenger\\MessageBusInterface',
'security.token_storage' => '?Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface',
'security.csrf.token_manager' => '?Symfony\\Component\\Security\\Csrf\\CsrfTokenManagerInterface',
);

$this->assertEquals($expectedServices, $subscribed, 'Subscribed core services in AbstractController have changed');
}

public function testGetParameter()
{
$container = new Container(new FrozenParameterBag(array('foo' => 'bar')));
Expand Down
0