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);
 }
 /**
  * Test the postFlush method has deferred files
  */
 public function testPostFlushHasDeferred()
 {
     $args = Mocks::getEventArgsMock($this);
     $obj = new DummyEntity();
     $file = Mocks::getFileMock($this);
     $propertyMapping = $this->createFilledPropertyMapping($file);
     $this->setDataStorageObjectMapping($obj, $propertyMapping);
     $listener = $this->getUploaderListener();
     $listener->prePersist(Mocks::getEventArgsMock($this));
     $this->assertEquals($listener->getDeferredObjectNum(), 1);
     $this->fileStorage->expects($this->once())->method('upload')->with($propertyMapping, $file)->will($this->returnValue(array('fileName' => 'NEW_NAME')));
     $propertyMapping->expects($this->once())->method('setFileDataPropertyValue')->with(array('fileName' => 'NEW_NAME'));
     $this->dataStorage->expects($this->once())->method('postFlush');
     $listener->postFlush($args);
     $this->assertEquals($listener->getDeferredObjectNum(), 0);
 }