protected function setDataStorageObjectMapping($obj, $propertyMapping) { $class = new \ReflectionClass($obj); $this->dataStorage->expects($this->once())->method('getObjectFromArgs')->will($this->returnValue($obj)); $this->dataStorage->expects($this->once())->method('getReflectionClass')->with($obj)->will($this->returnValue($class)); $this->propertyMappingfactory->expects($this->once())->method('getMappingsFromObject')->with($obj, $class)->will($this->returnValue(array($propertyMapping))); }
function testPreBind() { $obj = new DummyEntity(); $class = new \ReflectionClass($obj); $formEvent = $this->getMockBuilder('Symfony\\Component\\Form\\FormEvent')->disableOriginalConstructor()->getMock(); $form = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock(); $parentForm = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock(); $formEvent->expects($this->once())->method('getForm')->will($this->returnValue($form)); $form->expects($this->once())->method('getParent')->will($this->returnValue($parentForm)); $parentForm->expects($this->once())->method('getData')->will($this->returnValue($obj)); $this->dataStorage->expects($this->once())->method('getReflectionClass')->with($obj)->will($this->returnValue($class)); $propertyMapping = Mocks::getPropertyMappingMock($this); $this->propertyMappingFactory->expects($this->once())->method('getMappingFromField')->with($obj, $class, 'file')->will($this->returnValue($propertyMapping)); $form->expects($this->once())->method('getName')->will($this->returnValue('file')); $this->transformer->expects($this->once())->method('setMapping')->with($propertyMapping); $this->subscriber->preBind($formEvent); }