From bd65c3eeaf8e0ba0694a49600bf1d37b8273097d Mon Sep 17 00:00:00 2001
From: llaffont <laurent.laffont@gmail.com>
Date: Tue, 4 Mar 2014 16:17:52 +0100
Subject: [PATCH] Album audio record: fix display file size when empty

---
 library/ZendAfi/View/Helper/AlbumRessourceInfos.php        | 7 ++++++-
 library/ZendAfi/View/Helper/FileInfos.php                  | 6 +++++-
 .../RechercheControllerAlbumAudioRecordTest.php            | 4 ++--
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/library/ZendAfi/View/Helper/AlbumRessourceInfos.php b/library/ZendAfi/View/Helper/AlbumRessourceInfos.php
index d635ee66f5b..900cab6dc01 100644
--- a/library/ZendAfi/View/Helper/AlbumRessourceInfos.php
+++ b/library/ZendAfi/View/Helper/AlbumRessourceInfos.php
@@ -22,9 +22,14 @@
 class ZendAfi_View_Helper_AlbumRessourceInfos extends Zend_View_Helper_HtmlElement {
 	public function albumRessourceInfos($ressource) {
 		$file_info = new Class_File_Info($ressource->getOriginalPath());
+
+		$description = $file_info->fileExtension();
+		if ($size = $file_info->fileSize())
+			$description .=', '.$this->view->memoryFormat($size);
+
 		return $ressource->findTitle()
 			.'<br/>'
-			.'['.$file_info->fileExtension().', '.$this->view->memoryFormat($file_info->fileSize()).']';
+			.'['.$description.']';
 	}
 }
 
diff --git a/library/ZendAfi/View/Helper/FileInfos.php b/library/ZendAfi/View/Helper/FileInfos.php
index 6df62644d80..d65c97ac7b4 100644
--- a/library/ZendAfi/View/Helper/FileInfos.php
+++ b/library/ZendAfi/View/Helper/FileInfos.php
@@ -25,7 +25,11 @@ class ZendAfi_View_Helper_FileInfos extends Zend_View_Helper_Abstract {
 	 */
 	public function fileInfos($path) {
 		$file_info = new Class_File_Info($path);
-		return $file_info->fileNameWithExtension().', '.$this->view->memoryFormat($file_info->fileSize());
+		
+		$description = $file_info->fileNameWithExtension();
+		if ($size = $file_info->fileSize())
+			$description .=', '.$this->view->memoryFormat($size);
+		return $description;
 	}
 }
 ?>
\ No newline at end of file
diff --git a/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php b/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php
index 7f2372aaa09..0540887906c 100644
--- a/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php
+++ b/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php
@@ -252,9 +252,9 @@ class RechercheControllerAlbumAudioRecordViewRessourcesNumeriquesTest extends Re
 
 
 	/** @test **/
-	public function liForUnknownShouldBeFileNameUnknownMp3ZeroBite() {
+	public function liForUnknownShouldBeFileNameUnknownMp3() {
 		$this->assertXPathContentContains('//ol//li', 'Unknown');
-		$this->assertXPathContentContains('//ol//li', '[mp3, 0 o]');
+		$this->assertXPathContentContains('//ol//li', '[mp3]');
 	}
 
 
-- 
GitLab