Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Enhanced the triggering of E_USER_DEPRECATED errors

- Removed useless error handlers around FormEvent as the triggering has
  been fixed in it.
- Enhanced the triggering of deprecation errors for places where the BC
  method provide some user logic needing to be converted to a new way.
- Enhanced the deprecation messages to mention the replacement whenever
  possible.
  • Loading branch information...
commit 5412a4e398b668cb25131961e816ccc158290f5e 1 parent 2d5bede
Christophe Coevoet stof authored
22 AbstractType.php
View
@@ -51,10 +51,20 @@ public function finishView(FormView $view, FormInterface $form, array $options)
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
- set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
- $resolver->setDefaults($this->getDefaultOptions(array()));
- $resolver->addAllowedValues($this->getAllowedOptionValues(array()));
- restore_error_handler();
+ $defaults = $this->getDefaultOptions(array());
+ $allowedTypes = $this->getAllowedOptionValues(array());
+
+ if (!empty($defaults)) {
+ trigger_error('getDefaultOptions() is deprecated since version 2.1 and will be removed in 2.3. Use setDefaultOptions() instead.', E_USER_DEPRECATED);
+
+ $resolver->setDefaults($defaults);
+ }
+
+ if (!empty($allowedTypes)) {
+ trigger_error('getAllowedOptionValues() is deprecated since version 2.1 and will be removed in 2.3. Use setDefaultOptions() instead.', E_USER_DEPRECATED);
+
+ $resolver->addAllowedValues($allowedTypes);
+ }
}
/**
@@ -69,8 +79,6 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
*/
public function getDefaultOptions(array $options)
{
- trigger_error('getDefaultOptions() is deprecated since version 2.1 and will be removed in 2.3. Use setDefaultOptions() instead.', E_USER_DEPRECATED);
-
return array();
}
@@ -86,8 +94,6 @@ public function getDefaultOptions(array $options)
*/
public function getAllowedOptionValues(array $options)
{
- trigger_error('getAllowedOptionValues() is deprecated since version 2.1 and will be removed in 2.3. Use setDefaultOptions() instead.', E_USER_DEPRECATED);
-
return array();
}
22 AbstractTypeExtension.php
View
@@ -44,10 +44,20 @@ public function finishView(FormView $view, FormInterface $form, array $options)
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
- set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
- $resolver->setDefaults($this->getDefaultOptions());
- $resolver->addAllowedValues($this->getAllowedOptionValues());
- restore_error_handler();
+ $defaults = $this->getDefaultOptions(array());
+ $allowedTypes = $this->getAllowedOptionValues(array());
+
+ if (!empty($defaults)) {
+ trigger_error('getDefaultOptions() is deprecated since version 2.1 and will be removed in 2.3. Use setDefaultOptions() instead.', E_USER_DEPRECATED);
+
+ $resolver->setDefaults($defaults);
+ }
+
+ if (!empty($allowedTypes)) {
+ trigger_error('getAllowedOptionValues() is deprecated since version 2.1 and will be removed in 2.3. Use setDefaultOptions() instead.', E_USER_DEPRECATED);
+
+ $resolver->addAllowedValues($allowedTypes);
+ }
}
/**
@@ -60,8 +70,6 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
*/
public function getDefaultOptions()
{
- trigger_error('getDefaultOptions() is deprecated since version 2.1 and will be removed in 2.3. Use setDefaultOptions() instead.', E_USER_DEPRECATED);
-
return array();
}
@@ -75,8 +83,6 @@ public function getDefaultOptions()
*/
public function getAllowedOptionValues()
{
- trigger_error('getAllowedOptionValues() is deprecated since version 2.1 and will be removed in 2.3. Use setDefaultOptions() instead.', E_USER_DEPRECATED);
-
return array();
}
}
2  CallbackValidator.php
View
@@ -27,7 +27,7 @@ class CallbackValidator implements FormValidatorInterface
*/
public function __construct($callback)
{
- trigger_error('CallbackValidator is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
+ trigger_error('CallbackValidator is deprecated since version 2.1 and will be removed in 2.3. Use the FormEvents::POST_BIND event instead.', E_USER_DEPRECATED);
$this->callback = $callback;
}
23 Form.php
View
@@ -367,11 +367,12 @@ public function setData($modelData)
// Hook to change content of the data
if ($dispatcher->hasListeners(FormEvents::PRE_SET_DATA) || $dispatcher->hasListeners(FormEvents::SET_DATA)) {
- set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
$event = new FormEvent($this, $modelData);
- restore_error_handler();
$dispatcher->dispatch(FormEvents::PRE_SET_DATA, $event);
// BC until 2.3
+ if ($dispatcher->hasListeners(FormEvents::SET_DATA)) {
+ trigger_error('The FormEvents::SET_DATA event is deprecated since 2.1 and will be removed in 2.3. Use the FormEvents::PRE_SET_DATA event instead.', E_USER_DEPRECATED);
+ }
$dispatcher->dispatch(FormEvents::SET_DATA, $event);
$modelData = $event->getData();
}
@@ -532,11 +533,12 @@ public function bind($submittedData)
// Hook to change content of the data bound by the browser
if ($dispatcher->hasListeners(FormEvents::PRE_BIND) || $dispatcher->hasListeners(FormEvents::BIND_CLIENT_DATA)) {
- set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
$event = new FormEvent($this, $submittedData);
- restore_error_handler();
$dispatcher->dispatch(FormEvents::PRE_BIND, $event);
// BC until 2.3
+ if ($dispatcher->hasListeners(FormEvents::BIND_CLIENT_DATA)) {
+ trigger_error('The FormEvents::BIND_CLIENT_DATA event is deprecated since 2.1 and will be removed in 2.3. Use the FormEvents::PRE_BIND event instead.', E_USER_DEPRECATED);
+ }
$dispatcher->dispatch(FormEvents::BIND_CLIENT_DATA, $event);
$submittedData = $event->getData();
}
@@ -594,11 +596,12 @@ public function bind($submittedData)
// Hook to change content of the data into the normalized
// representation
if ($dispatcher->hasListeners(FormEvents::BIND) || $dispatcher->hasListeners(FormEvents::BIND_NORM_DATA)) {
- set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
$event = new FormEvent($this, $normData);
- restore_error_handler();
$dispatcher->dispatch(FormEvents::BIND, $event);
// BC until 2.3
+ if ($dispatcher->hasListeners(FormEvents::BIND_NORM_DATA)) {
+ trigger_error('The FormEvents::BIND_NORM_DATA event is deprecated since 2.1 and will be removed in 2.3. Use the FormEvents::BIND event instead.', E_USER_DEPRECATED);
+ }
$dispatcher->dispatch(FormEvents::BIND_NORM_DATA, $event);
$normData = $event->getData();
}
@@ -621,10 +624,14 @@ public function bind($submittedData)
}
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
- foreach ($this->config->getValidators() as $validator) {
+ $validators = $this->config->getValidators();
+ restore_error_handler();
+
+ foreach ($validators as $validator) {
+ trigger_error(sprintf('FormConfigInterface::getValidators() is deprecated since 2.1 and will be removed in 2.3. Convert your %s class to a listener on the FormEvents::POST_BIND event.', get_class($validator)), E_USER_DEPRECATED);
+
$validator->validate($this);
}
- restore_error_handler();
return $this;
}
4 FormBuilder.php
View
@@ -301,12 +301,12 @@ public function getIterator()
*/
public function getTypes()
{
+ trigger_error('getTypes() is deprecated since version 2.1 and will be removed in 2.3. Use getConfig() and FormConfigInterface::getType() instead.', E_USER_DEPRECATED);
+
if ($this->locked) {
throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}
- trigger_error('getTypes() is deprecated since version 2.1 and will be removed in 2.3. Use getConfig() and FormConfigInterface::getType() instead.', E_USER_DEPRECATED);
-
$types = array();
for ($type = $this->getType(); null !== $type; $type = $type->getParent()) {
12 Test/DeprecationErrorHandler.php
View
@@ -2,9 +2,6 @@
namespace Symfony\Component\Form\Test;
-use Symfony\Component\Form\FormInterface as NonTestFormInterface;
-use Symfony\Component\Form\FormEvent;
-
class DeprecationErrorHandler
{
public static function handle($errorNumber, $message, $file, $line, $context)
@@ -24,13 +21,4 @@ public static function handleBC($errorNumber, $message, $file, $line, $context)
return false;
}
-
- public static function getFormEvent(NonTestFormInterface $form, $data)
- {
- set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
- $event = new FormEvent($form, $data);
- restore_error_handler();
-
- return $event;
- }
}
4 Tests/CompoundFormTest.php
View
@@ -231,9 +231,7 @@ public function testRemove()
$this->form->remove('foo');
$this->assertNull($child->getParent());
- set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
- $this->assertFalse($this->form->hasChildren());
- restore_error_handler();
+ $this->assertCount(0, $this->form);
}
/**
8 Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php
View
@@ -11,9 +11,9 @@
namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
+use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\Extension\Core\EventListener\FixRadioInputListener;
use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
-use Symfony\Component\Form\Test\DeprecationErrorHandler;
class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
{
@@ -42,7 +42,7 @@ public function testFixRadio()
{
$data = '1';
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
- $event = DeprecationErrorHandler::getFormEvent($form, $data);
+ $event = new FormEvent($form, $data);
$this->listener->preBind($event);
@@ -53,7 +53,7 @@ public function testFixZero()
{
$data = '0';
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
- $event = DeprecationErrorHandler::getFormEvent($form, $data);
+ $event = new FormEvent($form, $data);
$this->listener->preBind($event);
@@ -64,7 +64,7 @@ public function testIgnoreEmptyString()
{
$data = '';
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
- $event = DeprecationErrorHandler::getFormEvent($form, $data);
+ $event = new FormEvent($form, $data);
$this->listener->preBind($event);
8 Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php
View
@@ -11,8 +11,8 @@
namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
+use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\Extension\Core\EventListener\FixUrlProtocolListener;
-use Symfony\Component\Form\Test\DeprecationErrorHandler;
class FixUrlProtocolListenerTest extends \PHPUnit_Framework_TestCase
{
@@ -27,7 +27,7 @@ public function testFixHttpUrl()
{
$data = "www.symfony.com";
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
- $event = DeprecationErrorHandler::getFormEvent($form, $data);
+ $event = new FormEvent($form, $data);
$filter = new FixUrlProtocolListener('http');
$filter->onBind($event);
@@ -39,7 +39,7 @@ public function testSkipKnownUrl()
{
$data = "http://www.symfony.com";
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
- $event = DeprecationErrorHandler::getFormEvent($form, $data);
+ $event = new FormEvent($form, $data);
$filter = new FixUrlProtocolListener('http');
$filter->onBind($event);
@@ -51,7 +51,7 @@ public function testSkipOtherProtocol()
{
$data = "ftp://www.symfony.com";
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
- $event = DeprecationErrorHandler::getFormEvent($form, $data);
+ $event = new FormEvent($form, $data);
$filter = new FixUrlProtocolListener('http');
$filter->onBind($event);
20 Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php
View
@@ -11,8 +11,8 @@
namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
+use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\Extension\Core\EventListener\MergeCollectionListener;
-use Symfony\Component\Form\Test\DeprecationErrorHandler;
abstract class MergeCollectionListenerTest extends \PHPUnit_Framework_TestCase
{
@@ -84,7 +84,7 @@ public function testAddExtraEntriesIfAllowAdd($allowDelete)
$this->form->setData($originalData);
- $event = DeprecationErrorHandler::getFormEvent($this->form, $newData);
+ $event = new FormEvent($this->form, $newData);
$listener->onBind($event);
// The original object was modified
@@ -108,7 +108,7 @@ public function testAddExtraEntriesIfAllowAddDontOverwriteExistingIndices($allow
$this->form->setData($originalData);
- $event = DeprecationErrorHandler::getFormEvent($this->form, $newData);
+ $event = new FormEvent($this->form, $newData);
$listener->onBind($event);
// The original object was modified
@@ -133,7 +133,7 @@ public function testDoNothingIfNotAllowAdd($allowDelete)
$this->form->setData($originalData);
- $event = DeprecationErrorHandler::getFormEvent($this->form, $newData);
+ $event = new FormEvent($this->form, $newData);
$listener->onBind($event);
// We still have the original object
@@ -157,7 +157,7 @@ public function testRemoveMissingEntriesIfAllowDelete($allowAdd)
$this->form->setData($originalData);
- $event = DeprecationErrorHandler::getFormEvent($this->form, $newData);
+ $event = new FormEvent($this->form, $newData);
$listener->onBind($event);
// The original object was modified
@@ -182,7 +182,7 @@ public function testDoNothingIfNotAllowDelete($allowAdd)
$this->form->setData($originalData);
- $event = DeprecationErrorHandler::getFormEvent($this->form, $newData);
+ $event = new FormEvent($this->form, $newData);
$listener->onBind($event);
// We still have the original object
@@ -201,7 +201,7 @@ public function testDoNothingIfNotAllowDelete($allowAdd)
public function testRequireArrayOrTraversable($allowAdd, $allowDelete)
{
$newData = 'no array or traversable';
- $event = DeprecationErrorHandler::getFormEvent($this->form, $newData);
+ $event = new FormEvent($this->form, $newData);
$listener = new MergeCollectionListener($allowAdd, $allowDelete);
$listener->onBind($event);
}
@@ -215,7 +215,7 @@ public function testDealWithNullData()
$this->form->setData($originalData);
- $event = DeprecationErrorHandler::getFormEvent($this->form, $newData);
+ $event = new FormEvent($this->form, $newData);
$listener->onBind($event);
$this->assertSame($originalData, $event->getData());
@@ -233,7 +233,7 @@ public function testDealWithNullOriginalDataIfAllowAdd($allowDelete)
$this->form->setData($originalData);
- $event = DeprecationErrorHandler::getFormEvent($this->form, $newData);
+ $event = new FormEvent($this->form, $newData);
$listener->onBind($event);
$this->assertSame($newData, $event->getData());
@@ -251,7 +251,7 @@ public function testDontDealWithNullOriginalDataIfNotAllowAdd($allowDelete)
$this->form->setData($originalData);
- $event = DeprecationErrorHandler::getFormEvent($this->form, $newData);
+ $event = new FormEvent($this->form, $newData);
$listener->onBind($event);
$this->assertNull($event->getData());
30 Tests/Extension/Core/EventListener/ResizeFormListenerTest.php
View
@@ -13,7 +13,7 @@
use Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener;
use Symfony\Component\Form\FormBuilder;
-use Symfony\Component\Form\Test\DeprecationErrorHandler;
+use Symfony\Component\Form\FormEvent;
class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase
{
@@ -80,7 +80,7 @@ public function testPreSetDataResizesForm()
->will($this->returnValue($this->getForm('2')));
$data = array(1 => 'string', 2 => 'string');
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array('max_length' => '10'), false, false);
$listener->preSetData($event);
@@ -95,7 +95,7 @@ public function testPreSetDataResizesForm()
public function testPreSetDataRequiresArrayOrTraversable()
{
$data = 'no array or traversable';
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, false);
$listener->preSetData($event);
}
@@ -105,7 +105,7 @@ public function testPreSetDataDealsWithNullData()
$this->factory->expects($this->never())->method('createNamed');
$data = null;
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, false);
$listener->preSetData($event);
}
@@ -120,7 +120,7 @@ public function testPreBindResizesUpIfAllowAdd()
->will($this->returnValue($this->getForm('1')));
$data = array(0 => 'string', 1 => 'string');
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array('max_length' => 10), true, false);
$listener->preBind($event);
@@ -134,7 +134,7 @@ public function testPreBindResizesDownIfAllowDelete()
$this->form->add($this->getForm('1'));
$data = array(0 => 'string');
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, true);
$listener->preBind($event);
@@ -148,7 +148,7 @@ public function testPreBindRemovesZeroKeys()
$this->form->add($this->getForm('0'));
$data = array();
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, true);
$listener->preBind($event);
@@ -161,7 +161,7 @@ public function testPreBindDoesNothingIfNotAllowAddNorAllowDelete()
$this->form->add($this->getForm('1'));
$data = array(0 => 'string', 2 => 'string');
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, false);
$listener->preBind($event);
@@ -176,7 +176,7 @@ public function testPreBindDoesNothingIfNotAllowAddNorAllowDelete()
public function testPreBindRequiresArrayOrTraversable()
{
$data = 'no array or traversable';
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, false);
$listener->preBind($event);
}
@@ -186,7 +186,7 @@ public function testPreBindDealsWithNullData()
$this->form->add($this->getForm('1'));
$data = null;
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, true);
$listener->preBind($event);
@@ -199,7 +199,7 @@ public function testPreBindDealsWithEmptyData()
$this->form->add($this->getForm('1'));
$data = '';
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, true);
$listener->preBind($event);
@@ -211,7 +211,7 @@ public function testOnBindNormDataRemovesEntriesMissingInTheFormIfAllowDelete()
$this->form->add($this->getForm('1'));
$data = array(0 => 'first', 1 => 'second', 2 => 'third');
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, true);
$listener->onBind($event);
@@ -223,7 +223,7 @@ public function testOnBindNormDataDoesNothingIfNotAllowDelete()
$this->form->add($this->getForm('1'));
$data = array(0 => 'first', 1 => 'second', 2 => 'third');
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, false);
$listener->onBind($event);
@@ -236,7 +236,7 @@ public function testOnBindNormDataDoesNothingIfNotAllowDelete()
public function testOnBindNormDataRequiresArrayOrTraversable()
{
$data = 'no array or traversable';
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, false);
$listener->onBind($event);
}
@@ -246,7 +246,7 @@ public function testOnBindNormDataDealsWithNullData()
$this->form->add($this->getForm('1'));
$data = null;
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, true);
$listener->onBind($event);
8 Tests/Extension/Core/EventListener/TrimListenerTest.php
View
@@ -11,8 +11,8 @@
namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
+use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\Extension\Core\EventListener\TrimListener;
-use Symfony\Component\Form\Test\DeprecationErrorHandler;
class TrimListenerTest extends \PHPUnit_Framework_TestCase
{
@@ -27,7 +27,7 @@ public function testTrim()
{
$data = " Foo! ";
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
- $event = DeprecationErrorHandler::getFormEvent($form, $data);
+ $event = new FormEvent($form, $data);
$filter = new TrimListener();
$filter->preBind($event);
@@ -39,7 +39,7 @@ public function testTrimSkipNonStrings()
{
$data = 1234;
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
- $event = DeprecationErrorHandler::getFormEvent($form, $data);
+ $event = new FormEvent($form, $data);
$filter = new TrimListener();
$filter->preBind($event);
@@ -60,7 +60,7 @@ public function testTrimUtf8($chars)
$data = $data."ab\ncd".$data;
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
- $event = DeprecationErrorHandler::getFormEvent($form, $data);
+ $event = new FormEvent($form, $data);
$filter = new TrimListener();
$filter->preBind($event);
4 Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php
View
@@ -12,8 +12,8 @@
namespace Symfony\Component\Form\Tests\Extension\Csrf\EventListener;
use Symfony\Component\Form\FormBuilder;
+use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener;
-use Symfony\Component\Form\Test\DeprecationErrorHandler;
class CsrfValidationListenerTest extends \PHPUnit_Framework_TestCase
{
@@ -67,7 +67,7 @@ protected function getMockForm()
public function testStringFormData()
{
$data = "XP4HUzmHPi";
- $event = DeprecationErrorHandler::getFormEvent($this->form, $data);
+ $event = new FormEvent($this->form, $data);
$validation = new CsrfValidationListener('csrf', $this->csrfProvider, 'unknown');
$validation->preBind($event);
18 Tests/Extension/HttpFoundation/EventListener/BindRequestListenerTest.php
View
@@ -14,9 +14,9 @@
use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormConfigBuilder;
+use Symfony\Component\Form\FormEvent;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\File\UploadedFile;
-use Symfony\Component\Form\Test\DeprecationErrorHandler;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
@@ -98,7 +98,7 @@ public function testBindRequest($method)
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$config = new FormConfigBuilder('author', null, $dispatcher);
$form = new Form($config);
- $event = DeprecationErrorHandler::getFormEvent($form, $request);
+ $event = new FormEvent($form, $request);
$listener = new BindRequestListener();
$listener->preBind($event);
@@ -125,7 +125,7 @@ public function testBindRequestWithEmptyName($method)
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$config = new FormConfigBuilder('', null, $dispatcher);
$form = new Form($config);
- $event = DeprecationErrorHandler::getFormEvent($form, $request);
+ $event = new FormEvent($form, $request);
$listener = new BindRequestListener();
$listener->preBind($event);
@@ -154,7 +154,7 @@ public function testBindEmptyRequestToCompoundForm($method)
$config->setCompound(true);
$config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface'));
$form = new Form($config);
- $event = DeprecationErrorHandler::getFormEvent($form, $request);
+ $event = new FormEvent($form, $request);
$listener = new BindRequestListener();
$listener->preBind($event);
@@ -180,7 +180,7 @@ public function testBindEmptyRequestToSimpleForm($method)
$config = new FormConfigBuilder('author', null, $dispatcher);
$config->setCompound(false);
$form = new Form($config);
- $event = DeprecationErrorHandler::getFormEvent($form, $request);
+ $event = new FormEvent($form, $request);
$listener = new BindRequestListener();
$listener->preBind($event);
@@ -203,7 +203,7 @@ public function testBindGetRequest()
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$config = new FormConfigBuilder('author', null, $dispatcher);
$form = new Form($config);
- $event = DeprecationErrorHandler::getFormEvent($form, $request);
+ $event = new FormEvent($form, $request);
$listener = new BindRequestListener();
$listener->preBind($event);
@@ -227,7 +227,7 @@ public function testBindGetRequestWithEmptyName()
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$config = new FormConfigBuilder('', null, $dispatcher);
$form = new Form($config);
- $event = DeprecationErrorHandler::getFormEvent($form, $request);
+ $event = new FormEvent($form, $request);
$listener = new BindRequestListener();
$listener->preBind($event);
@@ -253,7 +253,7 @@ public function testBindEmptyGetRequestToCompoundForm()
$config->setCompound(true);
$config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface'));
$form = new Form($config);
- $event = DeprecationErrorHandler::getFormEvent($form, $request);
+ $event = new FormEvent($form, $request);
$listener = new BindRequestListener();
$listener->preBind($event);
@@ -275,7 +275,7 @@ public function testBindEmptyGetRequestToSimpleForm()
$config = new FormConfigBuilder('author', null, $dispatcher);
$config->setCompound(false);
$form = new Form($config);
- $event = DeprecationErrorHandler::getFormEvent($form, $request);
+ $event = new FormEvent($form, $request);
$listener = new BindRequestListener();
$listener->preBind($event);
10 Tests/Extension/Validator/EventListener/ValidationListenerTest.php
View
@@ -11,14 +11,12 @@
namespace Symfony\Component\Form\Tests\Extension\Validator\EventListener;
-use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormBuilder;
-use Symfony\Component\Form\FormError;
+use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\Util\PropertyPath;
use Symfony\Component\Form\Extension\Validator\Constraints\Form;
use Symfony\Component\Form\Extension\Validator\EventListener\ValidationListener;
use Symfony\Component\Validator\ConstraintViolation;
-use Symfony\Component\Form\Test\DeprecationErrorHandler;
class ValidationListenerTest extends \PHPUnit_Framework_TestCase
{
@@ -109,7 +107,7 @@ public function testMapViolation()
->method('mapViolation')
->with($violation, $form, false);
- $this->listener->validateForm(DeprecationErrorHandler::getFormEvent($form, null));
+ $this->listener->validateForm(new FormEvent($form, null));
}
public function testMapViolationAllowsNonSyncIfInvalid()
@@ -126,7 +124,7 @@ public function testMapViolationAllowsNonSyncIfInvalid()
// pass true now
->with($violation, $form, true);
- $this->listener->validateForm(DeprecationErrorHandler::getFormEvent($form, null));
+ $this->listener->validateForm(new FormEvent($form, null));
}
public function testValidateIgnoresNonRoot()
@@ -142,6 +140,6 @@ public function testValidateIgnoresNonRoot()
$this->violationMapper->expects($this->never())
->method('mapViolation');
- $this->listener->validateForm(DeprecationErrorHandler::getFormEvent($form, null));
+ $this->listener->validateForm(new FormEvent($form, null));
}
}
3  Tests/SimpleFormTest.php
View
@@ -648,7 +648,6 @@ public function testBindValidatesAfterTransformation()
$form = $this->getBuilder()
->addValidator($validator)
->getForm();
- restore_error_handler();
$validator->expects($this->once())
->method('validate')
@@ -658,6 +657,8 @@ public function testBindValidatesAfterTransformation()
}));
$form->bind('foobar');
+
+ restore_error_handler();
}
public function testBindResetsErrors()
Please sign in to comment.
Something went wrong with that request. Please try again.