From 91ea95d9576b81ecc0f0c297f99de9711d1dda6f Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Fri, 7 Sep 2018 10:25:57 +0200
Subject: [PATCH] dev #68187 fix telephone failures

---
 .../recherche/ressourcesnumeriques.phtml      |  1 -
 library/ZendAfi/View/Helper/RenderAlbum.php   |  4 +-
 .../View/Helper/Telephone/RenderAlbum.php     |  4 +-
 .../Helper/Telephone/TagDilicomWidget.php     | 25 ++++---
 ...hercheControllerRessourceNumeriqueTest.php | 60 ----------------
 .../TelephoneAbstractControllerTestCase.php   |  3 +-
 tests/bootstrap.php                           |  3 +-
 tests/scenarios/PnbDilicom/PnbDilicomTest.php | 71 ++++++++++++++++++-
 8 files changed, 87 insertions(+), 84 deletions(-)

diff --git a/application/modules/telephone/views/scripts/recherche/ressourcesnumeriques.phtml b/application/modules/telephone/views/scripts/recherche/ressourcesnumeriques.phtml
index 39359e51cc0..7382cbf2d5f 100644
--- a/application/modules/telephone/views/scripts/recherche/ressourcesnumeriques.phtml
+++ b/application/modules/telephone/views/scripts/recherche/ressourcesnumeriques.phtml
@@ -3,4 +3,3 @@ echo $this->toolbar($this->_("Livre numérisé"),
                     ['action' => 'simple']);
 echo $this->tag('h1', $this->notice->getTitrePrincipal());
 echo $this->renderAlbum($this->notice->getAlbum());
-?>
diff --git a/library/ZendAfi/View/Helper/RenderAlbum.php b/library/ZendAfi/View/Helper/RenderAlbum.php
index c96b359367d..47e2cf37a35 100644
--- a/library/ZendAfi/View/Helper/RenderAlbum.php
+++ b/library/ZendAfi/View/Helper/RenderAlbum.php
@@ -38,6 +38,4 @@ class ZendAfi_View_Helper_RenderAlbum extends ZendAfi_View_Helper_BaseHelper {
   public function renderAlbumHelper($album) {
     return $album->renderOn($this->view);
   }
-}
-
-?>
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/library/ZendAfi/View/Helper/Telephone/RenderAlbum.php b/library/ZendAfi/View/Helper/Telephone/RenderAlbum.php
index c914d248b8a..c82e861e15c 100644
--- a/library/ZendAfi/View/Helper/Telephone/RenderAlbum.php
+++ b/library/ZendAfi/View/Helper/Telephone/RenderAlbum.php
@@ -25,6 +25,4 @@ class ZendAfi_View_Helper_Telephone_RenderAlbum extends ZendAfi_View_Helper_Rend
       ? sprintf('<div id="resnum">%s</div>', $this->renderAlbumHelper($album))
       : $this->view->_('Aucune ressource numérique trouvée.');
   }
-}
-
-?>
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/library/ZendAfi/View/Helper/Telephone/TagDilicomWidget.php b/library/ZendAfi/View/Helper/Telephone/TagDilicomWidget.php
index b673e497ef2..d9db97f9030 100644
--- a/library/ZendAfi/View/Helper/Telephone/TagDilicomWidget.php
+++ b/library/ZendAfi/View/Helper/Telephone/TagDilicomWidget.php
@@ -19,7 +19,9 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
 class ZendAfi_View_Helper_Telephone_TagDilicomWidget extends ZendAfi_View_Helper_TagDilicomWidget {
+
   protected function _getLoanBookAction() {
     return 'loan-book';
   }
@@ -30,26 +32,23 @@ class ZendAfi_View_Helper_Telephone_TagDilicomWidget extends ZendAfi_View_Helper
   }
 
 
