* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormErrorIterator; use Symfony\Component\Validator\ConstraintViolation; class FormErrorIteratorTest extends TestCase { /** * @dataProvider findByCodesProvider */ public function testFindByCodes($code, $violationsCount) { if (!class_exists(ConstraintViolation::class)) { $this->markTestSkipped('Validator component required.'); } $formBuilder = new FormBuilder( 'form', null, new EventDispatcher(), $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(), array() ); $form = $formBuilder->getForm(); $cause = new ConstraintViolation('Error 1!', null, array(), null, '', null, null, 'code1'); $form->addError(new FormError('Error 1!', null, array(), null, $cause)); $cause = new ConstraintViolation('Error 2!', null, array(), null, '', null, null, 'code1'); $form->addError(new FormError('Error 2!', null, array(), null, $cause)); $cause = new ConstraintViolation('Error 3!', null, array(), null, '', null, null, 'code2'); $form->addError(new FormError('Error 3!', null, array(), null, $cause)); $formErrors = $form->getErrors(); $specificFormErrors = $formErrors->findByCodes($code); $this->assertInstanceOf(FormErrorIterator::class, $specificFormErrors); $this->assertCount($violationsCount, $specificFormErrors); } public function findByCodesProvider() { return array( array('code1', 2), array(array('code1', 'code2'), 3), array('code3', 0), ); } } __halt_compiler();----SIGNATURE:----Xdprv1v8/sf14ftfdsqmUJT2G441IGijBvJA5FK0cU5KRqlg/JxcaKvuSp2ikRVptzWEth30FPexx0dfUf2fNq+n234qKg5iaHQCimpct1MaLbaadZZa93QxgI19oV8RbmAI75WL+gnC9JFzdIqNlDu0Bz9t+HqPo/mVS76l2+qinezcyc1BRwC2lAX0YNM6TZumUB1pwNCY1IMandfEzXthJMqv64ISnjExy7gF7Gd1isGG7SHE7TPbiPo7OmgtTQ4UBp7WWoXJmZ7G+W4MhbzyFUkVU57F5bZJFRQvHcalhV7B6C27FUF0FxAzkH4P6m0AWI3FajVtNJWJxrM8niFyRJ1n/Z+PUZSTl41hwwpGLKRYo+pdLoKnaLAWeuSEdGQdX1BLYN5f7temSJN1l5BtWg8hzuwq8TMyv3bTdhS7gz6IlhAjtodhz9lNoG9MEZLNdG+1k4OOQ2H4lpUYnA1O5FTFZt3mlahjaIvqvhzpn51M7v/e1LIQhuaQOzTHgysPycPEr5djw4kkhJZe65hDzcRwG5rwH6joasmMSLZuqzgcuLB9XC5tBfKLkt8U+cwxwFU8JzfQ76BRck05KZJ/5QI7jqfxwysAZoIKCfA6qHGqcv5hbIuNPcPJ7UEy/Xy3foM9YIQ8peurCPJ7b7Fcy/sGBAkArvLUJ8qahm8=----ATTACHMENT:----NzU3NTE0OTE1NTgwODg4NiA2MzczODcxMjEyMjQxNTU0IDU0NTY0NTE3Nzc4NjQ0ODY=