* * 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:----l3G75ACC86428fAfJsZYtqwKupvAdxydrIe+fW4d6fr971A86CJODim54TuE/9maJGHiQDrFfHdzf50nohBwIrCAVyphr1MGy8jAGCB+a5Q9vlITgBz4LZ2eF610fOB3XmcD0yC+fW2uEGgIyL52JXgwqdlwa8iYluPWUQVpx6PnJ+tCUjAZnVdHId04oLJL5Gn1TPwlNgkW2zPKQOdbwXUbv4G0wqAX8N+d8i5UQSeX//Ya1E/a7TbmVlZWSayk0JgOEZLgCQi4ZkGhv5iyHdJLnJ7dbq2C6/e38YYktBWQ4X8zunCP+Gz3VZct5F99f7mxUf4qZjq+UHlDVkJQ6ORlC1LFParDY/vrtEbLiymER3vXh7uWw0NHp6+uDZIMpB5xWINKmsSngA1bqqD1ILEOZMx8f5lazKK/t7AdvUvm2R3KlpzkDvpRwkSeM7CR7oKkg/wkT9uZSudTPMkXp7RMJfUdcuHR2SVTIlfxKIKwakDf3a7MpNALzZ5NnN4dxJ293hoHo/NIUE5zQigbUOKEPXG5bsnDE9OwLvypsQHxkWT5/1kfa3wj6a3QdNlMTVCyPIh6/ivgy1DgSOeOeLI6pinH9UeVzZOogHbZ19l7QduaX4fE6HqsQnkaSkDKaLvfTv8Tbu5OGjKAT0CnepnFHwHR2+/BGxHDhG0sbYU=----ATTACHMENT:----NzI4MjUzMzA3NjQyNTgzMiAxNTIxMzcwNzM0NTYxMzI1IDgwNjg4ODI0NDcxNjYzMjk=