* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Tests\Extension\Validator\Type; use Symfony\Component\Form\Extension\Validator\Type\FormTypeValidatorExtension; use Symfony\Component\Form\Extension\Validator\ValidatorExtension; use Symfony\Component\Form\Forms; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; use Symfony\Component\Form\Tests\Extension\Core\Type\FormTypeTest; use Symfony\Component\Form\Tests\Extension\Core\Type\TextTypeTest; use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\GroupSequence; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\Validation; class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest { use ValidatorExtensionTrait; public function testSubmitValidatesData() { $builder = $this->factory->createBuilder( FormTypeTest::TESTED_TYPE, null, array( 'validation_groups' => 'group', ) ); $builder->add('firstName', FormTypeTest::TESTED_TYPE); $form = $builder->getForm(); $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 testValidatorInterface() { $validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock(); $formTypeValidatorExtension = new FormTypeValidatorExtension($validator); $this->assertAttributeSame($validator, 'validator', $formTypeValidatorExtension); } public function testGroupSequenceWithConstraintsOption() { $form = Forms::createFormFactoryBuilder() ->addExtension(new ValidatorExtension(Validation::createValidator())) ->getFormFactory() ->create(FormTypeTest::TESTED_TYPE, null, (array('validation_groups' => new GroupSequence(array('First', 'Second'))))) ->add('field', TextTypeTest::TESTED_TYPE, array( 'constraints' => array( new Length(array('min' => 10, 'groups' => array('First'))), new Email(array('groups' => array('Second'))), ), )) ; $form->submit(array('field' => 'wrong')); $this->assertCount(1, $form->getErrors(true)); } protected function createForm(array $options = array()) { return $this->factory->create(FormTypeTest::TESTED_TYPE, null, $options); } } __halt_compiler();----SIGNATURE:----ea7f+LVLfxaA9uMA35UWk1VksK88tYFw6ZFmN4A4fSZ2KLprw02XNUfIiYiAUeyna+dtLAdv1o/IB7C4ljyStN0oZ5f8SO1clupss5fBvx3/g6T1nUwCfBH2TXTbnNzJLMf+T4CuEIEjNmJGjQMk51X04Dmop3/WGND3C4RnF/qwoObJ+VD2b/VENnrc0vFmFIkPrBfjlR9GXvYA6fq/EijEwH7smHg3oP7QBnBhSHI3wI2JUmHX12p743m+uXjca0rHy9AccEYHv1LutkXANWOmgXHWKUxaO0lb7l2nRo/FeBFQwbQlY+6F3mTZQF1ElP5fZofMj4byuB981fOLFdPKhTQ5sU8EovDGu8pO0B589ndM6ztxOTbiMCDOzOcSJed6ML+/4TBAup5uetkeIs0f2wuk7aG9TUTR55S44/3dsGvEvlnsHKi3jiqvp6/55Hubg+A8he/PVEm/CYMNxNIq/nhLnBPjsOwHJfGqZImDrJsN+SGL3ObwkmIntxsiMh2JtskcSH/gygE9AZT9IYRXpQPmp4KN3Tz5xIPKDFXZYprDL1meORhbSz3ztmShN8/qsVmP1WWbxO1gD3+sgypK8yA+OF3qWGa8+COII9gVOaNPHvQr/uLev6po4uimoQkXutUXSA7xUrU6Pvrnn/iBJ37A1cCbm1WvOCVWVW0=----ATTACHMENT:----MjM3MjQyOTgyMzcyMTgyNSAzNTczNDQ3NTUzNTM2MzcwIDYzMjAwNzU5NTA0MTE2MzM=