-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[3.0] [Validator] deprecations cleanup #15708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
df22026
89314c8
fc257bc
b5f40a7
c2b495b
630346a
b594d26
9dcaeb0
4f1b8c9
c8aabb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,55 +20,55 @@ abstract class BaseValidatorExtensionTest extends TypeTestCase | |
{ | ||
public function testValidationGroupNullByDefault() | ||
{ | ||
$form = $this->createForm(); | ||
// $form = $this->createForm(); | ||
|
||
$this->assertNull($form->getConfig()->getOption('validation_groups')); | ||
// $this->assertNull($form->getConfig()->getOption('validation_groups')); | ||
} | ||
|
||
public function testValidationGroupsTransformedToArray() | ||
{ | ||
$form = $this->createForm(array( | ||
'validation_groups' => 'group', | ||
)); | ||
|
||
$this->assertEquals(array('group'), $form->getConfig()->getOption('validation_groups')); | ||
} | ||
|
||
public function testValidationGroupsCanBeSetToArray() | ||
{ | ||
$form = $this->createForm(array( | ||
'validation_groups' => array('group1', 'group2'), | ||
)); | ||
|
||
$this->assertEquals(array('group1', 'group2'), $form->getConfig()->getOption('validation_groups')); | ||
} | ||
|
||
public function testValidationGroupsCanBeSetToFalse() | ||
{ | ||
$form = $this->createForm(array( | ||
'validation_groups' => false, | ||
)); | ||
|
||
$this->assertEquals(array(), $form->getConfig()->getOption('validation_groups')); | ||
} | ||
|
||
public function testValidationGroupsCanBeSetToCallback() | ||
{ | ||
$form = $this->createForm(array( | ||
'validation_groups' => array($this, 'testValidationGroupsCanBeSetToCallback'), | ||
)); | ||
|
||
$this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); | ||
} | ||
|
||
public function testValidationGroupsCanBeSetToClosure() | ||
{ | ||
$form = $this->createForm(array( | ||
'validation_groups' => function (FormInterface $form) { return; }, | ||
)); | ||
|
||
$this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); | ||
} | ||
// public function testValidationGroupsTransformedToArray() | ||
// { | ||
// $form = $this->createForm(array( | ||
// 'validation_groups' => 'group', | ||
// )); | ||
// | ||
// $this->assertEquals(array('group'), $form->getConfig()->getOption('validation_groups')); | ||
// } | ||
// | ||
// public function testValidationGroupsCanBeSetToArray() | ||
// { | ||
// $form = $this->createForm(array( | ||
// 'validation_groups' => array('group1', 'group2'), | ||
// )); | ||
// | ||
// $this->assertEquals(array('group1', 'group2'), $form->getConfig()->getOption('validation_groups')); | ||
// } | ||
// | ||
// public function testValidationGroupsCanBeSetToFalse() | ||
// { | ||
// $form = $this->createForm(array( | ||
// 'validation_groups' => false, | ||
// )); | ||
// | ||
// $this->assertEquals(array(), $form->getConfig()->getOption('validation_groups')); | ||
// } | ||
// | ||
// public function testValidationGroupsCanBeSetToCallback() | ||
// { | ||
// $form = $this->createForm(array( | ||
// 'validation_groups' => array($this, 'testValidationGroupsCanBeSetToCallback'), | ||
// )); | ||
// | ||
// $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); | ||
// } | ||
// | ||
// public function testValidationGroupsCanBeSetToClosure() | ||
// { | ||
// $form = $this->createForm(array( | ||
// 'validation_groups' => function (FormInterface $form) { return; }, | ||
// )); | ||
// | ||
// $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); | ||
// } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these comments must be reverted (any non legacy test should be kept) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, forgotten testing |
||
|
||
abstract protected function createForm(array $options = array()); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,57 +19,47 @@ class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest | |
{ | ||
public function testSubmitValidatesData() | ||
{ | ||
$builder = $this->factory->createBuilder( | ||
'Symfony\Component\Form\Extension\Core\Type\FormType', | ||
null, | ||
array( | ||
'validation_groups' => 'group', | ||
) | ||
); | ||
$builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\FormType'); | ||
$form = $builder->getForm(); | ||
// $builder = $this->factory->createBuilder( | ||
// 'Symfony\Component\Form\Extension\Core\Type\FormType', | ||
// null, | ||
// array( | ||
// 'validation_groups' => 'group', | ||
// ) | ||
// ); | ||
// $builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\FormType'); | ||
// $form = $builder->getForm(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please remove commented code |
||
|
||
$this->validator->expects($this->once()) | ||
->method('validate') | ||
->with($this->equalTo($form)) | ||
->will($this->returnValue(new ConstraintViolationList())); | ||
|
||
// specific data is irrelevant | ||
$form->submit(array()); | ||
} | ||
|
||
public function testValidConstraint() | ||
{ | ||
$form = $this->createForm(array('constraints' => $valid = new Valid())); | ||
|
||
$this->assertSame(array($valid), $form->getConfig()->getOption('constraints')); | ||
} | ||
|
||
public function testValidatorInterfaceSinceSymfony25() | ||
{ | ||
// Mock of ValidatorInterface since apiVersion 2.5 | ||
$validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); | ||
|
||
$formTypeValidatorExtension = new FormTypeValidatorExtension($validator); | ||
$this->assertAttributeSame($validator, 'validator', $formTypeValidatorExtension); | ||
// $this->validator->expects($this->once()) | ||
// ->method('validate') | ||
// ->with($this->equalTo($form)) | ||
// ->will($this->returnValue(new ConstraintViolationList())); | ||
// | ||
// // specific data is irrelevant | ||
// $form->submit(array()); | ||
} | ||
|
||
public function testValidatorInterfaceUntilSymfony24() | ||
{ | ||
// Mock of ValidatorInterface until apiVersion 2.4 | ||
$validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); | ||
// public function testValidConstraint() | ||
// { | ||
// $form = $this->createForm(array('constraints' => $valid = new Valid())); | ||
// | ||
// $this->assertSame(array($valid), $form->getConfig()->getOption('constraints')); | ||
// } | ||
|
||
$formTypeValidatorExtension = new FormTypeValidatorExtension($validator); | ||
$this->assertAttributeSame($validator, 'validator', $formTypeValidatorExtension); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testInvalidValidatorInterface() | ||
{ | ||
new FormTypeValidatorExtension(null); | ||
} | ||
// public function testValidatorInterfaceSinceSymfony25() | ||
// { | ||
// $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); | ||
// | ||
// $formTypeValidatorExtension = new FormTypeValidatorExtension($validator); | ||
// $this->assertAttributeSame($validator, 'validator', $formTypeValidatorExtension); | ||
// } | ||
// | ||
// /** | ||
// * @expectedException \InvalidArgumentException | ||
// */ | ||
// public function testInvalidValidatorInterface() | ||
// { | ||
// new FormTypeValidatorExtension(null); | ||
// } | ||
|
||
protected function createForm(array $options = array()) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are missing a deprecation warning here btw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What needs to be done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a PR should be opened to add the deprecation warning in the 2.7 branch