diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php
index ebb7ed0e98..9aaf53cd6e 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php
@@ -265,6 +265,23 @@ class GenericEntityChoiceListTest extends \PHPUnit_Framework_TestCase
);
$this->assertEquals(array(1, 2), $choiceList->getValuesForChoices(array($item1, $item2)));
+ }
+
+ public function testLegacyInitShorthandEntityName()
+ {
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
+ $item1 = new SingleIntIdEntity(1, 'Foo');
+ $item2 = new SingleIntIdEntity(2, 'Bar');
+
+ $this->em->persist($item1);
+ $this->em->persist($item2);
+
+ $choiceList = new EntityChoiceList(
+ $this->em,
+ 'SymfonyTestsDoctrine:SingleIntIdEntity'
+ );
+
$this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2)));
}
}
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleIntIdTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleIntIdTest.php
index a876878415..3fdb978666 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleIntIdTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleIntIdTest.php
@@ -20,4 +20,9 @@ class UnloadedEntityChoiceListSingleIntIdTest extends AbstractEntityChoiceListSi
{
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
}
+
+ public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
+ {
+ $this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
+ }
}
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
index cfc56b9b4c..b3398f35dc 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
@@ -23,7 +23,6 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
use Symfony\Component\Validator\Validation;
-use Symfony\Component\Validator\Validator;
use Doctrine\ORM\Tools\SchemaTool;
/**
diff --git a/src/Symfony/Bridge/Propel1/Tests/Form/ChoiceList/ModelChoiceListTest.php b/src/Symfony/Bridge/Propel1/Tests/Form/ChoiceList/ModelChoiceListTest.php
index 3b2ea0a8d2..53fb2c5d59 100644
--- a/src/Symfony/Bridge/Propel1/Tests/Form/ChoiceList/ModelChoiceListTest.php
+++ b/src/Symfony/Bridge/Propel1/Tests/Form/ChoiceList/ModelChoiceListTest.php
@@ -183,7 +183,6 @@ class ModelChoiceListTest extends Propel1TestCase
);
$this->assertEquals(array(1, 2), $choiceList->getValuesForChoices(array($item1, $item2)));
- $this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2)));
}
public function testDifferentEqualObjectsAreChoosen()
@@ -202,12 +201,58 @@ class ModelChoiceListTest extends Propel1TestCase
$choosenItem = new Item(1, 'Foo');
- $this->assertEquals(array(1), $choiceList->getIndicesForChoices(array($choosenItem)));
$this->assertEquals(array('1'), $choiceList->getValuesForChoices(array($choosenItem)));
}
- public function testGetIndicesForNullChoices()
+ public function testLegacygetIndicesForChoices()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
+ $item1 = new Item(1, 'Foo');
+ $item2 = new Item(2, 'Bar');
+
+ ItemQuery::$result = array(
+ $item1,
+ $item2,
+ );
+
+ $choiceList = new ModelChoiceList(
+ self::ITEM_CLASS,
+ 'value',
+ null,
+ null,
+ null,
+ null
+ );
+
+ $this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2)));
+ }
+
+ public function testLegacyDifferentEqualObjectsAreChoosen()
+ {
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
+ $item = new Item(1, 'Foo');
+
+ ItemQuery::$result = array(
+ $item,
+ );
+
+ $choiceList = new ModelChoiceList(
+ self::ITEM_CLASS,
+ 'value',
+ array($item)
+ );
+
+ $choosenItem = new Item(1, 'Foo');
+
+ $this->assertEquals(array(1), $choiceList->getIndicesForChoices(array($choosenItem)));
+ }
+
+ public function testLegacyGetIndicesForNullChoices()
+ {
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$item = new Item(1, 'Foo');
$choiceList = new ModelChoiceList(
self::ITEM_CLASS,
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php
index 2c5c7618a9..0c25ad44cd 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php
@@ -36,7 +36,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
'form_div_layout.html.twig',
'custom_widgets.html.twig',
));
- $renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface'));
+ $renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
$this->extension = new FormExtension($renderer);
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php
index 22331781da..b2e21a3961 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php
@@ -35,7 +35,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
'form_table_layout.html.twig',
'custom_widgets.html.twig',
));
- $renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface'));
+ $renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
$this->extension = new FormExtension($renderer);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php
index 4bd043ed59..5517afdb73 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php
@@ -12,33 +12,37 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper;
class SessionHelperTest extends \PHPUnit_Framework_TestCase
{
- protected $request;
+ protected $requestStack;
protected function setUp()
{
- $this->request = new Request();
+ $request = new Request();
$session = new Session(new MockArraySessionStorage());
$session->set('foobar', 'bar');
$session->getFlashBag()->set('notice', 'bar');
- $this->request->setSession($session);
+ $request->setSession($session);
+
+ $this->requestStack = new RequestStack();
+ $this->requestStack->push($request);
}
protected function tearDown()
{
- $this->request = null;
+ $this->requestStack = null;
}
public function testFlash()
{
- $helper = new SessionHelper($this->request);
+ $helper = new SessionHelper($this->requestStack);
$this->assertTrue($helper->hasFlash('notice'));
@@ -47,13 +51,13 @@ class SessionHelperTest extends \PHPUnit_Framework_TestCase
public function testGetFlashes()
{
- $helper = new SessionHelper($this->request);
+ $helper = new SessionHelper($this->requestStack);
$this->assertEquals(array('notice' => array('bar')), $helper->getFlashes());
}
public function testGet()
{
- $helper = new SessionHelper($this->request);
+ $helper = new SessionHelper($this->requestStack);
$this->assertEquals('bar', $helper->get('foobar'));
$this->assertEquals('foo', $helper->get('bar', 'foo'));
@@ -63,7 +67,7 @@ class SessionHelperTest extends \PHPUnit_Framework_TestCase
public function testGetName()
{
- $helper = new SessionHelper($this->request);
+ $helper = new SessionHelper($this->requestStack);
$this->assertEquals('session', $helper->getName());
}
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/RenderTokenParserTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php
similarity index 91%
rename from src/Symfony/Bundle/TwigBundle/Tests/TokenParser/RenderTokenParserTest.php
rename to src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php
index 55ebcd2566..3e415abf3e 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/RenderTokenParserTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php
@@ -15,8 +15,13 @@ use Symfony\Bundle\TwigBundle\Tests\TestCase;
use Symfony\Bundle\TwigBundle\TokenParser\RenderTokenParser;
use Symfony\Bundle\TwigBundle\Node\RenderNode;
-class RenderTokenParserTest extends TestCase
+class LegacyRenderTokenParserTest extends TestCase
{
+ public function setUp()
+ {
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
+ }
+
/**
* @dataProvider getTestsForRender
*/
diff --git a/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/LegacyApcUniversalClassLoaderTest.php
similarity index 98%
rename from src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php
rename to src/Symfony/Component/ClassLoader/Tests/LegacyApcUniversalClassLoaderTest.php
index 9755256c79..8a1f203118 100644
--- a/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php
+++ b/src/Symfony/Component/ClassLoader/Tests/LegacyApcUniversalClassLoaderTest.php
@@ -13,10 +13,12 @@ namespace Symfony\Component\ClassLoader\Tests;
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
-class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
+class LegacyApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
+
if (!extension_loaded('apc')) {
$this->markTestSkipped('The apc extension is not available.');
}
diff --git a/src/Symfony/Component/ClassLoader/Tests/UniversalClassLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/LegacyUniversalClassLoaderTest.php
similarity index 98%
rename from src/Symfony/Component/ClassLoader/Tests/UniversalClassLoaderTest.php
rename to src/Symfony/Component/ClassLoader/Tests/LegacyUniversalClassLoaderTest.php
index 6bd7e43621..f654f792fb 100644
--- a/src/Symfony/Component/ClassLoader/Tests/UniversalClassLoaderTest.php
+++ b/src/Symfony/Component/ClassLoader/Tests/LegacyUniversalClassLoaderTest.php
@@ -13,8 +13,13 @@ namespace Symfony\Component\ClassLoader\Tests;
use Symfony\Component\ClassLoader\UniversalClassLoader;
-class UniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
+class LegacyUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{
+ public function setUp()
+ {
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
+ }
+
/**
* @dataProvider getLoadClassTests
*/
diff --git a/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/LegacyDialogHelperTest.php
similarity index 98%
rename from src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php
rename to src/Symfony/Component/Console/Tests/Helper/LegacyDialogHelperTest.php
index 26383772b2..e58b8de708 100644
--- a/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/LegacyDialogHelperTest.php
@@ -17,8 +17,13 @@ use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Helper\FormatterHelper;
use Symfony\Component\Console\Output\StreamOutput;
-class DialogHelperTest extends \PHPUnit_Framework_TestCase
+class LegacyDialogHelperTest extends \PHPUnit_Framework_TestCase
{
+ public function setUp()
+ {
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
+ }
+
public function testSelect()
{
$dialog = new DialogHelper();
diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php
similarity index 97%
rename from src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php
rename to src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php
index 7bc475fce0..5dee669f46 100644
--- a/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php
@@ -14,8 +14,13 @@ namespace Symfony\Component\Console\Tests\Helper;
use Symfony\Component\Console\Helper\ProgressHelper;
use Symfony\Component\Console\Output\StreamOutput;
-class ProgressHelperTest extends \PHPUnit_Framework_TestCase
+class LegacyProgressHelperTest extends \PHPUnit_Framework_TestCase
{
+ public function setUp()
+ {
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
+ }
+
public function testAdvance()
{
$progress = new ProgressHelper();
diff --git a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/LegacyTableHelperTest.php
similarity index 98%
rename from src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php
rename to src/Symfony/Component/Console/Tests/Helper/LegacyTableHelperTest.php
index f3cda0dabf..046cc19ca8 100644
--- a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/LegacyTableHelperTest.php
@@ -14,12 +14,13 @@ namespace Symfony\Component\Console\Tests\Helper;
use Symfony\Component\Console\Helper\TableHelper;
use Symfony\Component\Console\Output\StreamOutput;
-class TableHelperTest extends \PHPUnit_Framework_TestCase
+class LegacyTableHelperTest extends \PHPUnit_Framework_TestCase
{
protected $stream;
protected function setUp()
{
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->stream = fopen('php://memory', 'r+');
}
diff --git a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php
index b284320afc..fec26dc01f 100644
--- a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php
+++ b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php
@@ -39,8 +39,16 @@ class StringInputTest extends \PHPUnit_Framework_TestCase
$input = new StringInput('--foo=bar');
$input->bind($definition);
$this->assertEquals('bar', $input->getOption('foo'));
+ }
+
+ public function testLegacyInputOptionDefinitionInConstructor()
+ {
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
+ $definition = new InputDefinition(
+ array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
+ );
- // definition in constructor
$input = new StringInput('--foo=bar', $definition);
$this->assertEquals('bar', $input->getOption('foo'));
}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/interfaces1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/interfaces1.php
deleted file mode 100644
index 27503a351c..0000000000
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/interfaces1.php
+++ /dev/null
@@ -1,25 +0,0 @@
-setParameter('cla', 'Fo');
-$container->setParameter('ss', 'Class');
-
-$definition = new Definition('%cla%o%ss%');
-$container->setDefinition('foo', $definition);
-
-return $container;
-
-if (!class_exists('FooClass')) {
- class FooClass
- {
- public $bar;
-
- public function setBar($bar)
- {
- $this->bar = $bar;
- }
- }
-}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/interfaces2.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/interfaces2.php
deleted file mode 100644
index a85190145e..0000000000
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/interfaces2.php
+++ /dev/null
@@ -1,34 +0,0 @@
-setDefinition('barFactory', $factoryDefinition);
-
-$definition = new Definition();
-$definition->setFactoryService('barFactory');
-$definition->setFactoryMethod('createBarClass');
-$container->setDefinition('bar', $definition);
-
-return $container;
-
-class BarClass
-{
- public $foo;
-
- public function setBar($foo)
- {
- $this->foo = $foo;
- }
-}
-
-class BarClassFactory
-{
- public function createBarClass()
- {
- return new BarClass();
- }
-}
diff --git a/src/Symfony/Component/EventDispatcher/Tests/EventTest.php b/src/Symfony/Component/EventDispatcher/Tests/EventTest.php
index 7a20fe6bf3..8f2fb7358e 100644
--- a/src/Symfony/Component/EventDispatcher/Tests/EventTest.php
+++ b/src/Symfony/Component/EventDispatcher/Tests/EventTest.php
@@ -60,24 +60,28 @@ class EventTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($this->event->isPropagationStopped());
}
- public function testSetDispatcher()
+ public function testLegacySetDispatcher()
{
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->event->setDispatcher($this->dispatcher);
$this->assertSame($this->dispatcher, $this->event->getDispatcher());
}
- public function testGetDispatcher()
+ public function testLegacyGetDispatcher()
{
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertNull($this->event->getDispatcher());
}
- public function testGetName()
+ public function testLegacyGetName()
{
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertNull($this->event->getName());
}
- public function testSetName()
+ public function testLegacySetName()
{
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->event->setName('foo');
$this->assertEquals('foo', $this->event->getName());
}
diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
index dc241779c9..fa10838f90 100644
--- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
+++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
@@ -62,7 +62,6 @@ class ChoiceType extends AbstractType
$placeholderView = new ChoiceView(null, '', $options['empty_value']);
// "placeholder" is a reserved index
- // see also ChoiceListInterface::getIndicesForChoices()
$this->addSubForms($builder, array('placeholder' => $placeholderView), $options);
}
diff --git a/src/Symfony/Component/Form/Forms.php b/src/Symfony/Component/Form/Forms.php
index c949c1f48a..96ac45129f 100644
--- a/src/Symfony/Component/Form/Forms.php
+++ b/src/Symfony/Component/Form/Forms.php
@@ -55,39 +55,6 @@ use Symfony\Component\Form\Extension\Core\CoreExtension;
* ->getFormFactory();
*
*
- * Support for CSRF protection is provided by the CsrfExtension.
- * This extension needs a CSRF provider with a strong secret
- * (e.g. a 20 character long random string). The default
- * implementation for this is DefaultCsrfProvider:
- *
- *
- * use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
- * use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
- *
- * $secret = 'V8a5Z97e...';
- * $formFactory = Forms::createFormFactoryBuilder()
- * ->addExtension(new CsrfExtension(new DefaultCsrfProvider($secret)))
- * ->getFormFactory();
- *
- *
- * Support for the HttpFoundation is provided by the
- * HttpFoundationExtension. You are also advised to load the CSRF
- * extension with the driver for HttpFoundation's Session class:
- *
- *
- * use Symfony\Component\HttpFoundation\Session\Session;
- * use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
- * use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
- * use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
- *
- * $session = new Session();
- * $secret = 'V8a5Z97e...';
- * $formFactory = Forms::createFormFactoryBuilder()
- * ->addExtension(new HttpFoundationExtension())
- * ->addExtension(new CsrfExtension(new SessionCsrfProvider($session, $secret)))
- * ->getFormFactory();
- *
- *
* Support for the Validator component is provided by ValidatorExtension.
* This extension needs a validator object to function properly:
*
@@ -129,26 +96,6 @@ use Symfony\Component\Form\Extension\Core\CoreExtension;
* ->getFormFactory();
*
*
- * If you also loaded the CsrfExtension, you should pass the CSRF provider
- * to the extension so that you can render CSRF tokens in your templates
- * more easily:
- *
- *
- * use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
- * use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
- * use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
- *
- *
- * $secret = 'V8a5Z97e...';
- * $csrfProvider = new DefaultCsrfProvider($secret);
- * $formFactory = Forms::createFormFactoryBuilder()
- * ->addExtension(new CsrfExtension($csrfProvider))
- * ->addExtension(new TemplatingExtension($engine, $csrfProvider, array(
- * 'FrameworkBundle:Form',
- * )))
- * ->getFormFactory();
- *
- *
* @author Bernhard Schussek
*/
final class Forms
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/AbstractChoiceListTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/AbstractChoiceListTest.php
index c762064e0b..f503b95622 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/AbstractChoiceListTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/AbstractChoiceListTest.php
@@ -161,63 +161,83 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
$this->assertSame($this->values, $this->list->getValues());
}
- public function testGetIndicesForChoices()
+ public function testLegacyGetIndicesForChoices()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$choices = array($this->choice1, $this->choice2);
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
}
- public function testGetIndicesForChoicesPreservesKeys()
+ public function testLegacyGetIndicesForChoicesPreservesKeys()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$choices = array(5 => $this->choice1, 8 => $this->choice2);
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForChoices($choices));
}
- public function testGetIndicesForChoicesPreservesOrder()
+ public function testLegacyGetIndicesForChoicesPreservesOrder()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$choices = array($this->choice2, $this->choice1);
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForChoices($choices));
}
- public function testGetIndicesForChoicesIgnoresNonExistingChoices()
+ public function testLegacyGetIndicesForChoicesIgnoresNonExistingChoices()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$choices = array($this->choice1, $this->choice2, 'foobar');
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
}
- public function testGetIndicesForChoicesEmpty()
+ public function testLegacyGetIndicesForChoicesEmpty()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$this->assertSame(array(), $this->list->getIndicesForChoices(array()));
}
- public function testGetIndicesForValues()
+ public function testLegacyGetIndicesForValues()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
// values and indices are always the same
$values = array($this->value1, $this->value2);
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForValues($values));
}
- public function testGetIndicesForValuesPreservesKeys()
+ public function testLegacyGetIndicesForValuesPreservesKeys()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
// values and indices are always the same
$values = array(5 => $this->value1, 8 => $this->value2);
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForValues($values));
}
- public function testGetIndicesForValuesPreservesOrder()
+ public function testLegacyGetIndicesForValuesPreservesOrder()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$values = array($this->value2, $this->value1);
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForValues($values));
}
- public function testGetIndicesForValuesIgnoresNonExistingValues()
+ public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$values = array($this->value1, $this->value2, 'foobar');
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForValues($values));
}
- public function testGetIndicesForValuesEmpty()
+ public function testLegacyGetIndicesForValuesEmpty()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$this->assertSame(array(), $this->list->getIndicesForValues(array()));
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php
index bcd309e050..d4ff2124af 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php
@@ -57,14 +57,18 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array(0 => new ChoiceView('a', 'a', 'A'), 2 => new ChoiceView('c', 'c', 'C')), $this->list->getRemainingViews());
}
- public function testGetIndicesForChoices()
+ public function testLegacyGetIndicesForChoices()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$choices = array('b', 'c');
$this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices));
}
- public function testGetIndicesForValues()
+ public function testLegacyGetIndicesForValues()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$values = array('b', 'c');
$this->assertSame(array(1, 2), $this->list->getIndicesForValues($values));
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php
index a05fb57c2f..c20ac1ce27 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php
@@ -185,8 +185,10 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
);
}
- public function testGetIndicesForChoicesWithValuePath()
+ public function testLegacyGetIndicesForChoicesWithValuePath()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$this->list = new ObjectChoiceList(
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
'name',
@@ -200,8 +202,10 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
}
- public function testGetIndicesForChoicesWithValuePathPreservesKeys()
+ public function testLegacyGetIndicesForChoicesWithValuePathPreservesKeys()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$this->list = new ObjectChoiceList(
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
'name',
@@ -214,8 +218,10 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForChoices($choices));
}
- public function testGetIndicesForChoicesWithValuePathPreservesOrder()
+ public function testLegacyGetIndicesForChoicesWithValuePathPreservesOrder()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$this->list = new ObjectChoiceList(
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
'name',
@@ -228,8 +234,10 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForChoices($choices));
}
- public function testGetIndicesForChoicesWithValuePathIgnoresNonExistingChoices()
+ public function testLegacyGetIndicesForChoicesWithValuePathIgnoresNonExistingChoices()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$this->list = new ObjectChoiceList(
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
'name',
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleNumericChoiceListTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleNumericChoiceListTest.php
index fea0dad9ea..540ae16f74 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleNumericChoiceListTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleNumericChoiceListTest.php
@@ -15,15 +15,19 @@ use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
class SimpleNumericChoiceListTest extends AbstractChoiceListTest
{
- public function testGetIndicesForChoicesDealsWithNumericChoices()
+ public function testLegacyGetIndicesForChoicesDealsWithNumericChoices()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
// Pass choices as strings although they are integers
$choices = array('0', '1');
$this->assertSame(array(0, 1), $this->list->getIndicesForChoices($choices));
}
- public function testGetIndicesForValuesDealsWithNumericValues()
+ public function testLegacyGetIndicesForValuesDealsWithNumericValues()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
// Pass values as strings although they are integers
$values = array('0', '1');
$this->assertSame(array(0, 1), $this->list->getIndicesForValues($values));
diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacyDefaultCsrfProviderTest.php
similarity index 100%
rename from src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php
rename to src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacyDefaultCsrfProviderTest.php
diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/SessionCsrfProviderTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php
similarity index 92%
rename from src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/SessionCsrfProviderTest.php
rename to src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php
index 99e87158b5..018f80fa44 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/SessionCsrfProviderTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php
@@ -13,13 +13,15 @@ namespace Symfony\Component\Form\Tests\Extension\Csrf\CsrfProvider;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
-class SessionCsrfProviderTest extends \PHPUnit_Framework_TestCase
+class LegacySessionCsrfProviderTest extends \PHPUnit_Framework_TestCase
{
protected $provider;
protected $session;
protected function setUp()
{
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
+
$this->session = $this->getMock(
'Symfony\Component\HttpFoundation\Session\Session',
array(),
diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php
index 786de984ae..b92536fb0f 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php
@@ -566,7 +566,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
private function getMockExecutionContext()
{
- return $this->getMock('Symfony\Component\Validator\ExecutionContextInterface');
+ return $this->getMock('Symfony\Component\Validator\Context\ExecutionContextInterface');
}
/**
diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php
index 4d88a5ef0f..06047cfb2a 100644
--- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php
+++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php
@@ -100,16 +100,16 @@ class SimpleFormTest extends AbstractFormTest
public function testFalseIsConvertedToNull()
{
$mock = $this->getMockBuilder('\stdClass')
- ->setMethods(array('preBind'))
+ ->setMethods(array('preSubmit'))
->getMock();
$mock->expects($this->once())
- ->method('preBind')
+ ->method('preSubmit')
->with($this->callback(function ($event) {
return null === $event->getData();
}));
$config = new FormConfigBuilder('name', null, $this->dispatcher);
- $config->addEventListener(FormEvents::PRE_SUBMIT, array($mock, 'preBind'));
+ $config->addEventListener(FormEvents::PRE_SUBMIT, array($mock, 'preSubmit'));
$form = new Form($config);
$form->submit(false);
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php
index b242ede446..c68f3af37b 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\HttpKernel\Tests\EventListener;
+use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\EventListener\ProfilerListener;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
@@ -23,11 +24,11 @@ class ProfilerListenerTest extends \PHPUnit_Framework_TestCase
{
/**
* Test to ensure BC without RequestStack
- *
- * @deprecated Deprecated since version 2.4, to be removed in 3.0.
*/
- public function testEventsWithoutRequestStack()
+ public function testLegacyEventsWithoutRequestStack()
{
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
+
$profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile')
->disableOriginalConstructor()
->getMock();
@@ -86,15 +87,16 @@ class ProfilerListenerTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
+ $requestStack = new RequestStack();
+ $requestStack->push($masterRequest);
+
$onlyException = true;
- $listener = new ProfilerListener($profiler, null, $onlyException);
+ $listener = new ProfilerListener($profiler, null, $onlyException, false, $requestStack);
// master request
- $listener->onKernelRequest(new GetResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST));
$listener->onKernelResponse(new FilterResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST, $response));
// sub request
- $listener->onKernelRequest(new GetResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST));
$listener->onKernelException(new GetResponseForExceptionEvent($kernel, $subRequest, Kernel::SUB_REQUEST, new HttpException(404)));
$listener->onKernelResponse(new FilterResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST, $response));
diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/LegacyApacheMatcherDumperTest.php
similarity index 97%
rename from src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php
rename to src/Symfony/Component/Routing/Tests/Matcher/Dumper/LegacyApacheMatcherDumperTest.php
index 72bee71002..1cdb3d3a5c 100644
--- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php
+++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/LegacyApacheMatcherDumperTest.php
@@ -15,7 +15,7 @@ use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper;
-class ApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase
+class LegacyApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase
{
protected static $fixturesPath;
@@ -24,6 +24,11 @@ class ApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase
self::$fixturesPath = realpath(__DIR__.'/../../Fixtures/');
}
+ public function setUp()
+ {
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
+ }
+
public function testDump()
{
$dumper = new ApacheMatcherDumper($this->getRouteCollection());
diff --git a/src/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/LegacyApacheUrlMatcherTest.php
similarity index 97%
rename from src/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php
rename to src/Symfony/Component/Routing/Tests/Matcher/LegacyApacheUrlMatcherTest.php
index 05e6261a5f..3a02dea0e6 100644
--- a/src/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php
+++ b/src/Symfony/Component/Routing/Tests/Matcher/LegacyApacheUrlMatcherTest.php
@@ -15,12 +15,13 @@ use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Matcher\ApacheUrlMatcher;
-class ApacheUrlMatcherTest extends \PHPUnit_Framework_TestCase
+class LegacyApacheUrlMatcherTest extends \PHPUnit_Framework_TestCase
{
protected $server;
protected function setUp()
{
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->server = $_SERVER;
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
index b47a45b9ca..7792913cb5 100644
--- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
@@ -86,7 +86,8 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
$this->validator->validate('secret', $constraint);
- $this->assertViolation('myMessage');
+ $this->buildViolation('myMessage')
+ ->assertRaised();
}
/**
diff --git a/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php
index e8a1388362..67e7b044e6 100644
--- a/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php
+++ b/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php
@@ -24,8 +24,10 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
$this->assertSame($logger, $loader->getLogger(), '->setLogger() sets the logger instance');
}
- public function testGetSetDebugger()
+ public function testLegacyGetSetDebugger()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$loader = new ProjectTemplateLoader4();
$debugger = $this->getMock('Symfony\Component\Templating\DebuggerInterface');
$loader->setDebugger($debugger);
diff --git a/src/Symfony/Component/Validator/Constraints/GroupSequence.php b/src/Symfony/Component/Validator/Constraints/GroupSequence.php
index de5210285b..72bfb16d2c 100644
--- a/src/Symfony/Component/Validator/Constraints/GroupSequence.php
+++ b/src/Symfony/Component/Validator/Constraints/GroupSequence.php
@@ -55,6 +55,8 @@ use Symfony\Component\Validator\Exception\OutOfBoundsException;
* @author Bernhard Schussek
*
* @api
+ *
+ * Implementing \ArrayAccess, \IteratorAggregate and \Countable is @deprecated since 2.5 and will be removed in 3.0.
*/
class GroupSequence implements \ArrayAccess, \IteratorAggregate, \Countable
{
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php
index 8cc834a908..de274124fe 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php
@@ -53,6 +53,10 @@ abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCa
protected function setUp()
{
+ if (Validation::API_VERSION_2_5 !== $this->getApiVersion()) {
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+ }
+
$this->group = 'MyGroup';
$this->metadata = null;
$this->object = null;
diff --git a/src/Symfony/Component/Validator/Tests/ExecutionContextTest.php b/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php
similarity index 98%
rename from src/Symfony/Component/Validator/Tests/ExecutionContextTest.php
rename to src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php
index 3b54a9e472..88549d5815 100644
--- a/src/Symfony/Component/Validator/Tests/ExecutionContextTest.php
+++ b/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php
@@ -20,7 +20,7 @@ use Symfony\Component\Validator\ExecutionContext;
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
use Symfony\Component\Validator\ValidationVisitor;
-class ExecutionContextTest extends \PHPUnit_Framework_TestCase
+class LegacyExecutionContextTest extends \PHPUnit_Framework_TestCase
{
const TRANS_DOMAIN = 'trans_domain';
@@ -38,6 +38,8 @@ class ExecutionContextTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$this->visitor = $this->getMockBuilder('Symfony\Component\Validator\ValidationVisitor')
->disableOriginalConstructor()
->getMock();
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Cache/ApcCacheTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Cache/LegacyApcCacheTest.php
similarity index 94%
rename from src/Symfony/Component/Validator/Tests/Mapping/Cache/ApcCacheTest.php
rename to src/Symfony/Component/Validator/Tests/Mapping/Cache/LegacyApcCacheTest.php
index 4c7fe790f3..a80e2cb59f 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/Cache/ApcCacheTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Cache/LegacyApcCacheTest.php
@@ -13,10 +13,12 @@ namespace Symfony\Component\Validator\Tests\Mapping\Cache;
use Symfony\Component\Validator\Mapping\Cache\ApcCache;
-class ApcCacheTest extends \PHPUnit_Framework_TestCase
+class LegacyApcCacheTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
if (!extension_loaded('apc') || !ini_get('apc.enable_cli')) {
$this->markTestSkipped('APC is not loaded.');
}
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/BlackholeMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/BlackHoleMetadataFactoryTest.php
similarity index 64%
rename from src/Symfony/Component/Validator/Tests/Mapping/BlackholeMetadataFactoryTest.php
rename to src/Symfony/Component/Validator/Tests/Mapping/Factory/BlackHoleMetadataFactoryTest.php
index 74bcc69d7f..641bf919d4 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/BlackholeMetadataFactoryTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/BlackHoleMetadataFactoryTest.php
@@ -9,24 +9,24 @@
* file that was distributed with this source code.
*/
-namespace Symfony\Component\Validator\Tests\Mapping;
+namespace Symfony\Component\Validator\Tests\Mapping\Factory;
-use Symfony\Component\Validator\Mapping\BlackholeMetadataFactory;
+use Symfony\Component\Validator\Mapping\Factory\BlackHoleMetadataFactory;
-class BlackholeMetadataFactoryTest extends \PHPUnit_Framework_TestCase
+class BlackHoleMetadataFactoryTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \LogicException
*/
public function testGetMetadataForThrowsALogicException()
{
- $metadataFactory = new BlackholeMetadataFactory();
+ $metadataFactory = new BlackHoleMetadataFactory();
$metadataFactory->getMetadataFor('foo');
}
public function testHasMetadataForReturnsFalse()
{
- $metadataFactory = new BlackholeMetadataFactory();
+ $metadataFactory = new BlackHoleMetadataFactory();
$this->assertFalse($metadataFactory->hasMetadataFor('foo'));
}
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php
similarity index 87%
rename from src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php
rename to src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php
index b55985292d..74ee912cb7 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php
@@ -9,21 +9,21 @@
* file that was distributed with this source code.
*/
-namespace Symfony\Component\Validator\Tests\Mapping;
+namespace Symfony\Component\Validator\Tests\Mapping\Factory;
use Symfony\Component\Validator\Mapping\ClassMetadata;
-use Symfony\Component\Validator\Mapping\ClassMetadataFactory;
+use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
-class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
+class LazyLoadingMetadataFactoryTest extends \PHPUnit_Framework_TestCase
{
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
public function testLoadClassMetadata()
{
- $factory = new ClassMetadataFactory(new TestLoader());
+ $factory = new LazyLoadingMetadataFactory(new TestLoader());
$metadata = $factory->getMetadataFor(self::PARENTCLASS);
$constraints = array(
@@ -35,7 +35,7 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
public function testMergeParentConstraints()
{
- $factory = new ClassMetadataFactory(new TestLoader());
+ $factory = new LazyLoadingMetadataFactory(new TestLoader());
$metadata = $factory->getMetadataFor(self::CLASSNAME);
$constraints = array(
@@ -61,7 +61,7 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
public function testWriteMetadataToCache()
{
$cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface');
- $factory = new ClassMetadataFactory(new TestLoader(), $cache);
+ $factory = new LazyLoadingMetadataFactory(new TestLoader(), $cache);
$tester = $this;
$constraints = array(
@@ -90,7 +90,7 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
{
$loader = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface');
$cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface');
- $factory = new ClassMetadataFactory($loader, $cache);
+ $factory = new LazyLoadingMetadataFactory($loader, $cache);
$tester = $this;
$metadata = new ClassMetadata(self::PARENTCLASS);
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/ElementMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/LegacyElementMetadataTest.php
similarity index 94%
rename from src/Symfony/Component/Validator/Tests/Mapping/ElementMetadataTest.php
rename to src/Symfony/Component/Validator/Tests/Mapping/LegacyElementMetadataTest.php
index c2eb4cee79..473eea6176 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/ElementMetadataTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/LegacyElementMetadataTest.php
@@ -15,12 +15,14 @@ use Symfony\Component\Validator\Mapping\ElementMetadata;
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
use Symfony\Component\Validator\Tests\Fixtures\ConstraintB;
-class ElementMetadataTest extends \PHPUnit_Framework_TestCase
+class LegacyElementMetadataTest extends \PHPUnit_Framework_TestCase
{
protected $metadata;
protected function setUp()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$this->metadata = new TestElementMetadata();
}
diff --git a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php
index 62fa87ccf7..fbc045d266 100644
--- a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php
+++ b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php
@@ -633,8 +633,10 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest
/**
* @expectedException \Symfony\Component\Validator\Exception\UnsupportedMetadataException
*/
- public function testPropertyMetadataMustImplementPropertyMetadataInterface()
+ public function testLegacyPropertyMetadataMustImplementPropertyMetadataInterface()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$entity = new Entity();
// Legacy interface
diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php
index 748e106d40..bef0b98177 100644
--- a/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php
+++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php
@@ -42,6 +42,8 @@ abstract class AbstractLegacyApiTest extends AbstractValidatorTest
protected function setUp()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
parent::setUp();
$this->validator = $this->createValidator($this->metadataFactory);
diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php
index 2236d6cb02..26085901fe 100644
--- a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php
@@ -841,8 +841,10 @@ abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase
*
* @expectedException \Symfony\Component\Validator\Exception\ValidatorException
*/
- public function testValidatePropertyFailsIfPropertiesNotSupported()
+ public function testLegacyValidatePropertyFailsIfPropertiesNotSupported()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
// $metadata does not implement PropertyMetadataContainerInterface
$metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');
@@ -971,8 +973,10 @@ abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase
*
* @expectedException \Symfony\Component\Validator\Exception\ValidatorException
*/
- public function testValidatePropertyValueFailsIfPropertiesNotSupported()
+ public function testLegacyValidatePropertyValueFailsIfPropertiesNotSupported()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
// $metadata does not implement PropertyMetadataContainerInterface
$metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');
diff --git a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php
index ba184f7c78..4de62efe99 100644
--- a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php
+++ b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php
@@ -110,8 +110,10 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertSame($this->builder, $this->builder->setTranslationDomain('TRANS_DOMAIN'));
}
- public function testDefaultApiVersion()
+ public function testLegacyDefaultApiVersion()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
if (PHP_VERSION_ID < 50309) {
// Old implementation on PHP < 5.3.9
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
@@ -121,8 +123,10 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
}
}
- public function testSetApiVersion24()
+ public function testLegacySetApiVersion24()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
$this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_4));
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
}
@@ -133,8 +137,10 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('Symfony\Component\Validator\Validator\RecursiveValidator', $this->builder->getValidator());
}
- public function testSetApiVersion24And25()
+ public function testLegacySetApiVersion24And25()
{
+ $this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
+
if (PHP_VERSION_ID < 50309) {
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
}
diff --git a/src/Symfony/Component/Validator/ValidatorBuilder.php b/src/Symfony/Component/Validator/ValidatorBuilder.php
index b4489f4c2b..f0c7e3c7e7 100644
--- a/src/Symfony/Component/Validator/ValidatorBuilder.php
+++ b/src/Symfony/Component/Validator/ValidatorBuilder.php
@@ -23,6 +23,7 @@ use Symfony\Component\Validator\Exception\InvalidArgumentException;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
use Symfony\Component\Validator\Mapping\ClassMetadataFactory;
+use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
use Symfony\Component\Validator\Mapping\Loader\LoaderChain;
use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader;
@@ -345,6 +346,13 @@ class ValidatorBuilder implements ValidatorBuilderInterface
public function getValidator()
{
$metadataFactory = $this->metadataFactory;
+ $apiVersion = $this->apiVersion;
+
+ if (null === $apiVersion) {
+ $apiVersion = PHP_VERSION_ID < 50309
+ ? Validation::API_VERSION_2_4
+ : Validation::API_VERSION_2_5_BC;
+ }
if (!$metadataFactory) {
$loaders = array();
@@ -377,18 +385,15 @@ class ValidatorBuilder implements ValidatorBuilderInterface
$loader = $loaders[0];
}
- $metadataFactory = new ClassMetadataFactory($loader, $this->metadataCache);
+ if (Validation::API_VERSION_2_5 === $apiVersion) {
+ $metadataFactory = new LazyLoadingMetadataFactory($loader, $this->metadataCache);
+ } else {
+ $metadataFactory = new ClassMetadataFactory($loader, $this->metadataCache);
+ }
}
$validatorFactory = $this->validatorFactory ?: new ConstraintValidatorFactory($this->propertyAccessor);
$translator = $this->translator ?: new DefaultTranslator();
- $apiVersion = $this->apiVersion;
-
- if (null === $apiVersion) {
- $apiVersion = PHP_VERSION_ID < 50309
- ? Validation::API_VERSION_2_4
- : Validation::API_VERSION_2_5_BC;
- }
if (Validation::API_VERSION_2_4 === $apiVersion) {
return new ValidatorV24($metadataFactory, $validatorFactory, $translator, $this->translationDomain, $this->initializers);