Skip to content

Commit

Permalink
Add unit test for a custom filename attribute suffix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Restless-ET committed Jun 29, 2015
1 parent cb290db commit 4a9d075
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Tests/Mapping/PropertyMappingFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,36 @@ public function testFromFieldReturnsNullOnInvalidFieldName()
$this->assertNull($mapping);
}

public function testCustomFileNameProperty()
{
$mappings = array(
'dummy_file' => array(
'namer' => false,
'directory_namer' => false
)
);

$this->metadata
->expects($this->once())
->method('isUploadable')
->with('Vich\UploaderBundle\Tests\DummyEntity')
->will($this->returnValue(true));

$this->metadata
->expects($this->once())
->method('getUploadableField')
->with('Vich\UploaderBundle\Tests\DummyEntity')
->will($this->returnValue(array(
'mapping' => 'dummy_file',
'propertyName' => 'file'
)));

$factory = new PropertyMappingFactory($this->container, $this->metadata, $mappings, '_suffix');
$mapping = $factory->fromField(new DummyEntity(), 'file');

$this->assertEquals('file_suffix', $mapping->getFileNamePropertyName());
}

public function testConfiguredNamersAreRetrievedFromContainer()
{
$mappings = array(
Expand Down

0 comments on commit 4a9d075

Please sign in to comment.