From 2bc60832521726f8abc4383acfd43534175be914 Mon Sep 17 00:00:00 2001
From: Ghislain Loas <ghislo@sandbox.pergame.net>
Date: Wed, 21 Jan 2015 10:36:57 +0100
Subject: [PATCH] dev #17514 indexation refactoring

fix tests failures
---
 library/Class/Album.php                       |  2 +-
 library/Class/PanierNotice.php                |  3 +-
 .../Cyberlibris/LivresNumeriquesReader.php    |  2 +-
 library/storm                                 |  2 +-
 .../opac/controllers/PanierControllerTest.php |  2 +-
 ...echercheControllerAlbumAudioRecordTest.php | 36 +++++++++----------
 .../Class/Indexation/PseudoNoticeTest.php     |  1 +
 tests/library/Class/Notice/ClefAlphaTest.php  |  4 +--
 tests/library/Class/PanierNoticeTest.php      |  8 ++---
 .../Class/Systeme/ModulesMenu/NumilogTest.php |  5 ++-
 10 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/library/Class/Album.php b/library/Class/Album.php
index a3703eea85d..c8ff8c2d77b 100644
--- a/library/Class/Album.php
+++ b/library/Class/Album.php
@@ -1594,7 +1594,7 @@ class Class_Album extends Storm_Model_Abstract {
 
 		$visitor->visitTitre($this->getTitre())
 						->visitComplementTitre($this->getSousTitre())
-						->visitAuteur(array_shift($authors))
+						->visitAuteur(implode($authors))
 						->visitTypeDocId($this->getTypeDocId())
 						->visitEditeur(array_shift($editors))
 						->visitAnnee($this->getAnnee());
diff --git a/library/Class/PanierNotice.php b/library/Class/PanierNotice.php
index b30a5d9433a..9f73ae36acd 100644
--- a/library/Class/PanierNotice.php
+++ b/library/Class/PanierNotice.php
@@ -254,7 +254,8 @@ class Class_PanierNotice extends Storm_Model_Abstract {
 		$user=Class_Users::getIdentity();
 		if ($user && $user->getIdabon())
 			$this->setIdabon($user->getIdabon());
-		$this->setDateMaj(date('Y-m-d'));
+		if($this->hasChange())
+			$this->setDateMaj(date('Y-m-d'));
 		$this->unindex();
 	}
 
diff --git a/library/Class/WebService/BibNumerique/Cyberlibris/LivresNumeriquesReader.php b/library/Class/WebService/BibNumerique/Cyberlibris/LivresNumeriquesReader.php
index 1b0cbd4da00..ff989966eb9 100644
--- a/library/Class/WebService/BibNumerique/Cyberlibris/LivresNumeriquesReader.php
+++ b/library/Class/WebService/BibNumerique/Cyberlibris/LivresNumeriquesReader.php
@@ -36,7 +36,7 @@ class Class_WebService_BibNumerique_Cyberlibris_LivresNumeriquesReader extends C
 	}
 
 
