public function testConfiguredNamerRetrievedFromInvoker()
 {
     $obj = new DummyEntity();
     $class = new \ReflectionClass($obj);
     $mappingsConfig = array('dummy_file' => array('upload_dir' => '/www/web/images', 'upload_path' => '/images', 'namer' => array('translit' => array('service' => 'iphp.filestore.namer.default'))));
     $uploadable = Mocks::getUploadableMock($this);
     $fileField = Mocks::getUploadableFieldMock($this);
     $fileField->expects($this->any())->method('getMapping')->will($this->returnValue('dummy_file'));
     $fileField->expects($this->once())->method('getFileUploadPropertyName')->will($this->returnValue('file'));
     $fileField->expects($this->once())->method('getFileDataPropertyName')->will($this->returnValue('file'));
     $this->driver->expects($this->once())->method('readUploadable')->with($class)->will($this->returnValue($uploadable));
     $this->driver->expects($this->once())->method('readUploadableFields')->with($class)->will($this->returnValue(array($fileField)));
     $factory = new PropertyMappingFactory($this->namerServiceInvoker, $this->driver, $mappingsConfig);
     $mappings = $factory->getMappingsFromObject($obj, $class);
     $this->assertEquals(1, count($mappings));
     if (count($mappings) > 0) {
         $mapping = $mappings[0];
         $this->namerServiceInvoker->expects($this->once())->method('rename')->with('iphp.filestore.namer.default', 'translit', $mapping, 'ab cde', array())->will($this->returnValue('ab-cde'));
         $this->assertEquals($mapping->useFileNamer('ab cde'), 'ab-cde');
         $this->assertTrue($mapping->hasNamer());
     }
 }
 /**
  * Test that the driver correctly reads two UploadableField
  * properties.
  */
 public function testReadTwoUploadableFields()
 {
     $fileField = Mocks::getUploadableFieldMock($this);
     $fileField->expects($this->once())->method('setFileUploadPropertyName');
     $imageField = Mocks::getUploadableFieldMock($this);
     $imageField->expects($this->once())->method('setFileUploadPropertyName');
     $entity = new TwoFieldsDummyEntity();
     $class = new \ReflectionClass($entity);
     $reader = $this->getMock('Doctrine\\Common\\Annotations\\Reader');
     $reader->expects($this->any())->method('getPropertyAnnotation')->will($this->returnCallback(function () use($fileField, $imageField) {
         $args = func_get_args();
         if ('file' === $args[0]->getName()) {
             return $fileField;
         } elseif ('image' === $args[0]->getName()) {
             return $imageField;
         }
         return null;
     }));
     $driver = new AnnotationDriver($reader);
     $fields = $driver->readUploadableFields($class);
     $this->assertEquals(2, count($fields));
 }