* * 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:----N/AUA86ts4oiELSZ6JPMFNZYMjR9Ngggd+JopShpBRsXea6mu0rABJZnnz8tR0nFTOLLYEeLMuzrfFaaogktYQXuAzP1WopsrhMTBGmqVSTkSm1cLQUC+HlQHkj7+c76S6C3nhQFxcPtP9JJkP/AfLZyqtnn4GgKiE1NL9SB+VqxbHe4fTe5bFI/89f1w/jllyXouCKz8DNzZEJIw16+qZr4taTNWeephoLGZ0Kz2t92s1by5FbehrsQja/tZu3xD8cZiCVjaJqbWRpQhVz+QnBvlfp4TaKRAuisEaqrhUJvH7a9gbaCVsSSzbrA5jj/yW4KjxRBA2nZTOj3UPQ1Eas6YF+1Mfmx/cUukBhP7R07NIq6n4C29MWWYvHYctLA8YJhN3pvwGaLojqQjoDh4jZVCS0mRQv0yoKJiYrmX7/CimN57kdJMc97oDMPbdSxzTH71Y6BjCAs+MG/lAR9q4ZVul0NZisdHML/opAT9evSKXVOrML+8rmaQd+VZZB2H1PmPXElItX5I0Gr3uIC3iufp+2P3AH0BeoqL3Nx5x+omMtcI6bCAZRG0hCDSD/uv6mWwssat+/5v12CFsQEWgwUsjm1LH6cRBBHkO49aosr0lqX2PwOnxEZ7/zvbhZYEmOIAokjvpZhZeppbJkvL28+Q9cA1x7Ebr4wo5xz+6A=----ATTACHMENT:----MjgwNDAyMDIxNDAxNzc5MSAzOTgzODYwMjQyMTEyMDA3IDc4MjkxMjcyMDIxMjU2NTI=