/**
  * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
  * @expectedExceptionMessage During the validation whether the given property is unique or not, doctrine threw an exception with the following message: "Unrecognized field: test-field". Did you misconfigure any parameters such as the field or entity name?
  */
 public function testFindOneByThrowsORMException()
 {
     $repository = $this->getMockWithoutInvokingTheOriginalConstructor(EntityRepository::class);
     $repository->expects($this->once())->method('findOneBy')->with(['test-field' => 'test'])->willReturnCallback(function () {
         throw ORMException::unrecognizedField('test-field');
     });
     $manager = $this->getMock(ObjectManager::class);
     $manager->expects($this->any())->method('getRepository')->willReturn($repository);
     $mockRegistry = $this->getMock(ManagerRegistry::class);
     $mockRegistry->expects($this->any())->method('getManagerForClass')->willReturn($manager);
     $propertyMock = new UniquePropertyValidator($mockRegistry);
     $propertyMock->initialize($this->getMock(ExecutionContextInterface::class));
     $propertyMock->validate('test', new UniqueProperty(['entity' => 'AnotherMapping:User', 'field' => 'test-field']));
 }
 /**
  * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
  * @expectedExceptionMessage The given entity "AnotherMapping:User" must not be an embeddable or an abstract/superclass object!
  */
 public function testClassIsEmbeddable()
 {
     $classMetadata = $this->getMockWithoutInvokingTheOriginalConstructor(ClassMetadata::class);
     $classMetadata->expects($this->any())->method('hasField')->willReturn(true);
     $classMetadata->isEmbeddedClass = true;
     $classMetadata->isMappedSuperclass = false;
     $manager = $this->getMock(ObjectManager::class);
     $manager->expects($this->any())->method('getClassMetadata')->willReturn($classMetadata);
     $mockRegistry = $this->getMock(ManagerRegistry::class);
     $mockRegistry->expects($this->any())->method('getManagerForClass')->willReturn($manager);
     $propertyMock = new UniquePropertyValidator($mockRegistry, $this->getMock(SuggestorInterface::class));
     $propertyMock->initialize($this->getMock(ExecutionContextInterface::class));
     $propertyMock->validate('test', new UniqueProperty(['entity' => 'AnotherMapping:User', 'field' => 'test-field']));
 }