From 2c1fe0f740a7c521543c6c4b7641b8eb07de7686 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Fri, 14 Sep 2012 08:51:49 +0000
Subject: [PATCH] =?UTF-8?q?Correction=20lien=20t=C3=A9l=C3=A9chargement=20?=
 =?UTF-8?q?EPUB=20c=C3=B4t=C3=A9=20admin?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .gitattributes                                |  1 +
 .../ZendAfi/View/Helper/TagAlbumMediaList.php |  9 ++--
 .../controllers/AlbumControllerEPubTest.php   | 49 +++++++++++++++++++
 .../ZendAfi/View/Helper/RenderAlbumTest.php   |  2 +-
 4 files changed, 56 insertions(+), 5 deletions(-)
 create mode 100644 tests/application/modules/admin/controllers/AlbumControllerEPubTest.php

diff --git a/.gitattributes b/.gitattributes
index e487e1d2125..66b35853311 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -4151,6 +4151,7 @@ tests/application/modules/admin/controllers/AdminAuthControllerTest.php -text
 tests/application/modules/admin/controllers/AdminAvisModerationControllerTest.php -text
 tests/application/modules/admin/controllers/AdminControllerTest.php -text
 tests/application/modules/admin/controllers/AdminIndexControllerTest.php -text
+tests/application/modules/admin/controllers/AlbumControllerEPubTest.php -text
 tests/application/modules/admin/controllers/AlbumControllerPharoVideosTest.php -text
 tests/application/modules/admin/controllers/AlbumControllerTest.php -text
 tests/application/modules/admin/controllers/AlbumControllerVideoAndAudioTest.php -text
diff --git a/library/ZendAfi/View/Helper/TagAlbumMediaList.php b/library/ZendAfi/View/Helper/TagAlbumMediaList.php
index aa1315c7812..783275f2f5f 100644
--- a/library/ZendAfi/View/Helper/TagAlbumMediaList.php
+++ b/library/ZendAfi/View/Helper/TagAlbumMediaList.php
@@ -26,11 +26,12 @@ class ZendAfi_View_Helper_TagAlbumMediaList extends Zend_View_Helper_HtmlElement
 		$ressources = $album->getRessources();
 		foreach($ressources as $ressource) {
 			$html .= sprintf('<li>%s</li>',
-											 $this->view->tagAnchor(array('controller' => 'bib-numerique',
-																										'action' => 'download-resource',
-																										'id' => $ressource->getId()),
+											 $this->view->tagAnchor(['module' => 'opac',
+																							 'controller' => 'bib-numerique',
+																							 'action' => 'download-resource',
+																							 'id' => $ressource->getId()],
 																							$this->view->albumRessourceInfos($ressource),
-																							array('data-ajax' => 'false')));
+																							['data-ajax' => 'false']));
 		}
 		
 		$html .= '</ul>';
diff --git a/tests/application/modules/admin/controllers/AlbumControllerEPubTest.php b/tests/application/modules/admin/controllers/AlbumControllerEPubTest.php
new file mode 100644
index 00000000000..37653de5a57
--- /dev/null
+++ b/tests/application/modules/admin/controllers/AlbumControllerEPubTest.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
+ *
+ * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
+ * the Free Software Foundation.
+ *
+ * There are special exceptions to the terms and conditions of the AGPL as it
+ * is applied to this software (see README file).
+ *
+ * AFI-OPAC 2.0 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * along with AFI-OPAC 2.0; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ */
+
+require_once 'AlbumControllerTest.php';
+
+class Admin_AlbumControllerEPubTest extends Admin_AlbumControllerTestCase {
+	protected $_xpath;
+
+	public function setUp() {
+		parent::setUp();
+
+		$album = Class_Album::newInstanceWithId(999)
+			->beEPUB()
+			->setTitre('Informatique')
+			->setRessources([Class_AlbumRessource::newInstanceWithId(4)
+											 ->setUrl('pragmatic_programmers.epub')
+											 ->setTitre('Pragmatic Programmers')
+											 ->setVignette('pragprog.jpg')]);
+
+		$this->dispatch('/admin/album/preview_album/id/999', true);
+	}
+
+
+	/** @test */
+	public function linkToDownloadEPubShouldBeModuleOPACBibNumDownload() {
+		$this->assertXpath('//a[@href="/bib-numerique/download-resource/id/4"]');
+	}
+}
+
+
+?>
\ No newline at end of file
diff --git a/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php b/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php
index 0ecaf077462..c3af23c667c 100644
--- a/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php
+++ b/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php
@@ -63,7 +63,7 @@ class ZendAfi_View_Helper_RenderAlbumEPUBTest extends ZendAfi_View_Helper_Render
 	/** @test */
 	public function pageShouldContainsLinkToDownloadEPUB() {
 		$this->assertXPathContentContains($this->html, 
-																			'//a[contains(@href, "bib-numerique/download-resource/id/123")]',
+																			'//a[contains(@href, "'.BASE_URL.'/bib-numerique/download-resource/id/123")]',
 																			'versailles.epub');
 	}
 }
-- 
GitLab