From 1a393b7dc78db505571dfbb8affd34e07fa20a11 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Thu, 28 Mar 2013 12:19:31 +0100 Subject: [PATCH] Fix #1133 : Permalinks always expose the file extension of the original document --- lib/classes/media/Permalink/Adapter.class.php | 2 +- .../Permalink/media_Permalink_AdapterTest.php | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/classes/media/Permalink/Adapter.class.php b/lib/classes/media/Permalink/Adapter.class.php index 37574e2444..418a1d62ee 100644 --- a/lib/classes/media/Permalink/Adapter.class.php +++ b/lib/classes/media/Permalink/Adapter.class.php @@ -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() ); } diff --git a/tests/media/Permalink/media_Permalink_AdapterTest.php b/tests/media/Permalink/media_Permalink_AdapterTest.php index 4483859323..308eac74ce 100644 --- a/tests/media/Permalink/media_Permalink_AdapterTest.php +++ b/tests/media/Permalink/media_Permalink_AdapterTest.php @@ -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();