X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fvalidator%2FTests%2FConstraintViolationListTest.php;h=f0e6afe20da3f67eccd2a2601902fe7a47ee8be1;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=6f4518cab39e45373c37d9b3ac4a5ac5605fa119;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/validator/Tests/ConstraintViolationListTest.php b/vendor/symfony/validator/Tests/ConstraintViolationListTest.php index 6f4518cab..f0e6afe20 100644 --- a/vendor/symfony/validator/Tests/ConstraintViolationListTest.php +++ b/vendor/symfony/validator/Tests/ConstraintViolationListTest.php @@ -89,16 +89,16 @@ class ConstraintViolationListTest extends TestCase $this->list[] = $violation; $this->assertSame($violation, $this->list[0]); - $this->assertTrue(isset($this->list[0])); + $this->assertArrayHasKey(0, $this->list); unset($this->list[0]); - $this->assertFalse(isset($this->list[0])); + $this->assertArrayNotHasKey(0, $this->list); $this->list[10] = $violation; $this->assertSame($violation, $this->list[10]); - $this->assertTrue(isset($this->list[10])); + $this->assertArrayHasKey(10, $this->list); } public function testToString() @@ -128,8 +128,35 @@ EOF; $this->assertEquals($expected, (string) $this->list); } - protected function getViolation($message, $root = null, $propertyPath = null) + /** + * @dataProvider findByCodesProvider + */ + public function testFindByCodes($code, $violationsCount) { - 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); } }