From 357af7b00a0b699627956b0bb05f14363062487e Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Wed, 11 Jul 2018 14:28:22 +0200
Subject: [PATCH] hotline #76959 fix tests failures

---
 library/Class/Notice/Thumbnail/ResizeImage.php           | 9 ++++-----
 .../ZendAfi/Controller/Plugin/Manager/FileManager.php    | 9 ++++-----
 library/ZendAfi/View/Helper/Thumbnail.php                | 3 ++-
 tests/application/modules/AbstractControllerTestCase.php | 1 +
 .../admin/controllers/FileManagerControllerTest.php      | 2 +-
 tests/library/Class/ModelTestCase.php                    | 1 +
 6 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/library/Class/Notice/Thumbnail/ResizeImage.php b/library/Class/Notice/Thumbnail/ResizeImage.php
index 17de318f3bd..7e3812e8065 100644
--- a/library/Class/Notice/Thumbnail/ResizeImage.php
+++ b/library/Class/Notice/Thumbnail/ResizeImage.php
@@ -51,7 +51,7 @@ class Class_Notice_Thumbnail_ResizeImage {
 
   public function resize($width, $height, $unlink = false, $bestfit = true) {
     if (!$this->_image || !$this->_image->isImage())
-      return new Class_Entity(['Url' => '']);
+      return new Class_Entity();
 
     $pattern = 'temp/thumbnails/file-manager/%sx%s';
 
@@ -92,12 +92,11 @@ class Class_Notice_Thumbnail_ResizeImage {
       $image->destroy();
 
     } catch(Exception $e) {
-      return new Class_Entity(['Url' => $thumb_url,
-                               'Title' => $this->_('Erreur lors du vignettage de l\'image "%s". %s', $this->_image->getName(),
-                                                 $e->getMessage())]);
+      return new Class_Entity(['Title' => $this->_('Erreur lors du vignettage de l\'image "%s". %s', $this->_image->getName(),
+                                                   $e->getMessage())]);
     }
 
     return new Class_Entity(['Url' => $thumb_url,
-                             'Alt' => $this->_('Vignette de l\'image "%s"', $this->_image->getName())]);
+                             'Title' => $this->_('Vignette de l\'image "%s"', $this->_image->getName())]);
   }
 }
\ No newline at end of file
diff --git a/library/ZendAfi/Controller/Plugin/Manager/FileManager.php b/library/ZendAfi/Controller/Plugin/Manager/FileManager.php
index 3e438c55af1..c65def555f3 100644
--- a/library/ZendAfi/Controller/Plugin/Manager/FileManager.php
+++ b/library/ZendAfi/Controller/Plugin/Manager/FileManager.php
@@ -25,11 +25,10 @@ class ZendAfi_Controller_Plugin_Manager_FileManager extends ZendAfi_Controller_P
   public function getActions($model) {
     return [['url' => $this->_getBrowseUrl($model),
              'icon'  => '',
-             'caption' => function($model) {
-          return
-          (($img = $this->_view->thumbnail($model)) ? $img : $this->_view->tag('i', '', ['class' => $model->getFontAwesome()])) .
-          $model->getName();},
-
+             'caption' => function($model)
+      {
+          return $this->_view->thumbnail($model) . $model->getName();
+      },
              'label' => $this->_('Voir le contenu de "%s"', $model->getPath()),
              'anchorOptions' => array_filter(['title' => $this->_('Voir le contenu de "%s"', $model->getId()),
                                               'data-path' => $model->getPath(),
diff --git a/library/ZendAfi/View/Helper/Thumbnail.php b/library/ZendAfi/View/Helper/Thumbnail.php
index d78f6402a6d..469d27502fe 100644
--- a/library/ZendAfi/View/Helper/Thumbnail.php
+++ b/library/ZendAfi/View/Helper/Thumbnail.php
@@ -29,6 +29,7 @@ class ZendAfi_View_Helper_Thumbnail extends ZendAfi_View_Helper_BaseHelper {
     return ($url = $resized_image->getUrl())
       ? $this->view->tagImg($url, ['title' => $resized_image->getTitle(),
                                    'alt' => $resized_image->getAlt()])
-      : '';
+      : $this->_tag('i', '', ['title' => $resized_image->getTitle(),
+                              'class' => $instance->getFontAwesome()]);
   }
 }
\ No newline at end of file
diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php
index b8010fe4bc1..7343f543762 100644
--- a/tests/application/modules/AbstractControllerTestCase.php
+++ b/tests/application/modules/AbstractControllerTestCase.php
@@ -203,6 +203,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe
     Class_Notice_Xsl::reset();
     Class_CommSigb::setInstance(null);
     ZendAfi_Acl_AdminControllerGroup::setAcl(null);
+    Class_Album::setFileSystem(null);
   }
 
 
diff --git a/tests/application/modules/admin/controllers/FileManagerControllerTest.php b/tests/application/modules/admin/controllers/FileManagerControllerTest.php
index 42acfb1a2b2..edffe8b8505 100644
--- a/tests/application/modules/admin/controllers/FileManagerControllerTest.php
+++ b/tests/application/modules/admin/controllers/FileManagerControllerTest.php
@@ -695,7 +695,7 @@ class FileManagerControllerWallDispatchTest extends FileManagerControllerTestCas
 
   /** @test */
   public function thumbnailShouldBePresent() {
-    $this->assertXPath('//div//a[contains(@href, "&display_mode_browser=wall")][contains(@href, "?browser=userfiles%2Fimage.png")]//i');
+    $this->assertXPath('//div//a[contains(@href, "&display_mode_browser=wall")][contains(@href, "?browser=userfiles%2Fimage.png")]//i[contains(@title, "Erreur lors du vignettage de l\'image")]');
   }
 
 
diff --git a/tests/library/Class/ModelTestCase.php b/tests/library/Class/ModelTestCase.php
index c78d3636429..edd782f15f3 100644
--- a/tests/library/Class/ModelTestCase.php
+++ b/tests/library/Class/ModelTestCase.php
@@ -87,6 +87,7 @@ abstract class ModelTestCase extends Storm_Test_ModelTestCase {
   protected function tearDown() {
     Class_Url::setPhpMode(null);
     Class_Notice_Thumbnail_ResizeImage::reset();
+    Class_ALbum::setFileSystem(null);
     Class_FileManager::reset();
     Class_AdminVar::set('NOM_DOMAINE', '');
 
-- 
GitLab