/**
  * Test that if the file name property returns a null value
  * then no file is injected.
  */
 public function testPropertyIsNullWhenFileNamePropertyIsNull()
 {
     $obj = $this->getMock('Vich\\UploaderBundle\\Tests\\DummyEntity');
     $fileNameProp = $this->getMockBuilder('\\ReflectionProperty')->disableOriginalConstructor()->getMock();
     $fileNameProp->expects($this->once())->method('getValue')->will($this->returnValue(null));
     $fileMapping = $this->getMockBuilder('Vich\\UploaderBundle\\Mapping\\PropertyMapping')->disableOriginalConstructor()->getMock();
     $fileMapping->expects($this->once())->method('getInjectOnLoad')->will($this->returnValue(true));
     $fileMapping->expects($this->once())->method('getFileNameProperty')->will($this->returnValue($fileNameProp));
     $this->factory->expects($this->once())->method('fromObject')->with($obj)->will($this->returnValue(array($fileMapping)));
     $inject = new FileInjector($this->factory);
     $inject->injectFiles($obj);
     $this->assertEquals(null, $obj->getFile());
 }
 /**
  * Test that if the file name property returns a null value
  * then no file is injected.
  */
 public function testPropertyIsNullWhenFileNamePropertyIsNull()
 {
     $uploadDir = __DIR__ . '/..';
     $obj = $this->getMock('Vich\\UploaderBundle\\Tests\\DummyEntity');
     $fileNameProp = $this->getMockBuilder('\\ReflectionProperty')->disableOriginalConstructor()->getMock();
     $fileMapping = $this->getMockBuilder('Vich\\UploaderBundle\\Mapping\\PropertyMapping')->disableOriginalConstructor()->getMock();
     $fileMapping->expects($this->once())->method('getInjectOnLoad')->will($this->returnValue(true));
     $prop = $this->getMockBuilder('\\ReflectionProperty')->disableOriginalConstructor()->getMock();
     $prop->expects($this->once())->method('getName')->will($this->returnValue('test_adapter'));
     $prop->expects($this->once())->method('setValue');
     $fileMapping->expects($this->exactly(2))->method('getProperty')->will($this->returnValue($prop));
     $this->factory->expects($this->once())->method('fromObject')->with($obj)->will($this->returnValue(array($fileMapping)));
     $this->storage->expects($this->once())->method('resolvePath')->will($this->returnValue($uploadDir));
     $inject = new FileInjector($this->factory, $this->storage);
     $inject->injectFiles($obj);
     $this->assertEquals(null, $obj->getFile());
 }