RecursiveValidator2Dot5ApiTest.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Validator\Tests\Validator;
  11. use Symfony\Component\Translation\IdentityTranslator;
  12. use Symfony\Component\Validator\ConstraintValidatorFactory;
  13. use Symfony\Component\Validator\Context\ExecutionContextFactory;
  14. use Symfony\Component\Validator\MetadataFactoryInterface;
  15. use Symfony\Component\Validator\Tests\Fixtures\Entity;
  16. use Symfony\Component\Validator\Validator\RecursiveValidator;
  17. class RecursiveValidator2Dot5ApiTest extends Abstract2Dot5ApiTest
  18. {
  19. protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = array())
  20. {
  21. $translator = new IdentityTranslator();
  22. $translator->setLocale('en');
  23. $contextFactory = new ExecutionContextFactory($translator);
  24. $validatorFactory = new ConstraintValidatorFactory();
  25. return new RecursiveValidator($contextFactory, $metadataFactory, $validatorFactory, $objectInitializers);
  26. }
  27. public function testEmptyGroupsArrayDoesNotTriggerDeprecation()
  28. {
  29. $entity = new Entity();
  30. $validatorContext = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock();
  31. $validatorContext
  32. ->expects($this->once())
  33. ->method('validate')
  34. ->with($entity, null, array())
  35. ->willReturnSelf();
  36. $validator = $this
  37. ->getMockBuilder('Symfony\Component\Validator\Validator\RecursiveValidator')
  38. ->disableOriginalConstructor()
  39. ->setMethods(array('startContext'))
  40. ->getMock();
  41. $validator
  42. ->expects($this->once())
  43. ->method('startContext')
  44. ->willReturn($validatorContext);
  45. $validator->validate($entity, null, array());
  46. }
  47. }