-	public function parse() {
+	public function parse($xml) {
 		$this->_total_count = $this->_page_number = 0;
 		$this->_page_size = 1;
 		$this->livres = [];
diff --git a/library/storm b/library/storm
index 63c9c4af2a4..25ca343bac1 160000
--- a/library/storm
+++ b/library/storm
@@ -1 +1 @@
-Subproject commit 63c9c4af2a478b6eceafddcc259f49316c7f88cb
+Subproject commit 25ca343bac14e3227379c588cdccedd3df5b5a31
diff --git a/tests/application/modules/opac/controllers/PanierControllerTest.php b/tests/application/modules/opac/controllers/PanierControllerTest.php
index 25d5fb1c0a1..e48b1467ca0 100644
--- a/tests/application/modules/opac/controllers/PanierControllerTest.php
+++ b/tests/application/modules/opac/controllers/PanierControllerTest.php
@@ -1770,7 +1770,7 @@ class PanierControllerUnindexedBySupprimerNoticePanierTest extends PanierControl
 
 	/** @test */
 	public function record12ShouldHaveFacetH1() {
-		$this->assertContains('H1', Class_Notice::find(12)->getFacettes());
+		$this->assertContains('Q1', Class_Notice::find(12)->getFacettes());
 	}
 
 
diff --git a/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php b/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php
index 77cb03a5c0c..54767f88ba7 100644
--- a/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php
+++ b/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
 
@@ -24,7 +24,7 @@ require_once 'AbstractControllerTestCase.php';
 
 
 abstract class RechercheControllerAlbumAudioRecordTestCase extends AbstractControllerTestCase {
-	protected 
+	protected
 		$_notice,
 		$_codif_auteur_wrapper;
 
@@ -42,7 +42,7 @@ abstract class RechercheControllerAlbumAudioRecordTestCase extends AbstractContr
 		Class_CosmoVar::newInstanceWithId('black_list_856', ['valeur' => 'mabib']);
 		Class_CosmoVar::newInstanceWithId('unimarc_zone_titre',
 																			['valeur' => '200$a;200$e;200$d;200$i;327$a;464$a;461$t;464$t']);
-		
+
 		$album = $this->fixture('Class_Album',
 														['id' => 4,
 														 'type_doc_id' => Class_TypeDoc::AUDIO_RECORD,
@@ -88,7 +88,7 @@ abstract class RechercheControllerAlbumAudioRecordTestCase extends AbstractContr
 		$code_alpha = str_replace(' ', 'x', $indexation->alphaMaj($name.'|'));
 		$author = Class_CodifAuteur::newInstance([ 'formes' => $code_alpha,
 																							 'libelle' => $name]);
-		$author->assertSave();
+		$author->save();
 
 		$this->_codif_auteur_wrapper
 			->whenCalled('findFirstBy')
@@ -116,7 +116,7 @@ class RechercheControllerAlbumAudioRecordViewNoticeTest extends RechercheControl
 
 	/** @test */
 	public function clefAlphaShouldBeSEVENTHSON_IRONMAIDEN() {
-		$this->assertEquals('SEVENTHSONOFASEVENTHSON--IRONMAIDENBRUCEDICKINSONSTEVEHARRISDAVEMURRAYNICKOMCBRAINADRIANSMITH----109', 
+		$this->assertEquals('SEVENTHSONOFASEVENTHSON--IRONMAIDENBRUCEDICKINSONSTEVEHARRISDAVEMURRAYNICKOMCBRAINADRIANSMITH----109',
 												$this->_notice->getClefAlpha());
 	}
 
@@ -133,7 +133,7 @@ class RechercheControllerAlbumAudioRecordViewNoticeTest extends RechercheControl
 	}
 
 
-	/** 
+	/**
 	 * @disabledtest
 	 * en attendant de bien gérer la nouveauté pour les albums bib num (update de notice et non nouvelle création
 	 */
@@ -151,7 +151,7 @@ class RechercheControllerAlbumAudioRecordViewNoticeTest extends RechercheControl
 
 	/** @test */
 	public function titrePrincipalShouldBeSeventhSonOfASeventhSon() {
-		$this->assertXPathContentContains('//h1', 
+		$this->assertXPathContentContains('//h1',
 																			'Seventh Son of a Seventh Son',
 																			$this->_response->getBody());
 	}
@@ -186,28 +186,28 @@ class RechercheControllerAlbumAudioRecordViewNoticeTest extends RechercheControl
 
 	/** @test */
 	public function titresFulltextShouldContainsMOONCHILD() {
-		$this->assertContains('MOONCHILD', 
+		$this->assertContains('MOONCHILD',
 													explode(' ', $this->_notice->getRawAttributes()['titres']));
 	}
 
 
 	/** @test */
 	public function titresFulltextShouldContainsUNKNOWN() {
-		$this->assertContains('UNKNOWN', 
+		$this->assertContains('UNKNOWN',
 													explode(' ', $this->_notice->getRawAttributes()['titres']));
 	}
 
 
 	/** @test */
 	public function titresFulltextShouldContainsPROPHECY() {
-		$this->assertContains('PROPHECY', 
+		$this->assertContains('PROPHECY',
 													explode(' ', $this->_notice->getRawAttributes()['titres']));
 	}
 
 
 	/** @test */
 	public function titresFulltextShouldNotContains502() {
-		$this->assertNotContains('502', 
+		$this->assertNotContains('502',
 														 explode(' ', $this->_notice->getRawAttributes()['titres']));
 	}
 
@@ -291,7 +291,7 @@ class RechercheControllerAlbumAudioRecordViewDetailsTest extends RechercheContro
 
 	/** @test */
 	public function titresShouldContainsIronMaidenAsCodeRebond() {
-		$this->assertXPathContentContains('//dd//a[contains(@href, "code_rebond/A1")]', 
+		$this->assertXPathContentContains('//dd//a[contains(@href, "code_rebond/A1")]',
 																			'Iron Maiden');
 	}
 
@@ -300,13 +300,13 @@ class RechercheControllerAlbumAudioRecordViewDetailsTest extends RechercheContro
 		$this->assertNotXPath('//dt[contains(@class, "internet")]', $this->_response->getBody());
 	}
 
-	
+
 	/** @test */
 	public function distributorShouldBeGeffenRecords() {
-		$this->assertXPathContentContains('//dl//dd', 
+		$this->assertXPathContentContains('//dl//dd',
 																			'Geffen Records',
 																			$this->_response->getBody());
-	} 
+	}
 
 
 	/** @test */
@@ -317,7 +317,7 @@ class RechercheControllerAlbumAudioRecordViewDetailsTest extends RechercheContro
 
 	/** @test */
 	public function aDDForAuthorsShouldContainsBruceDickinsonAsChanteur() {
-		$this->assertXPathContentContains('//dl//dd//a', 
+		$this->assertXPathContentContains('//dl//dd//a',
 																			'Bruce Dickinson (Chanteur)',
 																			$this->_response->getBody());
 	}
@@ -375,7 +375,7 @@ class RechercheControllerAlbumAudioRecordViewRessourcesNumeriquesTest extends Re
 		$this->assertXPathContentContains('//ol//li', 'The prophecy');
 	}
 
-	
+
 	/** @test */
 	public function pageShouldContainsLinkToXSPFPlayList() {
 		$this->assertXPath('//a[contains(@href,"/bib-numerique/album-xspf-playlist/id/4.xspf")]');
@@ -396,7 +396,7 @@ class RechercheControllerAlbumAudioRecordViewRessourceInTelephoneModeTest extend
 		$this->dispatch('/opac/recherche/viewnotice/id/1', true);
 	}
 
-	
+
 	/** @test */
 	public function pageShouldContainsLinkToOpenRessourcesNumeriques() {
 		$this->assertXPathContentContains('//a[contains(@href,"recherche/ressourcesnumeriques/id/1")]','Ecouter l\'album',$this->_response->getBody());
diff --git a/tests/library/Class/Indexation/PseudoNoticeTest.php b/tests/library/Class/Indexation/PseudoNoticeTest.php
index 38ec685aa7f..8f1c5d00591 100644
--- a/tests/library/Class/Indexation/PseudoNoticeTest.php
+++ b/tests/library/Class/Indexation/PseudoNoticeTest.php
@@ -23,6 +23,7 @@ abstract class Class_Indexation_PseudoNoticeTestCase extends Storm_Test_ModelTes
 	public function setUp() {
 		parent::setUp();
 		Class_Notice::beVolatile();
+		Class_Exemplaire::beVolatile();
 	}
 }
 
diff --git a/tests/library/Class/Notice/ClefAlphaTest.php b/tests/library/Class/Notice/ClefAlphaTest.php
index 97490f694b3..91118a5c271 100644
--- a/tests/library/Class/Notice/ClefAlphaTest.php
+++ b/tests/library/Class/Notice/ClefAlphaTest.php
@@ -142,9 +142,7 @@ class Notice_ClefAlphaOnPseudoNoticeTest extends Storm_Test_ModelTestCase {
 									->addAuthor('Bruce Dickinson', 'Chanteur')
 									->addEditor('EMI');
 
-		$this->assertEquals('SEVENTHSONOFASEVENTHSON-EVILTHATMENDO-IRONMAIDEN--EMI-1988-109',
+		$this->assertEquals('SEVENTHSONOFASEVENTHSON-EVILTHATMENDO-IRONMAIDENBRUCEDICKINSON--EMI-1988-109',
 												(new Class_Notice_ClefAlpha($album))->keyString());
 	}
 }
-
-?>
\ No newline at end of file
diff --git a/tests/library/Class/PanierNoticeTest.php b/tests/library/Class/PanierNoticeTest.php
index 28bf30d503d..69f59fd81fc 100644
--- a/tests/library/Class/PanierNoticeTest.php
+++ b/tests/library/Class/PanierNoticeTest.php
@@ -482,8 +482,8 @@ class PanierNoticeIndexAllTest extends ModelTestCase {
 
 
 	/** @test */
-	public function facetOfRecordMontespanShouldContainsFacetH1() {
-		$this->assertContains('H1', Class_Notice::findFirstBy(['clef_alpha' => 'MONTESPAN'])->getFacettes());
+	public function facetOfRecordMontespanShouldContainsFacetQ1() {
+		$this->assertContains('Q1', Class_Notice::findFirstBy(['clef_alpha' => 'MONTESPAN'])->getFacettes());
 	}
 
 
@@ -494,7 +494,7 @@ class PanierNoticeIndexAllTest extends ModelTestCase {
 
 
 	/** @test */
-	public function recordMonstespanShouldNotHaveFacetH2() {
-		$this->assertNotContains('H2', Class_Notice::findFirstBy(['clef_alpha' => 'MONTESPAN'])->getFacettes());
+	public function recordMonstespanShouldNotHaveFacetQ2() {
+		$this->assertNotContains('Q2', Class_Notice::findFirstBy(['clef_alpha' => 'MONTESPAN'])->getFacettes());
 	}
 }
\ No newline at end of file
diff --git a/tests/library/Class/Systeme/ModulesMenu/NumilogTest.php b/tests/library/Class/Systeme/ModulesMenu/NumilogTest.php
index 4d10c49a7ce..c9d408c86a8 100644
--- a/tests/library/Class/Systeme/ModulesMenu/NumilogTest.php
+++ b/tests/library/Class/Systeme/ModulesMenu/NumilogTest.php
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
 
@@ -33,7 +33,7 @@ class Class_Systeme_ModulesMenu_NumilogTest extends Storm_Test_ModelTestCase {
 			'date_debut' => '1999-02-10',
 			'date_fin' => '2025-09-12',
 			'user_groups' => [$this->fixture('Class_UserGroup', [
-				'id' => 20, 
+				'id' => 20,
 				'libelle' => 'Numilog'
 			])->addRight(Class_UserGroup::RIGHT_ACCES_NUMILOG)]
 		])->beAbonneSIGB();
@@ -53,4 +53,3 @@ class Class_Systeme_ModulesMenu_NumilogTest extends Storm_Test_ModelTestCase {
 		$this->assertContains('numilog', $this->menu->getDynamiqueUrl());
 	}
 }
-?>
\ No newline at end of file
-- 
GitLab