Fix #1133 : Permalinks always expose the file extension of the original document

This commit is contained in:
Romain Neutron
2013-03-28 12:19:31 +01:00
parent 4dedcc9f3b
commit 1a393b7dc7
2 changed files with 18 additions and 2 deletions

View File

@@ -152,7 +152,7 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea
$this->media_subdef->get_record_id(),
$this->media_subdef->get_name(),
$this->get_label(),
pathinfo($this->media_subdef->get_record()->get_original_name(), PATHINFO_EXTENSION),
pathinfo($this->media_subdef->get_file(), PATHINFO_EXTENSION),
$this->get_token()
);
}

View File

@@ -54,12 +54,28 @@ class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
. static::$records['record_1']->get_sbas_id() . '/'
. static::$records['record_1']->get_record_id()
. '/document/' . static::$object->get_label()
. '.' . pathinfo(static::$records['record_1']->get_original_name(), PATHINFO_EXTENSION)
. '.' . pathinfo(static::$records['record_1']->get_subdef('document')->get_file(), PATHINFO_EXTENSION)
. '?token=' . static::$object->get_token();
$this->assertEquals($url, static::$object->get_url($registry));
}
public function testGet_Previewurl()
{
$databox = static::$records['record_1']->get_databox();
$previewPermalink = media_Permalink_Adapter::getPermalink($databox, static::$records['record_1']->get_subdef('preview'));
$registry = registry::get_instance();
$url = $registry->get('GV_ServerName') . 'permalink/v1/'
. static::$records['record_1']->get_sbas_id() . '/'
. static::$records['record_1']->get_record_id()
. '/preview/' . $previewPermalink->get_label()
. '.' . pathinfo(static::$records['record_1']->get_subdef('preview')->get_file(), PATHINFO_EXTENSION)
. '?token=' . $previewPermalink->get_token();
$this->assertEquals($url, $previewPermalink->get_url($registry));
}
public function testGet_page()
{
$registry = registry::get_instance();