- return new ConstraintViolation($message, $message, array(), $root, $propertyPath, null);
+ $violations = array(
+ $this->getViolation('Error', null, null, 'code1'),
+ $this->getViolation('Error', null, null, 'code1'),
+ $this->getViolation('Error', null, null, 'code2'),
+ );
+ $list = new ConstraintViolationList($violations);
+
+ $specificErrors = $list->findByCodes($code);
+
+ $this->assertInstanceOf(ConstraintViolationList::class, $specificErrors);
+ $this->assertCount($violationsCount, $specificErrors);
+ }
+
+ public function findByCodesProvider()
+ {
+ return array(
+ array('code1', 2),
+ array(array('code1', 'code2'), 3),
+ array('code3', 0),
+ );
+ }
+
+ protected function getViolation($message, $root = null, $propertyPath = null, $code = null)
+ {
+ return new ConstraintViolation($message, $message, array(), $root, $propertyPath, null, null, $code);