-  public function renderBookPreview($album) {
+  protected function _renderBookPreview($album) {
     // too much performance issues
     return '';
   }
 
 
-  protected function getConsultBookAnchor() {
+  protected function _getConsultBookAnchor() {
     return '';
   }
 
 
-  protected function getLoanBookAnchor() {
-    return $this->getDilicomAnchor(['controller' => 'bib-numerique',
-                                    'action' => $this->_getLoanBookAction(),
-                                    'id' => $this->_album->getId()],
-                                   $this->_('Emprunter le livre au format EPUB'),
-                                   ['data-role' => 'button',
-                                    'data-ajax' => 'false']);
+  protected function _getLoanBookAnchor() {
+    return $this->_anchor(['controller' => 'bib-numerique',
+                           'action' => $this->_getLoanBookAction(),
+                           'id' => $this->_album->getId()],
+                          $this->_('Emprunter le livre au format EPUB'),
+                          ['data-role' => 'button',
+                           'data-ajax' => 'false']);
   }
-
-}
-
-?>
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/tests/application/modules/telephone/controllers/RechercheControllerRessourceNumeriqueTest.php b/tests/application/modules/telephone/controllers/RechercheControllerRessourceNumeriqueTest.php
index 9e848c88128..6ae0f878e9b 100644
--- a/tests/application/modules/telephone/controllers/RechercheControllerRessourceNumeriqueTest.php
+++ b/tests/application/modules/telephone/controllers/RechercheControllerRessourceNumeriqueTest.php
@@ -19,7 +19,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
-require_once 'TelephoneAbstractControllerTestCase.php';
 
 abstract class Telephone_RechercheControllerRessourceNumeriqueTestCase extends TelephoneAbstractControllerTestCase {
   protected $_storm_default_to_volatile = true;
@@ -195,63 +194,4 @@ class Telephone_RechercheControllerRessourceNumeriqueElserViewNoticeTest
                                       'Accéder à la vidéo',
                                       $this->_response->getBody());
   }
-}
-
-
-
-
-class Telephone_RechercheControllerRessourceNumeriqueViewNoticePNBTest extends Telephone_RechercheControllerRessourceNumeriqueTestCase {
-  public function setUp() {
-    parent::setUp();
-    $this->fixture('Class_Album',
-                   ['id' => 1,
-                    'titre' => 'Hypnophonic',
-                    'visible' => true,
-                    'status' => Class_Album::STATUS_VALIDATED,
-                    'type_doc_id' => Class_TypeDoc::DILICOM])->index();
-
-    $logged_user = $this->fixture('Class_Users',
-                                  ['id' => 6,
-                                   'nom'=>'Pito',
-                                   'login'=>'Chat',
-                                   'password'=>'123456',
-                                   'id_site' => 1,
-                                   'idabon' => '12345',
-                                   'user_groups' => [$this->fixture('Class_UserGroup',
-                                                                    ['id' => '20',
-                                                                     'libelle' => 'Multimedia',
-                                                                     'rights' => [Class_UserGroup::RIGHT_ACCES_PNB_DILICOM]])]]);
-    $logged_user->beAbonneSIGB()->assertSave();
-    ZendAfi_Auth::getInstance()->logUser($logged_user);
-  }
-
-
-  /** @test */
-  public function pageShouldContainsLinkToRessouresNumeriques() {
-    $this->dispatch('/telephone/recherche/viewnotice/id/1', true);
-
-    $this->assertXPathContentContains('//ul[contains(@class, "doctype_112")]//a',
-                                      'Accéder à la ressource',$this->_response->getBody());
-  }
-
-
-  /** @test */
-  public function loanBookActionShouldBeLoanBookNotAjax() {
-    $this->dispatch('/telephone/recherche/ressourcesnumeriques/id/1', true);
-    $this->assertXPath('//a[contains(@href, "bib-numerique/loan-book/id/1")]');
-  }
-
-
-  /** @test */
-  public function consultBookActionShouldNotBeVisiable() {
-    $this->dispatch('/telephone/recherche/ressourcesnumeriques/id/1', true);
-    $this->assertNotXPath('//a[contains(@href, "bib-numerique/consult-book/id/1")]');
-  }
-
-
-  /** @test */
-  public function previewIframeShouldNotBeDisplayed() {
-    $this->dispatch('/telephone/recherche/ressourcesnumeriques/id/1', true);
-    $this->assertNotXPath('//iframe');
-  }
 }
