feature #15695 [FrameworkBundle] Removed deprecated code paths (nicolas-grekas)

This PR was merged into the 3.0-dev branch.

Discussion
----------

[FrameworkBundle] Removed deprecated code paths

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

640b95a [FrameworkBundle] Removed deprecated code paths
This commit is contained in:
Fabien Potencier 2015-09-06 10:19:14 +02:00
commit 722edcebb9
39 changed files with 49 additions and 533 deletions

View File

@ -327,10 +327,6 @@ abstract class Controller extends ContainerAware
*/
protected function get($id)
{
if ('request' === $id) {
@trigger_error('The "request" service is deprecated and will be removed in 3.0. Add a typehint for Symfony\\Component\\HttpFoundation\\Request to your controller parameters to retrieve the request instead.', E_USER_DEPRECATED);
}
return $this->container->get($id);
}

View File

@ -1,49 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
@trigger_error('The '.__NAMESPACE__.'\FragmentRendererPass class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass instead.', E_USER_DEPRECATED);
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
/**
* Adds services tagged kernel.fragment_renderer as HTTP content rendering strategies.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 2.7, to be removed in 3.0. Use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass instead.
*/
class FragmentRendererPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (false === $container->hasDefinition('fragment.handler')) {
return;
}
$definition = $container->getDefinition('fragment.handler');
foreach (array_keys($container->findTaggedServiceIds('kernel.fragment_renderer')) as $id) {
// We must assume that the class value has been correctly filled, even if the service is created by a factory
$class = $container->getDefinition($id)->getClass();
$refClass = new \ReflectionClass($class);
$interface = 'Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface';
if (!$refClass->implementsInterface($interface)) {
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
}
$definition->addMethodCall('addRenderer', array(new Reference($id)));
}
}
}

View File

