* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\DataCollector; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\DataCollector\ValidatorDataCollector; use Symfony\Component\Validator\Validator\TraceableValidator; use Symfony\Component\Validator\Validator\ValidatorInterface; class ValidatorDataCollectorTest extends TestCase { public function testCollectsValidatorCalls() { $originalValidator = $this->createMock(ValidatorInterface::class); $validator = new TraceableValidator($originalValidator); $collector = new ValidatorDataCollector($validator); $violations = new ConstraintViolationList(array( $this->createMock(ConstraintViolation::class), $this->createMock(ConstraintViolation::class), )); $originalValidator->method('validate')->willReturn($violations); $validator->validate(new \stdClass()); $collector->lateCollect(); $calls = $collector->getCalls(); $this->assertCount(1, $calls); $this->assertSame(2, $collector->getViolationsCount()); $call = $calls[0]; $this->assertArrayHasKey('caller', $call); $this->assertArrayHasKey('context', $call); $this->assertArrayHasKey('violations', $call); $this->assertCount(2, $call['violations']); } public function testReset() { $originalValidator = $this->createMock(ValidatorInterface::class); $validator = new TraceableValidator($originalValidator); $collector = new ValidatorDataCollector($validator); $violations = new ConstraintViolationList(array( $this->createMock(ConstraintViolation::class), $this->createMock(ConstraintViolation::class), )); $originalValidator->method('validate')->willReturn($violations); $validator->validate(new \stdClass()); $collector->lateCollect(); $collector->reset(); $this->assertCount(0, $collector->getCalls()); $this->assertSame(0, $collector->getViolationsCount()); } protected function createMock($classname) { return $this->getMockBuilder($classname)->disableOriginalConstructor()->getMock(); } } __halt_compiler();----SIGNATURE:----Hnnc5PorLHrYcyEKddKm/G4OicHn409iT6OCZ9cC+Gr4O8QMtZnKTYdqM1CGy7tGcoKwFhTYOSg+bHrNUHf///cHbB/XUFsCvD1DrQv9Vd4RkwBDzWktDySQjgnae3YrdOYUwNaDCg6gp6xrpFuMByOOgsNnzucfxt+K/iw8npod6yd0fVmGrraPvhimwHwfyPBcThRDKybMnZDgDuko+14jBgBnehFEALjMI20Pu0GnrjU0XAcMQF2Xxh5Se2yQro79vZJDoGOPVTEl+Sj5kG4F1Tfc9hYTrQkfUYEV/GzOr6azcElNSwC6YmMNdkjjTquCCCbi7Dua8HRHVB17MuGqGH3Y2rlZTIkAYczL6MjuZUgPTJYR4+ognKkQ5ECUxlGCqg3jo/l0/oz5ptQofJ1CL8JLcKV/RMB3gBodxKzTaCTNbeivfc+nTEK24/q2//gpTeiFkXJiafW33hpt4Geley+V8Jr+KVgMxPAGwUUkhy8E/qjVwhYVJHS84B4A+sQHy2/pJKDXRK8Ou3asPP7mN3UXP110WFdW10QK137ULw3/XdBz2GiCz1Rybzdag9GahUn4jaonKhdHGliKLHcAI6BEiLyGOsjd5yMvU4QFXRaEbW/zp4enHTPw1lWVg9z7Cq07a/MYwAeVfH/j8IyASEAjiZnaSs4byLlB4Sc=----ATTACHMENT:----NzY5Nzc3MTgyNDEwMjc1OCAxNjg1NTk5NDM0MjU0MDY2IDU1NDI1MTUxNTc0OTk2MjA=