\ No newline at end of file
diff --git a/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php b/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php
index fff38f0f996..62a89ff7f2e 100644
--- a/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php
+++ b/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php
@@ -34,5 +34,4 @@ abstract class TelephoneAbstractControllerTestCase extends AbstractControllerTes
     unset($_SERVER['HTTP_USER_AGENT']);
     parent::tearDown();
   }
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index b04ef170339..8276cf8b9da 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -92,8 +92,9 @@ require_once 'tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php';
 require_once 'tests/application/modules/admin/controllers/AdminAbstractControllerTestCase.php';
 require_once 'tests/fixtures/RessourcesNumeriquesFixtures.php';
 require_once 'tests/fixtures/MockedClasses.php';
+require_once 'tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php';
 
 register_shutdown_function(function(){
   TestSpeedTrap::printSpeedTrappedTests();
 });
-?>
+?>
\ No newline at end of file
diff --git a/tests/scenarios/PnbDilicom/PnbDilicomTest.php b/tests/scenarios/PnbDilicom/PnbDilicomTest.php
index cc3f931f511..a733afb06b2 100644
--- a/tests/scenarios/PnbDilicom/PnbDilicomTest.php
+++ b/tests/scenarios/PnbDilicom/PnbDilicomTest.php
@@ -3234,6 +3234,75 @@ class PnbDilicomAdminIndexControllerTest extends Admin_AbstractControllerTestCas
   public function pnPnbDilicomnShouldBePresent() {
     RessourcesNumeriquesFixtures::activateDilicom();
     $this->dispatch('/admin/index/index', true);
-    $this->assertXPathContentContains($this->_bibnum_menu_path . '//a', 'PNB Dilicom');
+    $this->assertXPathContentContains('//div[@class="menuGaucheAdmin"][.//td[text()="Bibliothèque numérique"]]//a', 'PNB Dilicom');
   }
 }
+
+
+
+
+class PnbDilicomTelephoneRechercheControllerViewNoticeTest extends TelephoneAbstractControllerTestCase {
+
+  protected $_storm_default_to_volatile = true;
+
+
+  public function setUp() {
+    parent::setUp();
+    RessourcesNumeriquesFixtures::activateDilicom();
+    $book = (new DilicomFixtures())->albumTotemThora()
+                                   ->setVisible(true)
+                                   ->setStatus(Class_Album::STATUS_VALIDATED);
+    $book->assertSave();
+    $book->index();
+
+    $this->fixture('Class_Bib',
+                   ['id' => 1,
+                    'libelle' => 'annecy',
+                    'gln' => '2222'
+                   ]);
+
+    $logged_user = $this->fixture('Class_Users',
+                                  ['id' => 6,
+                                   'nom'=>'Pito',
+                                   'login'=>'Chat',
+                                   'password'=>'123456',
+                                   'id_site' => 1,
+                                   'idabon' => '12345',
+                                   'user_groups' => [$this->fixture('Class_UserGroup',
+                                                                    ['id' => '20',
+                                                                     'libelle' => 'Multimedia',
+                                                                     'rights' => [Class_UserGroup::RIGHT_ACCES_PNB_DILICOM]])]]);
+
+    $logged_user->beAbonneSIGB()->assertSave();
+    ZendAfi_Auth::getInstance()->logUser($logged_user);
+  }
+
+
+  /** @test */
+  public function pageShouldContainsLinkToRessouresNumeriques() {
+    $this->dispatch('/telephone/recherche/viewnotice/id/1', true);
+    $this->assertXPathContentContains('//ul[contains(@class, "doctype_112")]//a',
+                                      'Accéder à la ressource');
+  }
+
+
+  /** @test */
+  public function loanBookActionShouldBeLoanBookNotAjax() {
+    $this->dispatch('/telephone/recherche/ressourcesnumeriques/id/1', true);
+    $this->assertXPath('//a[contains(@href, "bib-numerique/loan-book/id/3")]');
+  }
+
+
+  /** @test */
+  public function consultBookActionShouldNotBeVisible() {
+    $this->dispatch('/telephone/recherche/ressourcesnumeriques/id/1', true);
+    $this->assertNotXPath('//a[contains(@href, "bib-numerique/consult-book/id/3")]');
+  }
+
+
+  /** @test */
+  public function previewIframeShouldNotBeDisplayed() {
+    $this->dispatch('/telephone/recherche/ressourcesnumeriques/id/1', true);
+    $this->assertNotXPath('//iframe');
+  }
+}
\ No newline at end of file
-- 
GitLab