@ -43,16 +43,6 @@ class Configuration implements ConfigurationInterface
$rootNode = $treeBuilder->root('framework');
$rootNode
// Check deprecations before the config is processed to ensure
// the setting has been explicitly defined in a configuration file.
->beforeNormalization()
->ifTrue(function ($v) { return isset($v['csrf_protection']['field_name']); })
->then(function ($v) {
@trigger_error('The framework.csrf_protection.field_name configuration key is deprecated since version 2.4 and will be removed in 3.0. Use the framework.form.csrf_protection.field_name configuration key instead', E_USER_DEPRECATED);
return $v;
})
->end()
->children()
->scalarNode('secret')->end()
->scalarNode('http_method_override')
@ -95,7 +85,6 @@ class Configuration implements ConfigurationInterface
->end()
;
$this->addCsrfSection($rootNode);
$this->addFormSection($rootNode);
$this->addEsiSection($rootNode);
$this->addSsiSection($rootNode);
@ -115,23 +104,6 @@ class Configuration implements ConfigurationInterface
return $treeBuilder;
}
private function addCsrfSection(ArrayNodeDefinition $rootNode)
{
$rootNode
->children()
->arrayNode('csrf_protection')
->canBeEnabled()
->children()
->scalarNode('field_name')
->defaultValue('_token')
->info('Deprecated since version 2.4, to be removed in 3.0. Use form.csrf_protection.field_name instead')
->end()
->end()
->end()
->end()
;
}
private function addFormSection(ArrayNodeDefinition $rootNode)
{
$rootNode
@ -141,13 +113,9 @@ class Configuration implements ConfigurationInterface
->canBeEnabled()
->children()
->arrayNode('csrf_protection')
->treatFalseLike(array('enabled' => false))
->treatTrueLike(array('enabled' => true))
->treatNullLike(array('enabled' => true))
->addDefaultsIfNotSet()
->canBeEnabled()
->children()
->booleanNode('enabled')->defaultNull()->end() // defaults to framework.csrf_protection.enabled
->scalarNode('field_name')->defaultNull()->end()
->scalarNode('field_name')->defaultValue('_token')->end()
->end()
->end()
->end()

View File

@ -97,13 +97,9 @@ class FrameworkExtension extends Extension
if (!class_exists('Symfony\Component\Validator\Validation')) {
throw new LogicException('The Validator component is required to use the Form component.');
}
if ($this->isConfigEnabled($container, $config['form']['csrf_protection'])) {
$config['csrf_protection']['enabled'] = true;
}
}
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
$this->registerSecurityCsrfConfiguration($config['form']['csrf_protection'], $container, $loader);
if (isset($config['assets'])) {
$this->registerAssetsConfiguration($config['assets'], $container, $loader);
@ -200,20 +196,12 @@ class FrameworkExtension extends Extension
private function registerFormConfiguration($config, ContainerBuilder $container, XmlFileLoader $loader)
{
$loader->load('form.xml');
if (null === $config['form']['csrf_protection']['enabled']) {
$config['form']['csrf_protection']['enabled'] = $config['csrf_protection']['enabled'];
}
if ($this->isConfigEnabled($container, $config['form']['csrf_protection'])) {
$loader->load('form_csrf.xml');
$container->setParameter('form.type_extension.csrf.enabled', true);
if (null !== $config['form']['csrf_protection']['field_name']) {
$container->setParameter('form.type_extension.csrf.field_name', $config['form']['csrf_protection']['field_name']);
} else {
$container->setParameter('form.type_extension.csrf.field_name', $config['csrf_protection']['field_name']);
}
$container->setParameter('form.type_extension.csrf.field_name', $config['form']['csrf_protection']['field_name']);
} else {
$container->setParameter('form.type_extension.csrf.enabled', false);
}

View File

@ -1,55 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Fragment;
@trigger_error('The '.__NAMESPACE__.'\ContainerAwareHIncludeFragmentRenderer class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Bundle\FrameworkBundle\Fragment\HIncludeFragmentRenderer instead.', E_USER_DEPRECATED);
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\UriSigner;
use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer;
/**
* Implements the Hinclude rendering strategy.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 2.7, to be removed in 3.0. Use Symfony\Bundle\FrameworkBundle\Fragment\HIncludeFragmentRenderer instead.
*/
class ContainerAwareHIncludeFragmentRenderer extends HIncludeFragmentRenderer
{
private $container;
/**
* {@inheritdoc}
*/
public function __construct(ContainerInterface $container, UriSigner $signer = null, $globalDefaultTemplate = null)
{
$this->container = $container;
parent::__construct(null, $signer, $globalDefaultTemplate, $container->getParameter('kernel.charset'));
}
/**
* {@inheritdoc}
*/
public function render($uri, Request $request, array $options = array())
{
// setting the templating cannot be done in the constructor
// as it would lead to an infinite recursion in the service container
if (!$this->hasTemplating()) {
$this->setTemplating($this->container->get('templating'));
}
return parent::render($uri, $request, $options);
}
}

View File

@ -20,7 +20,6 @@
<xsd:all>
<xsd:element name="assets" type="assets" minOccurs="0" maxOccurs="1" />
<xsd:element name="form" type="form" minOccurs="0" maxOccurs="1" />
<xsd:element name="csrf-protection" type="csrf_protection" minOccurs="0" maxOccurs="1" />
<xsd:element name="esi" type="esi" minOccurs="0" maxOccurs="1" />
<xsd:element name="fragments" type="fragments" minOccurs="0" maxOccurs="1" />
<xsd:element name="profiler" type="profiler" minOccurs="0" maxOccurs="1" />
@ -55,11 +54,6 @@
<xsd:attribute name="field-name" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="csrf_protection">
<xsd:attribute name="enabled" type="xsd:boolean" />
<xsd:attribute name="field-name" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="esi">
<xsd:attribute name="enabled" type="xsd:boolean" />
</xsd:complexType>

View File

@ -14,7 +14,6 @@ namespace Symfony\Bundle\FrameworkBundle\Templating;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Security\Core\SecurityContext;
/**
* GlobalVariables is the entry point for Symfony global variables in PHP templates.
@ -33,22 +32,6 @@ class GlobalVariables
$this->container = $container;
}
/**
* Returns the security context service.
*
* @deprecated since version 2.6, to be removed in 3.0.
*
* @return SecurityContext|null The security context
*/
public function getSecurity()
{
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);
if ($this->container->has('security.context')) {
return $this->container->get('security.context');
}
}
/**
* Returns the current user.
*

View File

@ -12,7 +12,6 @@
namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;
use Symfony\Component\Templating\Helper\Helper;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
/**
@ -22,26 +21,11 @@ use Symfony\Component\HttpFoundation\RequestStack;
*/
class RequestHelper extends Helper
{
protected $request;
protected $requestStack;
/**
* Constructor.
*
* @param Request|RequestStack $requestStack A RequestStack instance or a Request instance
*
* @deprecated since version 2.5, passing a Request instance is deprecated and support for it will be removed in 3.0.
*/
public function __construct($requestStack)
public function __construct(RequestStack $requestStack)
{
if ($requestStack instanceof Request) {
@trigger_error('Since version 2.5, passing a Request instance into the '.__METHOD__.' is deprecated and support for it will be removed in 3.0. Inject a Symfony\Component\HttpFoundation\RequestStack instance instead.', E_USER_DEPRECATED);
$this->request = $requestStack;
} elseif ($requestStack instanceof RequestStack) {
$this->requestStack = $requestStack;
} else {
throw new \InvalidArgumentException('RequestHelper only accepts a Request or a RequestStack instance.');
}
$this->requestStack = $requestStack;
}
/**
@ -71,15 +55,11 @@ class RequestHelper extends Helper
private function getRequest()
{
if ($this->requestStack) {
if (!$this->requestStack->getCurrentRequest()) {
throw new \LogicException('A Request must be available.');
}
return $this->requestStack->getCurrentRequest();
if (!$this->requestStack->getCurrentRequest()) {
throw new \LogicException('A Request must be available.');
}
return $this->request;
return $this->requestStack->getCurrentRequest();
}
/**

View File

@ -12,7 +12,6 @@
namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;
use Symfony\Component\Templating\Helper\Helper;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
/**
@ -25,23 +24,9 @@ class SessionHelper extends Helper
protected $session;
protected $requestStack;
/**
* Constructor.
*
* @param Request|RequestStack $requestStack A RequestStack instance or a Request instance
*
* @deprecated since version 2.5, passing a Request instance is deprecated and support for it will be removed in 3.0.
*/
public function __construct($requestStack)
public function __construct(RequestStack $requestStack)
{
if ($requestStack instanceof Request) {
@trigger_error('Since version 2.5, passing a Request instance into the '.__METHOD__.' is deprecated and support for it will be removed in 3.0. Inject a Symfony\Component\HttpFoundation\RequestStack instance instead.', E_USER_DEPRECATED);
$this->session = $requestStack->getSession();
} elseif ($requestStack instanceof RequestStack) {
$this->requestStack = $requestStack;
} else {
throw new \InvalidArgumentException('RequestHelper only accepts a Request or a RequestStack instance.');
}
$this->requestStack = $requestStack;
}
/**

View File

@ -1,112 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FragmentRendererPass;
/**
* @group legacy
*/
class LegacyFragmentRendererPassTest extends \PHPUnit_Framework_TestCase
{
/**
* Tests that content rendering not implementing FragmentRendererInterface
* trigger an exception.
*
* @expectedException \InvalidArgumentException
*/
public function testContentRendererWithoutInterface()
{
// one service, not implementing any interface
$services = array(
'my_content_renderer' => array(),
);
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
$definition->expects($this->atLeastOnce())
->method('getClass')
->will($this->returnValue('stdClass'));
$builder = $this->getMock(
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
);
$builder->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));
// We don't test kernel.fragment_renderer here
$builder->expects($this->atLeastOnce())
->method('findTaggedServiceIds')
->will($this->returnValue($services));
$builder->expects($this->atLeastOnce())
->method('getDefinition')
->will($this->returnValue($definition));
$pass = new FragmentRendererPass();
$pass->process($builder);
}
public function testValidContentRenderer()
{
$services = array(
'my_content_renderer' => array(),
);
$renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition');
$renderer
->expects($this->once())
->method('addMethodCall')
->with('addRenderer', array(new Reference('my_content_renderer')))
;
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
$definition->expects($this->atLeastOnce())
->method('getClass')
->will($this->returnValue('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\RendererService'));
$builder = $this->getMock(
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
);
$builder->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));
// We don't test kernel.fragment_renderer here
$builder->expects($this->atLeastOnce())
->method('findTaggedServiceIds')
->will($this->returnValue($services));
$builder->expects($this->atLeastOnce())
->method('getDefinition')
->will($this->onConsecutiveCalls($renderer, $definition));
$pass = new FragmentRendererPass();
$pass->process($builder);
}
}
class RendererService implements \Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface
{
public function render($uri, Request $request = null, array $options = array())
{
}
public function getName()
{
return 'test';
}
}

