mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Fixup FilesystemService document filename generation.
There was a missing '.' before extension
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Filesystem;
|
namespace Alchemy\Phrasea\Filesystem;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Model\RecordInterface;
|
||||||
use MediaAlchemyst\Specification\SpecificationInterface;
|
use MediaAlchemyst\Specification\SpecificationInterface;
|
||||||
|
|
||||||
class FilesystemService
|
class FilesystemService
|
||||||
@@ -66,17 +67,17 @@ class FilesystemService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \record_adapter $record
|
* @param RecordInterface $record
|
||||||
* @param string|\SplFileInfo $source
|
* @param string|\SplFileInfo $source
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function generateDocumentFilename(\record_adapter $record, $source)
|
public function generateDocumentFilename(RecordInterface $record, $source)
|
||||||
{
|
{
|
||||||
if (!$source instanceof \SplFileInfo) {
|
if (!$source instanceof \SplFileInfo) {
|
||||||
$source = new \SplFileInfo($source);
|
$source = new \SplFileInfo($source);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $record->getRecordId() . '_document' . strtolower($source->getExtension());
|
return $record->getRecordId() . '_document.' . strtolower($source->getExtension());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2016 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Tests\Phrasea\Filesystem;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Filesystem\FilesystemService;
|
||||||
|
use Alchemy\Phrasea\Model\RecordInterface;
|
||||||
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
|
||||||
|
class FilesystemServiceTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var FilesystemService
|
||||||
|
*/
|
||||||
|
private $sut;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->sut = new FilesystemService(new Filesystem());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider provideRecordsAndExpectedDocumentFilenames
|
||||||
|
*/
|
||||||
|
public function testItProperlyGeneratesDocumentFileNames($expected, $recordId, $filename)
|
||||||
|
{
|
||||||
|
$record = $this->prophesize(RecordInterface::class);
|
||||||
|
$record->getRecordId()->willReturn($recordId);
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $this->sut->generateDocumentFilename($record->reveal(), $filename));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideRecordsAndExpectedDocumentFileNames()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['2_document.jpg', 2, 'foo.jpg'],
|
||||||
|
['42_document.jpg', 42, 'bar.JPG'],
|
||||||
|
['2_document.pdf', 2, new \SplFileInfo('foo_bar.pdf')],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user