This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
Fabien Potencier 842cba1d0c Merge branch '2.5'
* 2.5:
  Remove aligned '=>' and '='
  Break infinite loop while resolving aliases
  [Security][listener] change priority of switchuser
  Improved the phpdoc for security token classes
  bumped Symfony version to 2.5.7
  updated VERSION for 2.5.6
  updated CHANGELOG for 2.5.6
  bumped Symfony version to 2.3.22
  updated VERSION for 2.3.21
  update CONTRIBUTORS for 2.3.21
  updated CHANGELOG for 2.3.21

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
	src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php
	src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php
	src/Symfony/Component/Debug/ErrorHandler.php
	src/Symfony/Component/Debug/ExceptionHandler.php
	src/Symfony/Component/Form/Extension/Core/Type/BaseType.php
	src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
	src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php
	src/Symfony/Component/Form/Extension/Core/Type/DateType.php
	src/Symfony/Component/Form/Extension/Core/Type/TimeType.php
	src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php
	src/Symfony/Component/HttpFoundation/Request.php
	src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php
	src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php
	src/Symfony/Component/HttpKernel/Kernel.php
	src/Symfony/Component/Security/Core/SecurityContextInterface.php
	src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationFailureHandler.php
	src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php
	src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php
	src/Symfony/Component/Serializer/Serializer.php
	src/Symfony/Component/Validator/Constraints/File.php
2014-10-26 08:46:28 +01:00

151 lines
5.0 KiB
PHP

<?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;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration;
use Symfony\Component\Config\Definition\Processor;
class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
public function testDefaultConfig()
{
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(true), array(array('secret' => 's3cr3t')));
$this->assertEquals(
array_merge(array('secret' => 's3cr3t', 'trusted_hosts' => array()), self::getBundleDefaultConfig()),
$config
);
}
/**
* @dataProvider getTestValidTrustedProxiesData
*/
public function testValidTrustedProxies($trustedProxies, $processedProxies)
{
$processor = new Processor();
$configuration = new Configuration(true);
$config = $processor->processConfiguration($configuration, array(array(
'secret' => 's3cr3t',
'trusted_proxies' => $trustedProxies,
)));
$this->assertEquals($processedProxies, $config['trusted_proxies']);
}
public function getTestValidTrustedProxiesData()
{
return array(
array(array('127.0.0.1'), array('127.0.0.1')),
array(array('::1'), array('::1')),
array(array('127.0.0.1', '::1'), array('127.0.0.1', '::1')),
array(null, array()),
array(false, array()),
array(array(), array()),
array(array('10.0.0.0/8'), array('10.0.0.0/8')),
array(array('::ffff:0:0/96'), array('::ffff:0:0/96')),
);
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*/
public function testInvalidTypeTrustedProxies()
{
$processor = new Processor();
$configuration = new Configuration(true);
$processor->processConfiguration($configuration, array(
array(
'secret' => 's3cr3t',
'trusted_proxies' => 'Not an IP address',
),
));
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*/
public function testInvalidValueTrustedProxies()
{
$processor = new Processor();
$configuration = new Configuration(true);
$processor->processConfiguration($configuration, array(
array(
'secret' => 's3cr3t',
'trusted_proxies' => array('Not an IP address'),
),
));
}
protected static function getBundleDefaultConfig()
{
return array(
'http_method_override' => true,
'trusted_proxies' => array(),
'ide' => null,
'default_locale' => 'en',
'form' => array(
'enabled' => false,
'csrf_protection' => array(
'enabled' => null, // defaults to csrf_protection.enabled
'field_name' => null,
),
),
'csrf_protection' => array(
'enabled' => false,
'field_name' => '_token',
),
'esi' => array('enabled' => false),
'ssi' => array('enabled' => false),
'fragments' => array(
'enabled' => false,
'path' => '/_fragment',
),
'profiler' => array(
'enabled' => false,
'only_exceptions' => false,
'only_master_requests' => false,
'dsn' => 'file:%kernel.cache_dir%/profiler',
'username' => '',
'password' => '',
'lifetime' => 86400,
'collect' => true,
),
'translator' => array(
'enabled' => false,
'fallback' => 'en',
'logging' => true,
),
'validation' => array(
'enabled' => false,
'enable_annotations' => false,
'static_method' => array('loadValidatorMetadata'),
'translation_domain' => 'validators',
'strict_email' => false,
'api' => version_compare(PHP_VERSION, '5.3.9', '<') ? '2.4' : '2.5-bc',
),
'annotations' => array(
'cache' => 'file',
'file_cache_dir' => '%kernel.cache_dir%/annotations',
'debug' => '%kernel.debug%',
),
'serializer' => array(
'enabled' => false,
),
'property_access' => array(
'magic_call' => false,
'throw_exception_on_invalid_index' => false,
),
);
}
}