View File

@ -126,14 +126,10 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
'form' => array(
'enabled' => false,
'csrf_protection' => array(
'enabled' => null, // defaults to csrf_protection.enabled
'field_name' => null,
'enabled' => false,
'field_name' => '_token',
),
),
'csrf_protection' => array(
'enabled' => false,
'field_name' => '_token',
),
'esi' => array('enabled' => false),
'ssi' => array('enabled' => false),
'fragments' => array(

View File

@ -1,7 +1,6 @@
<?php
$container->loadFromExtension('framework', array(
'csrf_protection' => true,
'form' => array(
'enabled' => true,
'csrf_protection' => true,

View File

@ -1,7 +1,9 @@
<?php
$container->loadFromExtension('framework', array(
'csrf_protection' => array(
'enabled' => false,
'form' => array(
'csrf_protection' => array(
'enabled' => false,
),
),
));

View File

@ -1,7 +1,9 @@
<?php
$container->loadFromExtension('framework', array(
'csrf_protection' => array(
'enabled' => true,
'form' => array(
'csrf_protection' => array(
'enabled' => true,
),
),
));

View File

@ -1,12 +1,12 @@
<?php
$container->loadFromExtension('framework', array(
'csrf_protection' => array(
'enabled' => true,
'field_name' => '_custom',
),
'form' => array(
'enabled' => true,
'field_name' => '_custom',
'csrf_protection' => array(
'enabled' => true,
),
),
'session' => array(
'handler_id' => null,

View File

@ -1,10 +1,6 @@
<?php
$container->loadFromExtension('framework', array(
'csrf_protection' => array(
'enabled' => true,
'field_name' => '_custom',
),
'form' => array(
'enabled' => true,
'csrf_protection' => array(

View File

@ -5,14 +5,12 @@ $container->loadFromExtension('framework', array(
'default_locale' => 'fr',
'form' => array(
'csrf_protection' => array(
'enabled' => true,
'field_name' => '_csrf',
),
),
'http_method_override' => false,
'trusted_proxies' => array('127.0.0.1', '10.0.0.1'),
'csrf_protection' => array(
'enabled' => true,
),
'esi' => array(
'enabled' => true,
),

View File

@ -7,8 +7,6 @@
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:csrf-protection enabled="false" />
<framework:form>
<framework:csrf-protection />
</framework:form>

View File

@ -7,6 +7,8 @@
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:csrf-protection enabled="false" />
<framework:form>
<framework:csrf-protection enabled="false" />
</framework:form>
</framework:config>
</container>

View File

@ -7,6 +7,8 @@
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:csrf-protection />
<framework:form>
<framework:csrf-protection />
</framework:form>
</framework:config>
</container>

View File

@ -7,8 +7,9 @@
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:csrf-protection field-name="_custom" />
<framework:form />
<framework:form>
<framework:csrf-protection field-name="_custom" />
</framework:form>
<framework:session />
</framework:config>
</container>

View File

@ -7,7 +7,6 @@
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:csrf-protection field-name="_custom" />
<framework:form>
<framework:csrf-protection field-name="_custom_form" />
</framework:form>

View File

@ -7,9 +7,8 @@
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config secret="s3cr3t" ide="file%%link%%format" default-locale="fr" trusted-proxies="127.0.0.1, 10.0.0.1" http-method-override="false">
<framework:csrf-protection enabled="true" />
<framework:form>
<framework:csrf-protection field-name="_csrf"/>
<framework:csrf-protection enabled="true" field-name="_csrf"/>
</framework:form>
<framework:esi enabled="true" />
<framework:profiler only-exceptions="true" enabled="false" />

View File

@ -1,23 +0,0 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:templating assets-version="SomeVersionScheme" assets-version-format="%%s?version=%%s">
<framework:engine>php</framework:engine>
<framework:assets-base-url>http://cdn.example.com</framework:assets-base-url>
<framework:package name="images" version="1.0.0">
<framework:base-url>http://images1.example.com</framework:base-url>
<framework:base-url>http://images2.example.com</framework:base-url>
</framework:package>
<framework:package name="foo" version="1.0.0" version-format="%%s-%%s" />
<framework:package name="bar">
<framework:base-url>https://bar2.example.com</framework:base-url>
</framework:package>
</framework:templating>
</framework:config>
</container>

View File

@ -1,19 +0,0 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config secret="s3cr3t">
<framework:templating>
<framework:engine>php</framework:engine>
<framework:engine>twig</framework:engine>
<framework:assets-base-url>https://cdn.example.com</framework:assets-base-url>
<framework:package name="images">
<framework:base-url>https://images.example.com</framework:base-url>
</framework:package>
</framework:templating>
</framework:config>
</container>

View File

@ -1,8 +1,5 @@
framework:
csrf_protection: false
secret: s3cr3t
form:
csrf_protection: true
session: ~
# CSRF is disabled by default
# csrf_protection: ~

View File

@ -1,2 +1,3 @@
framework:
csrf_protection: false
form:
csrf_protection: false

View File

@ -1,2 +1,3 @@
framework:
csrf_protection: ~
form:
csrf_protection: ~

View File

@ -1,5 +0,0 @@
framework:
csrf_protection:
field_name: _custom
form: ~
session: ~

View File

@ -1,6 +1,4 @@
framework:
csrf_protection:
field_name: _custom
form:
csrf_protection:
field_name: _custom_form

View File

@ -6,8 +6,6 @@ framework:
field_name: _csrf
http_method_override: false
trusted_proxies: ['127.0.0.1', '10.0.0.1']
csrf_protection:
enabled: true
esi:
enabled: true
profiler:

View File

@ -308,20 +308,6 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]);
}
/**
* @group legacy
*/
public function testLegacyFullyConfiguredValidationService()
{
if (!extension_loaded('apc')) {
$this->markTestSkipped('The apc extension is not available.');
}
$container = $this->createContainerFromFile('full');
$this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $container->get('validator'));
}
public function testValidationService()
{
$container = $this->createContainerFromFile('validation_annotations');
@ -409,28 +395,6 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertFalse($container->getParameter('form.type_extension.csrf.enabled'));
}
/**
* @group legacy
*/
public function testLegacyFormCsrfFieldNameCanBeSetUnderCsrfSettings()
{
$container = $this->createContainerFromFile('form_csrf_sets_field_name');
$this->assertTrue($container->getParameter('form.type_extension.csrf.enabled'));
$this->assertEquals('_custom', $container->getParameter('form.type_extension.csrf.field_name'));
}
/**
* @group legacy
*/
public function testLegacyFormCsrfFieldNameUnderFormSettingsTakesPrecedence()
{
$container = $this->createContainerFromFile('form_csrf_under_form_sets_field_name');
$this->assertTrue($container->getParameter('form.type_extension.csrf.enabled'));
$this->assertEquals('_custom_form', $container->getParameter('form.type_extension.csrf.field_name'));
}
public function testStopwatchEnabledWithDebugModeEnabled()
{
$container = $this->createContainerFromFile('default_config', array(

View File

@ -1,33 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Fragment;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Bundle\FrameworkBundle\Fragment\ContainerAwareHIncludeFragmentRenderer;
use Symfony\Component\HttpFoundation\Request;
/**
* @group legacy
*/
class LegacyContainerAwareHIncludeFragmentRendererTest extends TestCase
{
public function testRender()
{
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container->expects($this->once())
->method('get')
->will($this->returnValue($this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock()))
;
$renderer = new ContainerAwareHIncludeFragmentRenderer($container);
$renderer->render('/', Request::create('/'));
}
}

View File

@ -1,10 +1,10 @@
framework:
secret: test
csrf_protection:
enabled: true
router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" }
validation: { enabled: true, enable_annotations: true }
form: ~
form:
csrf_protection:
enabled: true
test: ~
default_locale: en
session:

View File

@ -26,18 +26,6 @@ class GlobalVariablesTest extends TestCase
$this->globals = new GlobalVariables($this->container);
}
/**
* @group legacy
*/
public function testLegacyGetSecurity()
{
$securityContext = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
$this->assertNull($this->globals->getSecurity());
$this->container->set('security.context', $securityContext);
$this->assertSame($securityContext, $this->globals->getSecurity());
}
public function testGetUserNoTokenStorage()
{
$this->assertNull($this->globals->getUser());

View File

@ -10,11 +10,6 @@
</parameters>
<services>
<service id="security.context" class="Symfony\Component\Security\Core\SecurityContext">
<argument type="service" id="security.token_storage" />
<argument type="service" id="security.authorization_checker" />
</service>
<service id="security.authorization_checker" class="Symfony\Component\Security\Core\Authorization\AuthorizationChecker">
<argument type="service" id="security.token_storage" />
<argument type="service" id="security.authentication.manager" />

View File

@ -40,24 +40,6 @@ class SecurityDataCollectorTest extends \PHPUnit_Framework_TestCase
$this->assertEmpty($collector->getUser());
}
/**
* @group legacy
*/
public function testLegacyCollectWhenAuthenticationTokenIsNull()
{
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
$collector = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy());
$collector->collect($this->getRequest(), $this->getResponse());
$this->assertTrue($collector->isEnabled());
$this->assertFalse($collector->isAuthenticated());
$this->assertNull($collector->getTokenClass());
$this->assertTrue($collector->supportsRoleHierarchy());
$this->assertCount(0, $collector->getRoles());
$this->assertCount(0, $collector->getInheritedRoles());
$this->assertEmpty($collector->getUser());
}
/** @dataProvider provideRoles */
public function testCollectAuthenticationTokenAndRoles(array $roles, array $normalizedRoles, array $inheritedRoles)
{

View File

@ -1,10 +1,10 @@
framework:
secret: test
csrf_protection:
enabled: true
router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" }
validation: { enabled: true, enable_annotations: true }
form: ~
form:
csrf_protection:
enabled: true
test: ~
default_locale: en
session:

View File

@ -1,11 +1,11 @@
framework:
secret: test
csrf_protection:
enabled: true
router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" }
validation: { enabled: true, enable_annotations: true }
assets: ~
form: ~
form:
csrf_protection:
enabled: true
test: ~
default_locale: en
session: