Ejemplo n.º 1
0
 /**
  * @expectedException \Oro\Bundle\EntityBundle\Exception\FieldUpdateAccessException
  * @expectedExceptionMessage right message
  */
 public function testFailCustomValidate()
 {
     $classMetadata = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
     $classMetadata->expects(self::once())->method('hasField')->willReturn(true);
     $classMetadata->expects(self::never())->method('hasAssociation');
     $objectManager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $objectManager->expects(self::once())->method('getClassMetadata')->willReturn($classMetadata);
     $this->registry->expects(self::once())->method('getManager')->willReturn($objectManager);
     $entity = new \StdClass();
     $content = ['field1' => 'val1'];
     $this->translation->expects(self::once())->method('trans')->willReturn('right message');
     $customGridFieldValidator = $this->getMock('Oro\\Bundle\\EntityBundle\\Entity\\Manager\\Field\\CustomGridFieldValidatorInterface');
     $customGridFieldValidator->expects(self::once())->method('hasAccessEditField')->willReturn(false);
     $this->validator->addValidator($customGridFieldValidator, 'stdClass');
     $this->validator->validate($entity, $content);
 }
Ejemplo n.º 2
0
 /**
  * @param $entity
  * @param $content
  *
  * @return array
  */
 public function update($entity, $content)
 {
     $this->entityFieldValidator->validate($entity, $content);
     return $this->processUpdate($entity, $content);
 }