bug #13329 [Form] fixed deprecation triggers, removed usage of deprecated features (fabpot)

This PR was merged into the 2.7 branch.

Discussion
----------

[Form] fixed deprecation triggers, removed usage of deprecated features

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

Commits
-------

60bc402 [Form] fixed deprecation triggers, removed usage of deprecated features
This commit is contained in:
Fabien Potencier 2015-01-08 15:06:23 +01:00
commit 50ed09ed4a
6 changed files with 23 additions and 9 deletions

View File

@ -11,8 +11,6 @@
namespace Symfony\Component\Form\Exception;
trigger_error('The '.__NAMESPACE__.'\AlreadyBoundException class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Exception\AlreadySubmittedException class instead.', E_USER_DEPRECATED);
/**
* Alias of {@link AlreadySubmittedException}.
*
@ -21,4 +19,12 @@ trigger_error('The '.__NAMESPACE__.'\AlreadyBoundException class is deprecated s
*/
class AlreadyBoundException extends LogicException
{
public function __construct($message = '', $code = 0, \Exception $previous = null)
{
if (__CLASS__ === get_class($this)) {
trigger_error('The '.__CLASS__.' class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Exception\AlreadySubmittedException class instead.', E_USER_DEPRECATED);
}
parent::__construct($message, $code, $previous);
}
}

View File

@ -127,8 +127,8 @@ class ViolationMapper implements ViolationMapperInterface
$scope->addError(new FormError(
$violation->getMessage(),
$violation->getMessageTemplate(),
$violation->getMessageParameters(),
$violation->getMessagePluralization(),
$violation->getParameters(),
$violation->getPlural(),
$violation
));
}

View File

@ -791,8 +791,10 @@ class CompoundFormTest extends AbstractFormTest
$this->assertEquals(array('extra' => 'data'), $form->getExtraData());
}
public function testGetErrorsAsStringDeep()
public function testLegacyGetErrorsAsStringDeep()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$parent = $this->getBuilder()
->setCompound(true)
->setDataMapper($this->getDataMapper())
@ -810,8 +812,10 @@ class CompoundFormTest extends AbstractFormTest
);
}
public function testGetErrorsAsStringDeepWithIndentation()
public function testLegacyGetErrorsAsStringDeepWithIndentation()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$parent = $this->getBuilder()
->setCompound(true)
->setDataMapper($this->getDataMapper())

View File

@ -637,8 +637,10 @@ class FormTypeTest extends BaseTypeTest
$this->assertSame('0', $view->vars['label']);
}
public function testCanGetErrorsWhenButtonInForm()
public function testLegacyCanGetErrorsWhenButtonInForm()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$builder = $this->factory->createBuilder('form', null, array(
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
'required' => false,

View File

@ -575,7 +575,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
->add($this->getBuilder('child'))
->getForm();
$form->bind(array('foo' => 'bar'));
$form->submit(array('foo' => 'bar'));
$context->expects($this->never())
->method('addViolation');

View File

@ -733,8 +733,10 @@ class SimpleFormTest extends AbstractFormTest
$this->assertSame($view, $form->createView($parentView));
}
public function testGetErrorsAsString()
public function testLegacyGetErrorsAsString()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->form->addError(new FormError('Error!'));
$this->assertEquals("ERROR: Error!\n", $this->form->getErrorsAsString());