Merge branch '2.6' into 2.7
* 2.6: [2.3] Remove useless tests skips [ClassLoader] removes deprecated classes from documentation. [ClassLoader] added missing deprecation notice. [HttpFoundation] Fix an issue caused by php's Bug #66606. [Yaml] Update README.md Don't add Accept-Range header on unsafe HTTP requests simplify hasScheme method adapted merge to 2.5 adapted previous commit for 2.3 [Security] Don't send remember cookie for sub request [Security] fixed wrong phpdoc [HttpKernel] Fix UriSigner::check when _hash is not at the end of the uri [2.3] Cleanup deprecations Conflicts: src/Symfony/Bridge/Twig/composer.json src/Symfony/Bundle/FrameworkBundle/composer.json src/Symfony/Bundle/TwigBundle/composer.json src/Symfony/Component/ClassLoader/UniversalClassLoader.php src/Symfony/Component/Debug/composer.json src/Symfony/Component/Form/ButtonBuilder.php src/Symfony/Component/HttpKernel/Exception/FatalErrorException.php src/Symfony/Component/HttpKernel/Exception/FlattenException.php src/Symfony/Component/HttpKernel/composer.json src/Symfony/Component/Security/composer.json src/Symfony/Component/Validator/composer.json
This commit is contained in:
commit
ad84fb78e1
@ -16,7 +16,7 @@ use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
||||
/**
|
||||
* Class DoctrineOrmTestCase.
|
||||
*
|
||||
* @deprecated Deprecated as of Symfony 2.4, to be removed in Symfony 3.0.
|
||||
* @deprecated Deprecated as of Symfony 2.3, to be removed in Symfony 3.0.
|
||||
* Use {@link DoctrineTestHelper} instead.
|
||||
*/
|
||||
abstract class DoctrineOrmTestCase extends \PHPUnit_Framework_TestCase
|
||||
|
@ -36,22 +36,6 @@ abstract class AbstractEntityChoiceListTest extends AbstractChoiceListTest
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('Symfony\Component\Form\Form')) {
|
||||
$this->markTestSkipped('The "Form" component is not available');
|
||||
}
|
||||
|
||||
if (!class_exists('Doctrine\DBAL\Platforms\MySqlPlatform')) {
|
||||
$this->markTestSkipped('Doctrine DBAL is not available.');
|
||||
}
|
||||
|
||||
if (!class_exists('Doctrine\Common\Version')) {
|
||||
$this->markTestSkipped('Doctrine Common is not available.');
|
||||
}
|
||||
|
||||
if (!class_exists('Doctrine\ORM\EntityManager')) {
|
||||
$this->markTestSkipped('Doctrine ORM is not available.');
|
||||
}
|
||||
|
||||
$this->em = DoctrineTestHelper::createTestEntityManager();
|
||||
|
||||
$schemaTool = new SchemaTool($this->em);
|
||||
|
@ -36,22 +36,6 @@ class GenericEntityChoiceListTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('Symfony\Component\Form\Form')) {
|
||||
$this->markTestSkipped('The "Form" component is not available');
|
||||
}
|
||||
|
||||
if (!class_exists('Doctrine\DBAL\Platforms\MySqlPlatform')) {
|
||||
$this->markTestSkipped('Doctrine DBAL is not available.');
|
||||
}
|
||||
|
||||
if (!class_exists('Doctrine\Common\Version')) {
|
||||
$this->markTestSkipped('Doctrine Common is not available.');
|
||||
}
|
||||
|
||||
if (!class_exists('Doctrine\ORM\EntityManager')) {
|
||||
$this->markTestSkipped('Doctrine ORM is not available.');
|
||||
}
|
||||
|
||||
$this->em = DoctrineTestHelper::createTestEntityManager();
|
||||
|
||||
$schemaTool = new SchemaTool($this->em);
|
||||
|
@ -12,10 +12,10 @@
|
||||
namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList;
|
||||
|
||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
|
||||
use Symfony\Bridge\Doctrine\Tests\DoctrineOrmTestCase;
|
||||
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
||||
use Doctrine\DBAL\Connection;
|
||||
|
||||
class ORMQueryBuilderLoaderTest extends DoctrineOrmTestCase
|
||||
class ORMQueryBuilderLoaderTest extends DoctrineTestHelper
|
||||
{
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
|
||||
|
@ -14,7 +14,7 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\Type;
|
||||
use Symfony\Component\Form\Test\FormPerformanceTestCase;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
|
||||
use Doctrine\ORM\Tools\SchemaTool;
|
||||
use Symfony\Bridge\Doctrine\Tests\DoctrineOrmTestCase;
|
||||
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
||||
use Symfony\Component\Form\Extension\Core\CoreExtension;
|
||||
use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension;
|
||||
|
||||
@ -50,7 +50,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->em = DoctrineOrmTestCase::createTestEntityManager();
|
||||
$this->em = DoctrineTestHelper::createTestEntityManager();
|
||||
|
||||
parent::setUp();
|
||||
|
||||
|
@ -43,22 +43,6 @@ class EntityTypeTest extends TypeTestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('Symfony\Component\Form\Form')) {
|
||||
$this->markTestSkipped('The "Form" component is not available');
|
||||
}
|
||||
|
||||
if (!class_exists('Doctrine\DBAL\Platforms\MySqlPlatform')) {
|
||||
$this->markTestSkipped('Doctrine DBAL is not available.');
|
||||
}
|
||||
|
||||
if (!class_exists('Doctrine\Common\Version')) {
|
||||
$this->markTestSkipped('Doctrine Common is not available.');
|
||||
}
|
||||
|
||||
if (!class_exists('Doctrine\ORM\EntityManager')) {
|
||||
$this->markTestSkipped('Doctrine ORM is not available.');
|
||||
}
|
||||
|
||||
$this->em = DoctrineTestHelper::createTestEntityManager();
|
||||
$this->emRegistry = $this->createRegistryMock('default', $this->em);
|
||||
|
||||
|
@ -21,23 +21,6 @@ class CompatModelChoiceListTest extends AbstractChoiceListTest
|
||||
protected $item3;
|
||||
protected $item4;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
if (!class_exists('\Propel')) {
|
||||
self::markTestSkipped('Propel is not available.');
|
||||
}
|
||||
|
||||
if (!class_exists('Symfony\Component\Form\Form')) {
|
||||
self::markTestSkipped('The "Form" component is not available');
|
||||
}
|
||||
|
||||
if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) {
|
||||
self::markTestSkipped('The "PropertyAccessor" component is not available');
|
||||
}
|
||||
|
||||
parent::setUpBeforeClass();
|
||||
}
|
||||
|
||||
public function testGetChoicesForValues()
|
||||
{
|
||||
$this->query
|
||||
|
@ -22,19 +22,6 @@ class ModelChoiceListTest extends Propel1TestCase
|
||||
{
|
||||
const ITEM_CLASS = '\Symfony\Bridge\Propel1\Tests\Fixtures\Item';
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
if (!class_exists('Symfony\Component\Form\Form')) {
|
||||
self::markTestSkipped('The "Form" component is not available');
|
||||
}
|
||||
|
||||
if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) {
|
||||
self::markTestSkipped('The "PropertyAccessor" component is not available');
|
||||
}
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
ItemQuery::$result = array();
|
||||
|
@ -24,7 +24,7 @@
|
||||
"symfony/finder": "~2.3|~3.0.0",
|
||||
"symfony/form": "~2.6|~3.0.0",
|
||||
"symfony/http-kernel": "~2.3|~3.0.0",
|
||||
"symfony/locale": "~2.0,>=2.0.5|~3.0.0",
|
||||
"symfony/intl": "~2.3|~3.0.0",
|
||||
"symfony/routing": "~2.2|~3.0.0",
|
||||
"symfony/templating": "~2.1|~3.0.0",
|
||||
"symfony/translation": "~2.2|~3.0.0",
|
||||
|
@ -64,7 +64,11 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
||||
|
||||
protected function renderEnctype(FormView $view)
|
||||
{
|
||||
return (string) $this->engine->get('form')->enctype($view);
|
||||
if (!method_exists($form = $this->engine->get('form'), 'enctype')) {
|
||||
$this->markTestSkipped(sprintf("Deprecated method %s->enctype() is not implemented.", get_class($form)));
|
||||
}
|
||||
|
||||
return (string) $form->enctype($view);
|
||||
}
|
||||
|
||||
protected function renderLabel(FormView $view, $label = null, array $vars = array())
|
||||
|
@ -65,7 +65,11 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest
|
||||
|
||||
protected function renderEnctype(FormView $view)
|
||||
{
|
||||
return (string) $this->engine->get('form')->enctype($view);
|
||||
if (!method_exists($form = $this->engine->get('form'), 'enctype')) {
|
||||
$this->markTestSkipped(sprintf("Deprecated method %s->enctype() is not implemented.", get_class($form)));
|
||||
}
|
||||
|
||||
return (string) $form->enctype($view);
|
||||
}
|
||||
|
||||
protected function renderLabel(FormView $view, $label = null, array $vars = array())
|
||||
|
@ -37,7 +37,7 @@
|
||||
"symfony/css-selector": "~2.0,>=2.0.5|~3.0.0",
|
||||
"symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0",
|
||||
"symfony/finder": "~2.0,>=2.0.5|~3.0.0",
|
||||
"symfony/locale": "~2.0,>=2.0.5|~3.0.0",
|
||||
"symfony/intl": "~2.3|~3.0.0",
|
||||
"symfony/security": "~2.6|~3.0.0",
|
||||
"symfony/form": "~2.6|~3.0.0",
|
||||
"symfony/class-loader": "~2.1|~3.0.0",
|
||||
|
@ -20,7 +20,7 @@ class ExceptionControllerTest extends TestCase
|
||||
{
|
||||
public function testOnlyClearOwnOutputBuffers()
|
||||
{
|
||||
$flatten = $this->getMock('Symfony\Component\HttpKernel\Exception\FlattenException');
|
||||
$flatten = $this->getMock('Symfony\Component\Debug\Exception\FlattenException');
|
||||
$flatten
|
||||
->expects($this->once())
|
||||
->method('getStatusCode')
|
||||
|
@ -19,7 +19,7 @@
|
||||
"php": ">=5.3.3",
|
||||
"symfony/twig-bridge": "~2.6|~3.0.0",
|
||||
"symfony/http-foundation": "~2.5|~3.0.0",
|
||||
"symfony/http-kernel": "~2.1|~3.0.0"
|
||||
"symfony/http-kernel": "~2.3,>=2.3.24|~3.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/stopwatch": "~2.2|~3.0.0",
|
||||
|
@ -17,11 +17,19 @@ namespace Symfony\Component\ClassLoader;
|
||||
* It expects an object implementing a findFile method to find the file. This
|
||||
* allows using it as a wrapper around the other loaders of the component (the
|
||||
* ClassLoader and the UniversalClassLoader for instance) but also around any
|
||||
* other autoloader following this convention (the Composer one for instance)
|
||||
* other autoloaders following this convention (the Composer one for instance).
|
||||
*
|
||||
* // with a Symfony autoloader
|
||||
* use Symfony\Component\ClassLoader\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->addPrefix('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* // or with a Composer autoloader
|
||||
* use Composer\Autoload\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
|
@ -59,6 +59,8 @@ namespace Symfony\Component\ClassLoader;
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @deprecated Deprecated since version 2.4, to be removed in 3.0. Use the ApcClassLoader class instead.
|
||||
*/
|
||||
class ApcUniversalClassLoader extends UniversalClassLoader
|
||||
{
|
||||
|
@ -9,6 +9,9 @@ CHANGELOG
|
||||
2.4.0
|
||||
-----
|
||||
|
||||
* deprecated the UniversalClassLoader in favor of the ClassLoader class instead
|
||||
* deprecated the ApcUniversalClassLoader in favor of the ApcClassLoader class instead
|
||||
* deprecated the DebugUniversalClassLoader in favor of the DebugClassLoader class from the Debug component
|
||||
* deprecated the DebugClassLoader as it has been moved to the Debug component instead
|
||||
|
||||
2.3.0
|
||||
|
@ -15,6 +15,8 @@ namespace Symfony\Component\ClassLoader;
|
||||
* Checks that the class is actually declared in the included file.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated Deprecated since version 2.4, to be removed in 3.0. Use the DebugClassLoader provided by the Debug component instead.
|
||||
*/
|
||||
class DebugUniversalClassLoader extends UniversalClassLoader
|
||||
{
|
||||
|
@ -4,34 +4,34 @@ ClassLoader Component
|
||||
ClassLoader loads your project classes automatically if they follow some
|
||||
standard PHP conventions.
|
||||
|
||||
The Universal ClassLoader is able to autoload classes that implement the PSR-0
|
||||
The ClassLoader object is able to autoload classes that implement the PSR-0
|
||||
standard or the PEAR naming convention.
|
||||
|
||||
First, register the autoloader:
|
||||
|
||||
```php
|
||||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
|
||||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php';
|
||||
|
||||
use Symfony\Component\ClassLoader\UniversalClassLoader;
|
||||
use Symfony\Component\ClassLoader\ClassLoader;
|
||||
|
||||
$loader = new UniversalClassLoader();
|
||||
$loader = new ClassLoader();
|
||||
$loader->register();
|
||||
```
|
||||
|
||||
Then, register some namespaces with the `registerNamespace()` method:
|
||||
Then, register some namespaces with the `addPrefix()` method:
|
||||
|
||||
```php
|
||||
$loader->registerNamespace('Symfony', __DIR__.'/src');
|
||||
$loader->registerNamespace('Monolog', __DIR__.'/vendor/monolog/src');
|
||||
$loader->addPrefix('Symfony', __DIR__.'/src');
|
||||
$loader->addPrefix('Monolog', __DIR__.'/vendor/monolog/src');
|
||||
```
|
||||
|
||||
The `registerNamespace()` method takes a namespace prefix and a path where to
|
||||
The `addPrefix()` method takes a namespace prefix and a path where to
|
||||
look for the classes as arguments.
|
||||
|
||||
You can also register a sub-namespaces:
|
||||
|
||||
```php
|
||||
$loader->registerNamespace('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib');
|
||||
$loader->addPrefix('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib');
|
||||
```
|
||||
|
||||
The order of registration is significant and the first registered namespace
|
||||
@ -40,14 +40,14 @@ takes precedence over later registered one.
|
||||
You can also register more than one path for a given namespace:
|
||||
|
||||
```php
|
||||
$loader->registerNamespace('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src'));
|
||||
$loader->addPrefix('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src'));
|
||||
```
|
||||
|
||||
Alternatively, you can use the `registerNamespaces()` method to register more
|
||||
Alternatively, you can use the `addPrefixes()` method to register more
|
||||
than one namespace at once:
|
||||
|
||||
```php
|
||||
$loader->registerNamespaces(array(
|
||||
$loader->addPrefixes(array(
|
||||
'Symfony' => array(__DIR__.'/src', __DIR__.'/symfony/src'),
|
||||
'Doctrine\\Common' => __DIR__.'/vendor/doctrine-common/lib',
|
||||
'Doctrine' => __DIR__.'/vendor/doctrine/lib',
|
||||
@ -55,16 +55,20 @@ $loader->registerNamespaces(array(
|
||||
));
|
||||
```
|
||||
|
||||
For better performance, you can use the APC based version of the universal
|
||||
class loader:
|
||||
For better performance, you can use the APC class loader:
|
||||
|
||||
```php
|
||||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
|
||||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php';
|
||||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php';
|
||||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcClassLoader.php';
|
||||
|
||||
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
|
||||
use Symfony\Component\ClassLoader\ClassLoader;
|
||||
use Symfony\Component\ClassLoader\ApcClassLoader;
|
||||
|
||||
$loader = new ApcUniversalClassLoader('apc.prefix.');
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefix('Symfony', __DIR__.'/src');
|
||||
|
||||
$loader = new ApcClassLoader('apc.prefix.', $loader);
|
||||
$loader->register();
|
||||
```
|
||||
|
||||
Furthermore, the component provides tools to aggregate classes into a single
|
||||
|
@ -60,7 +60,7 @@ trigger_error('The "Symfony\Component\ClassLoader\UniversalClassLoader" class wa
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @deprecated Deprecated since version 2.7, to be removed in 3.0. Use the ClassLoader class instead.
|
||||
* @deprecated Deprecated since version 2.4, to be removed in 3.0. Use the ClassLoader class instead.
|
||||
*/
|
||||
class UniversalClassLoader
|
||||
{
|
||||
|
@ -17,11 +17,19 @@ namespace Symfony\Component\ClassLoader;
|
||||
* It expects an object implementing a findFile method to find the file. This
|
||||
* allow using it as a wrapper around the other loaders of the component (the
|
||||
* ClassLoader and the UniversalClassLoader for instance) but also around any
|
||||
* other autoloader following this convention (the Composer one for instance)
|
||||
* other autoloaders following this convention (the Composer one for instance).
|
||||
*
|
||||
* // with a Symfony autoloader
|
||||
* use Symfony\Component\ClassLoader\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->addPrefix('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* // or with a Composer autoloader
|
||||
* use Composer\Autoload\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
|
@ -17,11 +17,19 @@ namespace Symfony\Component\ClassLoader;
|
||||
* It expects an object implementing a findFile method to find the file. This
|
||||
* allows using it as a wrapper around the other loaders of the component (the
|
||||
* ClassLoader and the UniversalClassLoader for instance) but also around any
|
||||
* other autoloader following this convention (the Composer one for instance)
|
||||
* other autoloaders following this convention (the Composer one for instance).
|
||||
*
|
||||
* // with a Symfony autoloader
|
||||
* use Symfony\Component\ClassLoader\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->addPrefix('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* // or with a Composer autoloader
|
||||
* use Composer\Autoload\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
|
@ -480,8 +480,10 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testAsText()
|
||||
public function testLegacyAsText()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||
|
||||
$application = new Application();
|
||||
$application->add(new \FooCommand());
|
||||
$this->ensureStaticCommandHelp($application);
|
||||
@ -489,8 +491,10 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_astext2.txt', $this->normalizeLineBreaks($application->asText('foo')), '->asText() returns a text representation of the application');
|
||||
}
|
||||
|
||||
public function testAsXml()
|
||||
public function testLegacyAsXml()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||
|
||||
$application = new Application();
|
||||
$application->add(new \FooCommand());
|
||||
$this->ensureStaticCommandHelp($application);
|
||||
|
@ -318,8 +318,10 @@ class CommandTest extends \PHPUnit_Framework_TestCase
|
||||
$output->writeln('from the code...');
|
||||
}
|
||||
|
||||
public function testAsText()
|
||||
public function testLegacyAsText()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication(new Application());
|
||||
$tester = new CommandTester($command);
|
||||
@ -327,8 +329,10 @@ class CommandTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/command_astext.txt', $command->asText(), '->asText() returns a text representation of the command');
|
||||
}
|
||||
|
||||
public function testAsXml()
|
||||
public function testLegacyAsXml()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication(new Application());
|
||||
$tester = new CommandTester($command);
|
||||
|
@ -373,8 +373,10 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('foo1 ... [fooN]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
|
||||
}
|
||||
|
||||
public function testAsText()
|
||||
public function testLegacyAsText()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||
|
||||
$definition = new InputDefinition(array(
|
||||
new InputArgument('foo', InputArgument::OPTIONAL, 'The foo argument'),
|
||||
new InputArgument('baz', InputArgument::OPTIONAL, 'The baz argument', true),
|
||||
@ -388,8 +390,10 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertStringEqualsFile(self::$fixtures.'/definition_astext.txt', $definition->asText(), '->asText() returns a textual representation of the InputDefinition');
|
||||
}
|
||||
|
||||
public function testAsXml()
|
||||
public function testLegacyAsXml()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||
|
||||
$definition = new InputDefinition(array(
|
||||
new InputArgument('foo', InputArgument::OPTIONAL, 'The foo argument'),
|
||||
new InputArgument('baz', InputArgument::OPTIONAL, 'The baz argument', true),
|
||||
@ -398,7 +402,7 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
new InputOption('baz', null, InputOption::VALUE_OPTIONAL, 'The baz option', false),
|
||||
new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL, 'The bar option', 'bar'),
|
||||
));
|
||||
$this->assertXmlStringEqualsXmlFile(self::$fixtures.'/definition_asxml.txt', $definition->asXml(), '->asText() returns a textual representation of the InputDefinition');
|
||||
$this->assertXmlStringEqualsXmlFile(self::$fixtures.'/definition_asxml.txt', $definition->asXml(), '->asXml() returns an XML representation of the InputDefinition');
|
||||
}
|
||||
|
||||
protected function initializeArguments()
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Debug\Exception;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
|
||||
|
||||
/**
|
||||
* Fatal Error Exception.
|
||||
*
|
||||
@ -18,6 +20,19 @@ namespace Symfony\Component\Debug\Exception;
|
||||
* @author Konstanton Myakshin <koc-dp@yandex.ru>
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class FatalErrorException extends LegacyFatalErrorException
|
||||
{
|
||||
}
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Exception;
|
||||
|
||||
/**
|
||||
* Fatal Error Exception.
|
||||
*
|
||||
* @author Konstanton Myakshin <koc-dp@yandex.ru>
|
||||
*
|
||||
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
|
||||
*/
|
||||
class FatalErrorException extends \ErrorException
|
||||
{
|
||||
public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true)
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Debug\Exception;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\FlattenException as LegacyFlattenException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
|
||||
/**
|
||||
@ -20,7 +21,7 @@ use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class FlattenException
|
||||
class FlattenException extends LegacyFlattenException
|
||||
{
|
||||
private $message;
|
||||
private $code;
|
||||
@ -249,3 +250,35 @@ class FlattenException
|
||||
return $array['__PHP_Incomplete_Class_Name'];
|
||||
}
|
||||
}
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Exception;
|
||||
|
||||
use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
|
||||
|
||||
/**
|
||||
* FlattenException wraps a PHP Exception to be able to serialize it.
|
||||
*
|
||||
* Basically, this class removes all objects from the trace.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
|
||||
*/
|
||||
class FlattenException
|
||||
{
|
||||
private $handler;
|
||||
|
||||
public static function __callStatic($method, $args)
|
||||
{
|
||||
return forward_static_call_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args);
|
||||
}
|
||||
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (!isset($this->handler)) {
|
||||
$this->handler = new DebugFlattenException();
|
||||
}
|
||||
|
||||
return call_user_func_array(array($this->handler, $method), $args);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/class-loader": "~2.2",
|
||||
"symfony/http-kernel": "~2.2|~3.0.0",
|
||||
"symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2|~3.0.0",
|
||||
"symfony/http-foundation": "~2.1|~3.0.0"
|
||||
},
|
||||
"suggest": {
|
||||
|
@ -386,6 +386,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
|
||||
* @param bool $virtual
|
||||
*
|
||||
* @throws BadMethodCallException
|
||||
*
|
||||
* @deprecated since version 2.3, to be removed in 3.0. Use
|
||||
* {@link setInheritData()} instead.
|
||||
*/
|
||||
public function setVirtual($virtual)
|
||||
{
|
||||
@ -589,8 +592,8 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
|
||||
*
|
||||
* @return bool Always returns false.
|
||||
*
|
||||
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use
|
||||
* {@link getInheritData()} instead.
|
||||
* @deprecated since version 2.3, to be removed in 3.0. Use
|
||||
* {@link getInheritData()} instead.
|
||||
*/
|
||||
public function getVirtual()
|
||||
{
|
||||
|
@ -13,6 +13,9 @@ namespace Symfony\Component\Form\Test;
|
||||
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.3, to be removed in 3.0.
|
||||
*/
|
||||
class DeprecationErrorHandler
|
||||
{
|
||||
public static function handle($errorNumber, $message, $file, $line, $context)
|
||||
|
@ -101,7 +101,10 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
|
||||
abstract protected function renderForm(FormView $view, array $vars = array());
|
||||
|
||||
abstract protected function renderEnctype(FormView $view);
|
||||
protected function renderEnctype(FormView $view)
|
||||
{
|
||||
$this->markTestSkipped(sprintf('Legacy %s::renderEnctype() is not implemented.', get_class($this)));
|
||||
}
|
||||
|
||||
abstract protected function renderLabel(FormView $view, $label = null, array $vars = array());
|
||||
|
||||
@ -119,8 +122,10 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
|
||||
abstract protected function setTheme(FormView $view, array $themes);
|
||||
|
||||
public function testEnctype()
|
||||
public function testLegacyEnctype()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$form = $this->factory->createNamedBuilder('name', 'form')
|
||||
->add('file', 'file')
|
||||
->getForm();
|
||||
@ -128,8 +133,10 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
$this->assertEquals('enctype="multipart/form-data"', $this->renderEnctype($form->createView()));
|
||||
}
|
||||
|
||||
public function testNoEnctype()
|
||||
public function testLegacyNoEnctype()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$form = $this->factory->createNamedBuilder('name', 'form')
|
||||
->add('text', 'text')
|
||||
->getForm();
|
||||
|
@ -15,14 +15,13 @@ use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestLis
|
||||
use Symfony\Component\Form\Form;
|
||||
use Symfony\Component\Form\FormConfigBuilder;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\Test\DeprecationErrorHandler;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class BindRequestListenerTest extends \PHPUnit_Framework_TestCase
|
||||
class LegacyBindRequestListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $values;
|
||||
|
||||
@ -37,6 +36,8 @@ class BindRequestListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$path = tempnam(sys_get_temp_dir(), 'sf2');
|
||||
touch($path);
|
||||
|
||||
@ -98,7 +99,7 @@ class BindRequestListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$event = new FormEvent($form, $request);
|
||||
|
||||
$listener = new BindRequestListener();
|
||||
DeprecationErrorHandler::preBind($listener, $event);
|
||||
$listener->preBind($event);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'name' => 'Bernhard',
|
||||
@ -121,7 +122,7 @@ class BindRequestListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$event = new FormEvent($form, $request);
|
||||
|
||||
$listener = new BindRequestListener();
|
||||
DeprecationErrorHandler::preBind($listener, $event);
|
||||
$listener->preBind($event);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'name' => 'Bernhard',
|
||||
@ -146,7 +147,7 @@ class BindRequestListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$event = new FormEvent($form, $request);
|
||||
|
||||
$listener = new BindRequestListener();
|
||||
DeprecationErrorHandler::preBind($listener, $event);
|
||||
$listener->preBind($event);
|
||||
|
||||
// Default to empty array
|
||||
$this->assertEquals(array(), $event->getData());
|
||||
@ -168,7 +169,7 @@ class BindRequestListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$event = new FormEvent($form, $request);
|
||||
|
||||
$listener = new BindRequestListener();
|
||||
DeprecationErrorHandler::preBind($listener, $event);
|
||||
$listener->preBind($event);
|
||||
|
||||
// Default to null
|
||||
$this->assertNull($event->getData());
|
||||
@ -187,7 +188,7 @@ class BindRequestListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$event = new FormEvent($form, $request);
|
||||
|
||||
$listener = new BindRequestListener();
|
||||
DeprecationErrorHandler::preBind($listener, $event);
|
||||
$listener->preBind($event);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'name' => 'Bernhard',
|
||||
@ -207,7 +208,7 @@ class BindRequestListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$event = new FormEvent($form, $request);
|
||||
|
||||
$listener = new BindRequestListener();
|
||||
DeprecationErrorHandler::preBind($listener, $event);
|
||||
$listener->preBind($event);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'name' => 'Bernhard',
|
||||
@ -229,7 +230,7 @@ class BindRequestListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$event = new FormEvent($form, $request);
|
||||
|
||||
$listener = new BindRequestListener();
|
||||
DeprecationErrorHandler::preBind($listener, $event);
|
||||
$listener->preBind($event);
|
||||
|
||||
$this->assertEquals(array(), $event->getData());
|
||||
}
|
||||
@ -247,7 +248,7 @@ class BindRequestListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$event = new FormEvent($form, $request);
|
||||
|
||||
$listener = new BindRequestListener();
|
||||
DeprecationErrorHandler::preBind($listener, $event);
|
||||
$listener->preBind($event);
|
||||
|
||||
$this->assertNull($event->getData());
|
||||
}
|
@ -50,10 +50,6 @@ class ValidatorTypeGuesserTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('Symfony\Component\Validator\Constraint')) {
|
||||
$this->markTestSkipped('The "Validator" component is not available');
|
||||
}
|
||||
|
||||
$this->metadata = new ClassMetadata(self::TEST_CLASS);
|
||||
$this->metadataFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface');
|
||||
$this->metadataFactory->expects($this->any())
|
||||
|
@ -57,10 +57,6 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGetOptionsResolver()
|
||||
{
|
||||
if (version_compare(\PHPUnit_Runner_Version::id(), '3.7', '<')) {
|
||||
$this->markTestSkipped('This test requires PHPUnit 3.7.');
|
||||
}
|
||||
|
||||
$test = $this;
|
||||
$i = 0;
|
||||
|
||||
|
@ -170,7 +170,11 @@ class BinaryFileResponse extends Response
|
||||
public function prepare(Request $request)
|
||||
{
|
||||
$this->headers->set('Content-Length', $this->file->getSize());
|
||||
$this->headers->set('Accept-Ranges', 'bytes');
|
||||
|
||||
if (!$this->headers->has('Accept-Ranges')) {
|
||||
// Only accept ranges on safe HTTP methods
|
||||
$this->headers->set('Accept-Ranges', $request->isMethodSafe() ? 'bytes' : 'none');
|
||||
}
|
||||
|
||||
if (!$this->headers->has('Content-Type')) {
|
||||
$this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream');
|
||||
|
@ -279,7 +279,20 @@ class Request
|
||||
*/
|
||||
public static function createFromGlobals()
|
||||
{
|
||||
$request = self::createRequestFromFactory($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
|
||||
// With the php's bug #66606, the php's built-in web server
|
||||
// stores the Content-Type and Content-Length header values in
|
||||
// HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH fields.
|
||||
$server = $_SERVER;
|
||||
if ('cli-server' === php_sapi_name()) {
|
||||
if (array_key_exists('HTTP_CONTENT_LENGTH', $_SERVER)) {
|
||||
$server['CONTENT_LENGTH'] = $_SERVER['HTTP_CONTENT_LENGTH'];
|
||||
}
|
||||
if (array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) {
|
||||
$server['CONTENT_TYPE'] = $_SERVER['HTTP_CONTENT_TYPE'];
|
||||
}
|
||||
}
|
||||
|
||||
$request = self::createRequestFromFactory($_GET, $_POST, array(), $_COOKIE, $_FILES, $server);
|
||||
|
||||
if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
|
||||
&& in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH'))
|
||||
|
@ -208,6 +208,25 @@ class BinaryFileResponseTest extends ResponseTestCase
|
||||
$this->assertFileNotExists($path);
|
||||
}
|
||||
|
||||
public function testAcceptRangeOnUnsafeMethods()
|
||||
{
|
||||
$request = Request::create('/', 'POST');
|
||||
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif');
|
||||
$response->prepare($request);
|
||||
|
||||
$this->assertEquals('none', $response->headers->get('Accept-Ranges'));
|
||||
}
|
||||
|
||||
public function testAcceptRangeNotOverriden()
|
||||
{
|
||||
$request = Request::create('/', 'POST');
|
||||
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif');
|
||||
$response->headers->set('Accept-Ranges', 'foo');
|
||||
$response->prepare($request);
|
||||
|
||||
$this->assertEquals('foo', $response->headers->get('Accept-Ranges'));
|
||||
}
|
||||
|
||||
public function getSampleXAccelMappings()
|
||||
{
|
||||
return array(
|
||||
|
@ -23,7 +23,7 @@ CHANGELOG
|
||||
|
||||
* [BC BREAK] renamed `Symfony\Component\HttpKernel\EventListener\DeprecationLoggerListener` to `Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener` and changed its constructor
|
||||
* deprecated `Symfony\Component\HttpKernel\Debug\ErrorHandler`, `Symfony\Component\HttpKernel\Debug\ExceptionHandler`,
|
||||
`Symfony\Component\HttpKernel\Exception\FatalErrorException`, and `Symfony\Component\HttpKernel\Exception\FlattenException`
|
||||
`Symfony\Component\HttpKernel\Exception\FatalErrorException` and `Symfony\Component\HttpKernel\Exception\FlattenException`
|
||||
* deprecated `Symfony\Component\HttpKernel\Kernel::init()``
|
||||
* added the possibility to specify an id an extra attributes to hinclude tags
|
||||
* added the collect of data if a controller is a Closure in the Request collector
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\DataCollector;
|
||||
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\FlattenException;
|
||||
|
||||
/**
|
||||
* ExceptionDataCollector.
|
||||
|
@ -12,12 +12,12 @@
|
||||
namespace Symfony\Component\HttpKernel\EventListener;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\FlattenException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
|
@ -13,8 +13,6 @@ namespace Symfony\Component\HttpKernel\Exception;
|
||||
|
||||
trigger_error('Symfony\Component\HttpKernel\Exception\FatalErrorException is deprecated since version 2.3 and will be removed in 3.0. Use the same class from the Debug component instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Debug\Exception\FatalErrorException as DebugFatalErrorException;
|
||||
|
||||
/**
|
||||
* Fatal Error Exception.
|
||||
*
|
||||
@ -22,6 +20,4 @@ use Symfony\Component\Debug\Exception\FatalErrorException as DebugFatalErrorExce
|
||||
*
|
||||
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
|
||||
*/
|
||||
class FatalErrorException extends DebugFatalErrorException
|
||||
{
|
||||
}
|
||||
class_exists('Symfony\Component\Debug\Exception\FatalErrorException');
|
||||
|
@ -13,8 +13,6 @@ namespace Symfony\Component\HttpKernel\Exception;
|
||||
|
||||
trigger_error('Symfony\Component\HttpKernel\Exception\FlattenException is deprecated since version 2.3 and will be removed in 3.0. Use the same class from the Debug component instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
|
||||
|
||||
/**
|
||||
* FlattenException wraps a PHP Exception to be able to serialize it.
|
||||
*
|
||||
@ -24,6 +22,4 @@ use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
|
||||
*
|
||||
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
|
||||
*/
|
||||
class FlattenException extends DebugFlattenException
|
||||
{
|
||||
}
|
||||
class_exists('Symfony\Component\Debug\Exception\FlattenException');
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\DataCollector;
|
||||
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\HttpKernel\DataCollector\ExceptionDataCollector;
|
||||
use Symfony\Component\HttpKernel\Exception\FlattenException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\DataCollector;
|
||||
|
||||
use Symfony\Component\Debug\ErrorHandler;
|
||||
use Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector;
|
||||
|
||||
class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase
|
||||
|
@ -67,10 +67,6 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRouterResetWithParentRequestOnKernelFinishRequest()
|
||||
{
|
||||
if (!class_exists('Symfony\Component\Routing\Router')) {
|
||||
$this->markTestSkipped('The "Routing" component is not available');
|
||||
}
|
||||
|
||||
// the request context is updated
|
||||
$context = $this->getMock('Symfony\Component\Routing\RequestContext');
|
||||
$context->expects($this->once())->method('setParameter')->with('_locale', 'es');
|
||||
|
@ -194,11 +194,6 @@ class KernelTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testStripComments()
|
||||
{
|
||||
if (!function_exists('token_get_all')) {
|
||||
$this->markTestSkipped('The function token_get_all() is not available.');
|
||||
|
||||
return;
|
||||
}
|
||||
$source = <<<'EOF'
|
||||
<?php
|
||||
|
||||
|
@ -60,10 +60,6 @@ class ProfilerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('Symfony\Component\HttpFoundation\Request')) {
|
||||
$this->markTestSkipped('The "HttpFoundation" component is not available');
|
||||
}
|
||||
|
||||
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) {
|
||||
$this->markTestSkipped('This test requires SQLite support in your environment');
|
||||
}
|
||||
|
@ -33,5 +33,7 @@ class UriSignerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertTrue($signer->check($signer->sign('http://example.com/foo')));
|
||||
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar')));
|
||||
|
||||
$this->assertTrue($signer->sign('http://example.com/foo?foo=bar&bar=foo') === $signer->sign('http://example.com/foo?bar=foo&foo=bar'));
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,15 @@ class UriSigner
|
||||
*/
|
||||
public function sign($uri)
|
||||
{
|
||||
$url = parse_url($uri);
|
||||
if (isset($url['query'])) {
|
||||
parse_str($url['query'], $params);
|
||||
} else {
|
||||
$params = array();
|
||||
}
|
||||
|
||||
$uri = $this->buildUrl($url, $params);
|
||||
|
||||
return $uri.(false === (strpos($uri, '?')) ? '?' : '&').'_hash='.$this->computeHash($uri);
|
||||
}
|
||||
|
||||
@ -58,15 +67,43 @@ class UriSigner
|
||||
*/
|
||||
public function check($uri)
|
||||
{
|
||||
if (!preg_match('/^(.*)(?:\?|&)_hash=(.+?)$/', $uri, $matches)) {
|
||||
$url = parse_url($uri);
|
||||
if (isset($url['query'])) {
|
||||
parse_str($url['query'], $params);
|
||||
} else {
|
||||
$params = array();
|
||||
}
|
||||
|
||||
if (empty($params['_hash'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->computeHash($matches[1]) === $matches[2];
|
||||
$hash = urlencode($params['_hash']);
|
||||
unset($params['_hash']);
|
||||
|
||||
return $this->computeHash($this->buildUrl($url, $params)) === $hash;
|
||||
}
|
||||
|
||||
private function computeHash($uri)
|
||||
{
|
||||
return urlencode(base64_encode(hash_hmac('sha256', $uri, $this->secret, true)));
|
||||
}
|
||||
|
||||
private function buildUrl(array $url, array $params = array())
|
||||
{
|
||||
ksort($params);
|
||||
$url['query'] = http_build_query($params);
|
||||
|
||||
$scheme = isset($url['scheme']) ? $url['scheme'].'://' : '';
|
||||
$host = isset($url['host']) ? $url['host'] : '';
|
||||
$port = isset($url['port']) ? ':'.$url['port'] : '';
|
||||
$user = isset($url['user']) ? $url['user'] : '';
|
||||
$pass = isset($url['pass']) ? ':'.$url['pass'] : '';
|
||||
$pass = ($user || $pass) ? "$pass@" : '';
|
||||
$path = isset($url['path']) ? $url['path'] : '';
|
||||
$query = isset($url['query']) && $url['query'] ? '?'.$url['query'] : '';
|
||||
$fragment = isset($url['fragment']) ? '#'.$url['fragment'] : '';
|
||||
|
||||
return $scheme.$user.$pass.$host.$port.$path.$query.$fragment;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
"php": ">=5.3.3",
|
||||
"symfony/event-dispatcher": "~2.5.9|~2.6,>=2.6.2|~3.0.0",
|
||||
"symfony/http-foundation": "~2.5,>=2.5.4|~3.0.0",
|
||||
"symfony/debug": "~2.6|~3.0.0",
|
||||
"symfony/debug": "~2.6,>=2.6.2|~3.0.0",
|
||||
"psr/log": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
|
@ -1,6 +1,12 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
2.3.0
|
||||
-----
|
||||
|
||||
The Locale component is deprecated since version 2.3 and will be removed in
|
||||
Symfony 3.0. You should use the more capable Intl component instead.
|
||||
|
||||
2.1.0
|
||||
-----
|
||||
|
||||
|
@ -23,6 +23,8 @@ class LocaleTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
// Locale extends \Locale, so intl must be present
|
||||
IntlTestHelper::requireIntl($this);
|
||||
}
|
||||
|
@ -21,9 +21,10 @@ class StubLocaleTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
IntlTestHelper::requireIntl($this);
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
parent::setUp();
|
||||
// Locale extends \Locale, so intl must be present
|
||||
IntlTestHelper::requireIntl($this);
|
||||
}
|
||||
|
||||
public function testGetCurrenciesData()
|
||||
|
@ -39,7 +39,7 @@ final class PropertyAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias of {@link getPropertyAccessor}.
|
||||
* Alias of {@link createPropertyAccessor}.
|
||||
*
|
||||
* @return PropertyAccessor The new property accessor
|
||||
*
|
||||
|
@ -25,7 +25,7 @@ interface PropertyAccessorInterface
|
||||
*
|
||||
* use Symfony\Component\PropertyAccess\PropertyAccess;
|
||||
*
|
||||
* $propertyAccessor = PropertyAccess::getPropertyAccessor();
|
||||
* $propertyAccessor = PropertyAccess::createPropertyAccessor();
|
||||
*
|
||||
* echo $propertyAccessor->setValue($object, 'child.name', 'Fabien');
|
||||
* // equals echo $object->getChild()->setName('Fabien');
|
||||
@ -57,7 +57,7 @@ interface PropertyAccessorInterface
|
||||
*
|
||||
* use Symfony\Component\PropertyAccess\PropertyAccess;
|
||||
*
|
||||
* $propertyAccessor = PropertyAccess::getPropertyAccessor();
|
||||
* $propertyAccessor = PropertyAccess::createPropertyAccessor();
|
||||
*
|
||||
* echo $propertyAccessor->getValue($object, 'child.name);
|
||||
* // equals echo $object->getChild()->getName();
|
||||
|
@ -272,21 +272,14 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function hasScheme($scheme)
|
||||
{
|
||||
$scheme = strtolower($scheme);
|
||||
foreach ($this->schemes as $requiredScheme) {
|
||||
if ($scheme === $requiredScheme) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return in_array(strtolower($scheme), $this->schemes, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the uppercased HTTP methods this route is restricted to.
|
||||
* So an empty array means that any method is allowed.
|
||||
*
|
||||
* @return array The schemes
|
||||
* @return array The methods
|
||||
*/
|
||||
public function getMethods()
|
||||
{
|
||||
|
@ -35,7 +35,6 @@ class RouteTest extends \PHPUnit_Framework_TestCase
|
||||
public function getValidParameters()
|
||||
{
|
||||
return array(
|
||||
array('value', '/Blog', 'getPattern'),
|
||||
array('value', '/Blog', 'getPath'),
|
||||
array('requirements', array('_method' => 'GET'), 'getRequirements'),
|
||||
array('options', array('compiler_class' => 'RouteCompiler'), 'getOptions'),
|
||||
@ -47,4 +46,12 @@ class RouteTest extends \PHPUnit_Framework_TestCase
|
||||
array('condition', array('context.getMethod() == "GET"'), 'getCondition'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testLegacyGetPattern()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$route = new Route(array('value' => '/Blog'));
|
||||
$this->assertEquals($route->getPattern(), '/Blog');
|
||||
}
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase
|
||||
$subColl->add('bar', new Route('/bar'));
|
||||
$subColl->addPrefix('/prefix');
|
||||
// overwrite the pattern, so the prefix is not valid anymore for this route in the collection
|
||||
$subColl->get('bar')->setPattern('/new');
|
||||
$subColl->get('bar')->setPath('/new');
|
||||
|
||||
$coll->addCollection($subColl);
|
||||
|
||||
|
@ -146,7 +146,7 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase
|
||||
$collection2->add('bar', $bar = new Route('/bar'));
|
||||
$collection->addCollection($collection2);
|
||||
$collection->addPrefix(' / ');
|
||||
$this->assertSame('/foo', $collection->get('foo')->getPattern(), '->addPrefix() trims the prefix and a single slash has no effect');
|
||||
$this->assertSame('/foo', $collection->get('foo')->getPath(), '->addPrefix() trims the prefix and a single slash has no effect');
|
||||
$collection->addPrefix('/{admin}', array('admin' => 'admin'), array('admin' => '\d+'));
|
||||
$this->assertEquals('/{admin}/foo', $collection->get('foo')->getPath(), '->addPrefix() adds a prefix to all routes');
|
||||
$this->assertEquals('/{admin}/bar', $collection->get('bar')->getPath(), '->addPrefix() adds a prefix to all routes');
|
||||
@ -155,7 +155,7 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array('admin' => '\d+'), $collection->get('foo')->getRequirements(), '->addPrefix() adds requirements to all routes');
|
||||
$this->assertEquals(array('admin' => '\d+'), $collection->get('bar')->getRequirements(), '->addPrefix() adds requirements to all routes');
|
||||
$collection->addPrefix('0');
|
||||
$this->assertEquals('/0/{admin}/foo', $collection->get('foo')->getPattern(), '->addPrefix() ensures a prefix must start with a slash and must not end with a slash');
|
||||
$this->assertEquals('/0/{admin}/foo', $collection->get('foo')->getPath(), '->addPrefix() ensures a prefix must start with a slash and must not end with a slash');
|
||||
$collection->addPrefix('/ /');
|
||||
$this->assertSame('/ /0/{admin}/foo', $collection->get('foo')->getPath(), '->addPrefix() can handle spaces if desired');
|
||||
$this->assertSame('/ /0/{admin}/bar', $collection->get('bar')->getPath(), 'the route pattern of an added collection is in synch with the added prefix');
|
||||
|
@ -218,8 +218,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNotSame($compiled, $route->compile(), '->compile() recompiles if the route was modified');
|
||||
}
|
||||
|
||||
public function testPattern()
|
||||
public function testLegacyPattern()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$route = new Route('/{foo}');
|
||||
$this->assertEquals('/{foo}', $route->getPattern());
|
||||
|
||||
|
@ -47,8 +47,10 @@ interface TokenInterface extends \Serializable
|
||||
/**
|
||||
* Returns a user representation.
|
||||
*
|
||||
* @return mixed either returns an object which implements __toString(), or
|
||||
* a primitive string is returned.
|
||||
* @return mixed Can be a UserInterface instance, an object implementing a __toString method,
|
||||
* or the username as a regular string
|
||||
*
|
||||
* @see AbstractToken::setUser()
|
||||
*/
|
||||
public function getUser();
|
||||
|
||||
|
@ -27,6 +27,10 @@ class ResponseListener implements EventSubscriberInterface
|
||||
*/
|
||||
public function onKernelResponse(FilterResponseEvent $event)
|
||||
{
|
||||
if (!$event->isMasterRequest()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$request = $event->getRequest();
|
||||
$response = $event->getResponse();
|
||||
|
||||
|
@ -73,10 +73,6 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testHandledEventIsLogged()
|
||||
{
|
||||
if (!interface_exists('Psr\Log\LoggerInterface')) {
|
||||
$this->markTestSkipped('The "LoggerInterface" is not available');
|
||||
}
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||
$logger->expects($this->once())
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Security\Http\Tests\RememberMe;
|
||||
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\Security\Http\RememberMe\ResponseListener;
|
||||
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -34,6 +35,21 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$listener->onKernelResponse($this->getEvent($request, $response));
|
||||
}
|
||||
|
||||
public function testRememberMeCookieIsNotSendWithResponseForSubRequests()
|
||||
{
|
||||
$cookie = new Cookie('rememberme');
|
||||
|
||||
$request = $this->getRequest(array(
|
||||
RememberMeServicesInterface::COOKIE_ATTR_NAME => $cookie,
|
||||
));
|
||||
|
||||
$response = $this->getResponse();
|
||||
$response->headers->expects($this->never())->method('setCookie');
|
||||
|
||||
$listener = new ResponseListener();
|
||||
$listener->onKernelResponse($this->getEvent($request, $response, HttpKernelInterface::SUB_REQUEST));
|
||||
}
|
||||
|
||||
public function testRememberMeCookieIsNotSendWithResponse()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
@ -71,13 +87,14 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
||||
return $response;
|
||||
}
|
||||
|
||||
private function getEvent($request, $response)
|
||||
private function getEvent($request, $response, $type = HttpKernelInterface::MASTER_REQUEST)
|
||||
{
|
||||
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FilterResponseEvent')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$event->expects($this->any())->method('getRequest')->will($this->returnValue($request));
|
||||
$event->expects($this->any())->method('isMasterRequest')->will($this->returnValue($type === HttpKernelInterface::MASTER_REQUEST));
|
||||
$event->expects($this->any())->method('getResponse')->will($this->returnValue($response));
|
||||
|
||||
return $event;
|
||||
|
@ -28,7 +28,7 @@
|
||||
"symfony/security-http": "self.version"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/locale": "~2.0,>=2.0.5|~3.0.0",
|
||||
"symfony/intl": "~2.3|~3.0.0",
|
||||
"symfony/routing": "~2.2|~3.0.0",
|
||||
"symfony/translation": "~2.0,>=2.0.5|~3.0.0",
|
||||
"symfony/validator": "~2.5,>=2.5.5|~3.0.0",
|
||||
|
@ -170,7 +170,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
|
||||
$translator = new Translator('fr');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
|
||||
$translator->setFallbackLocale(array('en'));
|
||||
$translator->setFallbackLocales(array('en'));
|
||||
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), 'en');
|
||||
$this->assertEquals('foofoo', $translator->trans('foo'));
|
||||
|
14
src/Symfony/Component/Validator/Tests/bootstrap.php
Normal file
14
src/Symfony/Component/Validator/Tests/bootstrap.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
$loader = require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(function ($class) {return class_exists($class);});
|
@ -4,7 +4,7 @@
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
bootstrap="Tests/bootstrap.php"
|
||||
>
|
||||
<php>
|
||||
<!-- Disable E_USER_DEPRECATED until 3.0 -->
|
||||
|
@ -6,7 +6,7 @@ YAML implements most of the YAML 1.2 specification.
|
||||
```php
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
$array = Yaml::parse($file);
|
||||
$array = Yaml::parse(file_get_contents(filename));
|
||||
|
||||
print Yaml::dump($array);
|
||||
```
|
||||
|
Reference in New Issue
Block a user