From 34d4b71b63ab391c3053f76173b5fde30f990bbc Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@git-test.afi-sa.fr>
Date: Wed, 3 Apr 2013 17:43:09 +0000
Subject: [PATCH] Refacto de la recherche rebond.

---
 .../opac/controllers/RechercheController.php  |   5 +-
 .../views/scripts/recherche/avancee.phtml     |   2 +-
 library/Class/CriteresRecherche.php           |  48 ++-
 library/Class/Dewey.php                       |   2 +-
 library/Class/MoteurRecherche.php             |  23 +-
 .../View/Helper/TagCriteresRecherche.php      |   4 +
 tests/library/Class/CriteresRechercheTest.php |   1 +
 tests/library/Class/MoteurRechercheTest.php   | 345 ++++++++++--------
 8 files changed, 257 insertions(+), 173 deletions(-)

diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php
index 5c38d854423..91dcd0ff4ae 100644
--- a/application/modules/opac/controllers/RechercheController.php
+++ b/application/modules/opac/controllers/RechercheController.php
@@ -176,7 +176,7 @@ class RechercheController extends Zend_Controller_Action
 		$criteres_recherche->setParams($this->_request->getParams());
 
 
-		$this->getFrontController()->getRouter()->getCurrentRoute()->match(str_replace(BASE_URL, '', $this->view->url($criteres_recherche->getCriteres())));
+//		$this->getFrontController()->getRouter()->getCurrentRoute()->match(str_replace(BASE_URL, '', $this->view->url($criteres_recherche->getCriteres())));
 			$ret = $this->moteur->lancerRecherche($criteres_recherche);
 		
 		$this->renderResultatRecherche($criteres_recherche,$ret);
@@ -367,6 +367,7 @@ class RechercheController extends Zend_Controller_Action
 		// Test des parametres
 		$indice=$_REQUEST["rubrique"];
 		if(!$indice) unset($_SESSION["recherche"]);
+		xdebug_break();
 		$fil_ariane=$_SESSION["recherche"]["resultat"]["fil_ariane"]["fil"];
 
 		// Rubriques
@@ -479,7 +480,7 @@ class RechercheController extends Zend_Controller_Action
 		$criteres_recherche = new Class_CriteresRecherche();
 		$criteres_recherche->setParams($this->_request->getParams());
 
- 		$ret=$this->moteur->lancerRechercheRebond($criteres_recherche);
+ 		$ret=$this->moteur->lancerRecherche($criteres_recherche);
 		$this->renderResultatRecherche($criteres_recherche,$ret);
 	}
 
diff --git a/application/modules/opac/views/scripts/recherche/avancee.phtml b/application/modules/opac/views/scripts/recherche/avancee.phtml
index 2dc02525b0a..fb98adbe4b0 100644
--- a/application/modules/opac/views/scripts/recherche/avancee.phtml
+++ b/application/modules/opac/views/scripts/recherche/avancee.phtml
@@ -2,7 +2,7 @@
 if ($this->statut == "saisie") {
 	$this->openBoite($this->current_module["preferences"]["titre"]);
 	?>
-	<form method="post" action="<?php print(BASE_URL); ?>/opac/recherche/simple" name="recherche_avancee" class="recherche_avancee">
+	<form method="get" action="<?php print(BASE_URL); ?>/opac/recherche/simple" name="recherche_avancee" class="recherche_avancee">
 		<div class="contenu">
 			<table style="border-collapse: collapse;">
 				<tr><td><?php if ($this->current_module["preferences"]["select_bib"] == 1) echo $_SESSION["selection_bib"]["html"] ?></td></tr>
diff --git a/library/Class/CriteresRecherche.php b/library/Class/CriteresRecherche.php
index 2660bbfe7d6..c3224396ce5 100644
--- a/library/Class/CriteresRecherche.php
+++ b/library/Class/CriteresRecherche.php
@@ -40,7 +40,7 @@ class Class_CriteresRecherche {
 	];
 
 	public function getValidParameters() {
-		return array_merge(array_keys(self::$criteres), [ 'id_panier','id_module', 'facette','facettes', 'operateur_titres','operateur_auteurs','operateur_matieres','operateur_dewey','operateur_editeur','operateur_collection','code_rebond','pertinence','type_recherche','section','annexe']);
+		return array_merge(array_keys(self::$criteres), [ 'id_panier','id_module', 'facette','facettes', 'operateur_titres','operateur_auteurs','operateur_matieres','operateur_dewey','operateur_editeur','operateur_collection','code_rebond','pertinence','type_recherche','section','annexe','geo_zone']);
 	}
 
 	public function getListeTris() {
@@ -81,6 +81,9 @@ class Class_CriteresRecherche {
 		return  array_unique(array_filter($facettes));
 	}
 
+	public function getGeoZone(){
+		return $this->getParam('geo_zone',false);
+	}
 	
 	public function getFiltres() {
 		$profil = Class_Profil::getCurrentProfil();
@@ -89,6 +92,15 @@ class Class_CriteresRecherche {
 								$this->selectionToArray('Y', $profil->getSelAnnexe()),
 								$this->selectionToArray('S', $profil->getSelSection())];
 
+		if ($geo_zone=$this->getGeoZone()) {
+			$all_bibs=Class_Zone::find($geo_zone)->getBibs();
+			$bib_ids=[];
+			foreach ($all_bibs as $bib) {
+				$bib_ids[]='B'.$bib->getId();
+			}
+			$filtres[]=$bib_ids;
+		}
+
 		return  array_filter($filtres);
 	}
 
@@ -132,11 +144,16 @@ class Class_CriteresRecherche {
 	}
 	
 
+	public function visitByRechercheType($visitor) {
+		if ($code_rebond = $this->getCodeRebond()) {
+			$visitor->visitCodeRebond($code_rebond);
+			return;
+		}
 
-
-	public function acceptVisitor($visitor) {
-		if ($expression = $this->getExpressionRecherche()) 
+		if ($expression = $this->getExpressionRecherche())  {
 			$visitor->visitExpression($expression,$this->getPertinence(),$this->getTri());
+			
+		}
 		
 
 		$type_recherche = $this->getTypeRecherche();
@@ -150,14 +167,6 @@ class Class_CriteresRecherche {
 		if ($type_doc = $this->getParam('type_doc'))
 			$visitor->visitTypeDoc($type_doc);
 
-		$facettes = $this->getFacettes();
-		foreach($facettes as $facette)
-			$visitor->visitFacette($facette);
-
-		$filtres = $this->getFiltres();
-		foreach($filtres as $filtre) 
-			$visitor->visitFiltre($filtre);
-
 		if ($annexe = $this->getParam('annexe'))
 			$visitor->visitAnnexe($annexe);
 
@@ -169,6 +178,21 @@ class Class_CriteresRecherche {
 		if ($nouveaute)
 			$visitor->visitNouveaute($nouveaute);
 
+}
+
+	public function acceptVisitor($visitor) {
+		$this->visitByRechercheType($visitor);
+
+		$facettes = $this->getFacettes();
+		foreach($facettes as $facette)
+			$visitor->visitFacette($facette);
+
+		$filtres = $this->getFiltres();
+		foreach($filtres as $filtre) 
+			$visitor->visitFiltre($filtre);
+		
+
+
 	}
 
 
diff --git a/library/Class/Dewey.php b/library/Class/Dewey.php
index 4b802ac95f8..29c77ca8ede 100644
--- a/library/Class/Dewey.php
+++ b/library/Class/Dewey.php
@@ -22,7 +22,7 @@
 // OPAC 3 :INDICES DEWEY
 ///////////////////////////////////////////////////////////////////////////////////////
 
-class Class_Dewey
+class Class_Dewey extends Storm_Model_Loader
 {
 
 // ----------------------------------------------------------------
diff --git a/library/Class/MoteurRecherche.php b/library/Class/MoteurRecherche.php
index 4b4f46ed065..16dc7e95156 100644
--- a/library/Class/MoteurRecherche.php
+++ b/library/Class/MoteurRecherche.php
@@ -171,6 +171,11 @@ class Class_MoteurRecherche {
 
 	}
 
+	public function visitCodeRebond($code_rebond) {
+		$this->visitFacette($code_rebond);
+	}
+
+
 	public function visitExpression($expression,$pertinence,$tri) {
 		// Analyse de l'expression
 		$expression = trim($expression);
@@ -246,13 +251,15 @@ public function visitAnneeDebutFin($annee_debut,$annee_fin) {
 
 
 	public function visitAnnexe($annexe) {
-		$this->conditions.=" And MATCH(facettes) AGAINST('+Y".$annexe."' IN BOOLEAN MODE)";
+	$this->all_facettes .= ' +Y'.$annexe;
+//		$this->conditions.=" And MATCH(facettes) AGAINST('+Y".$annexe."' IN BOOLEAN MODE)";
 	}
 
 	public function visitNouveaute($nouveaute) {
-		$secs=$nouveaute * 30.5 * 24 * 3600;
-		$date=time() - $secs;
-		$date=date("Y-m-d",$date);
+		$date = date('Y-m-d',mktime(0, 0, 0, date("m")-$nouveaute,   date("d"),   date("Y")));
+//		$secs=$nouveaute * 30.5 * 24 * 3600;
+//		$date=time() - $secs;
+		//	$date=date("Y-m-d",$date);
 		if ($this->conditions!='') $this->conditions.=" and" ;
 		$this->conditions.=" date_creation >'".$date."' ";
 	}
@@ -278,7 +285,7 @@ public function visitAnneeDebutFin($annee_debut,$annee_fin) {
 		if(!$recherche) return ;
 		if (!$operateur) $operateur='and';
 		if($this->conditions) $this->conditions.=" ".$operateur." ";
-		elseif(striPos($operateur,"NOT")) $this->conditions.=" not ";
+		elseif(striPos($operateur,"NOT")) $this->conditions.="not ";
 				
 		// Type de recherche
 		if($type_recherche == "fulltext") {
@@ -311,8 +318,8 @@ public function visitAnneeDebutFin($annee_debut,$annee_fin) {
 		$criteres_recherche->acceptVisitor($this);
 		if ($this->all_facettes) {
 			if ($this->conditions!='')
-				$this->conditions.=' And';
-			$this->conditions.=" MATCH(facettes) AGAINST('".trim($this->all_facettes)."' IN BOOLEAN MODE)";}
+				$this->conditions.=' And ';
+			$this->conditions.="MATCH(facettes) AGAINST('".trim($this->all_facettes)."' IN BOOLEAN MODE)";}
 		$where='';
 		if ($this->conditions)
 			$where="Where ".$this->conditions;
@@ -394,7 +401,7 @@ public function visitAnneeDebutFin($annee_debut,$annee_fin) {
 			$facette=str_replace("["," +",$facette); $facette=str_replace("]"," ",$facette);}
 		$facette.="+".$rebond." ";
 
-		$conditions=" Where MATCH(facettes) AGAINST('".$facette."' IN BOOLEAN MODE)";
+		$conditions="Where MATCH(facettes) AGAINST('".$facette."' IN BOOLEAN MODE)";
 		if($type_doc) $conditions.=" And type_doc in(".$type_doc.")";
 		$order_by=" order by alpha_titre";
 		if (($tri > "") && ($tri !== '*')) 
diff --git a/library/ZendAfi/View/Helper/TagCriteresRecherche.php b/library/ZendAfi/View/Helper/TagCriteresRecherche.php
index 08e6f5dfae2..bed2b831117 100644
--- a/library/ZendAfi/View/Helper/TagCriteresRecherche.php
+++ b/library/ZendAfi/View/Helper/TagCriteresRecherche.php
@@ -70,6 +70,10 @@ class ZendAfi_View_Helper_TagCriteresRecherche extends Zend_View_Helper_HtmlElem
 		$this->htmlAppend($this->view->_("Type de document : %s", Class_Codification::getLibelleFacette("T".$type_doc)));
 	}
 
+	public function visitCodeRebond($code_rebond) {
+		$this->htmlAppend($this->view->_("Recherche élargie à : %s", Class_Codification::getLibelleFacette($code_rebond)));
+	}
+
 
 	public function visitAnneeDebutFin($annee_debut, $annee_fin) {
 		$texte = $this->view->_("Documents parus ");
diff --git a/tests/library/Class/CriteresRechercheTest.php b/tests/library/Class/CriteresRechercheTest.php
index 2bea58c115f..f3cb41c8fed 100644
--- a/tests/library/Class/CriteresRechercheTest.php
+++ b/tests/library/Class/CriteresRechercheTest.php
@@ -226,6 +226,7 @@ class CriteresRechercheFilterParamsTest extends AbstractControllerTestCase {
 
 			[['rech_titres' => 'No-logo',
 				'rech_auteurs' =>'',
+				'code_rebond' =>'',
 				'operateur_editeur' => 'and',
 				'operateur_titres' => 'or',
 
diff --git a/tests/library/Class/MoteurRechercheTest.php b/tests/library/Class/MoteurRechercheTest.php
index 538610adb36..46ca2a2e073 100644
--- a/tests/library/Class/MoteurRechercheTest.php
+++ b/tests/library/Class/MoteurRechercheTest.php
@@ -1,4 +1,4 @@
-<?php
+o<?php
 /**
  * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
  *
@@ -19,7 +19,17 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
  */
 
-class MoteurRechercheAvanceeTest extends Storm_Test_ModelTestCase {
+abstract class MoteurRechercheAbstractTest extends Storm_Test_ModelTestCase {
+	protected $lastyear;
+	protected $mock_sql;
+	protected $last3months;
+	
+	public function __construct($name = NULL, array $data = array(), $dataName = '') {
+		parent::__construct($name,$data,$dataName);
+		$this->lastyear = date('Y-m-d',mktime(0, 0, 0, date("m")-12,   date("d"),   date("Y")));
+		$this->last3months = date('Y-m-d',mktime(0, 0, 0, date("m")-3,   date("d"),   date("Y")));
+	}
+
 	public function setUp() {
 		parent::setUp();
 
@@ -33,6 +43,36 @@ class MoteurRechercheAvanceeTest extends Storm_Test_ModelTestCase {
 		$this->moteur_recherche = new Class_MoteurRecherche();
 	}
 
+	public function mockReqProfilAndZone($req_comptage,$params) {
+		$this->mock_sql
+			->expects($this->once())
+			->method('fetchOne')
+			->with($req_comptage)
+			->will($this->returnValue(10));
+
+		Class_Zone::newInstanceWithId(2)
+			->setBibs([ Class_Bib::newInstanceWithId(3),
+									Class_Bib::newInstanceWithId(4)
+									]);
+		$profil = Class_Profil::getLoader()->newInstanceWithId(26)
+			->setTypeDoc('1');
+		
+		if (isset($params['selection_annexe']))
+			$profil->setSelAnnexe($params['selection_annexe']);
+		if (isset($params['selection_bib']))
+			$profil->setIdSite($params['selection_bib']);
+		if (isset($params['selection_sections']))
+			$profil->setSelSection($params['selection_sections']);
+		Class_Profil::setCurrentProfil($profil);
+		
+	}
+}
+
+class MoteurRechercheAvanceeTest extends MoteurRechercheAbstractTest {
+	public function setUp() {
+		parent::setUp();
+	}
+
 
 	public function tearDown() {
 		Zend_Registry::set('sql', $this->_original_sql);
@@ -41,8 +81,7 @@ class MoteurRechercheAvanceeTest extends Storm_Test_ModelTestCase {
 
 
 	public function expectedSql() {
-		$lastyear = date('Y-m-d',mktime(0, 0, 0, date("m"),   date("d")-1,   date("Y")-1));
-		$last3months = date('Y-m-d',mktime(0, 0, 0, date("m"),   date("d"),   date("Y"))-3*30.5 * 24 * 3600);
+
 		return 		[
 			[['rech_auteurs' => 'Foucault', 'operateur_auteurs' => 'and', 'type_recherche' => 'fulltext', 'pertinence' => false, 'tri' => 'alpha_auteurs'] ,
 				'req_notices' => "Select id_notice from notices Where MATCH(auteurs) AGAINST('+(FOUCAULT FOUCAULTS FOUKOLT)' IN BOOLEAN MODE)  order by alpha_auteurs",
@@ -60,9 +99,9 @@ class MoteurRechercheAvanceeTest extends Storm_Test_ModelTestCase {
 			 'annexe' => 'MED1',
 			 'selection_annexe' => 'TUN;TAP',
 			 'type_recherche' => 'commence', 'pertinence' => true, 'tri' => 'alpha_titres'] ,
-			'req_notices' => "Select id_notice from notices Where auteurs like 'CLASTRES%' And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+(YTUN YTAP)' IN BOOLEAN MODE) order by alpha_titres",
-			'req_comptage' => "Select count(*) from notices Where auteurs like 'CLASTRES%' And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+(YTUN YTAP)' IN BOOLEAN MODE)",
-			'req_facettes' => "Select id_notice,type_doc,facettes from notices Where auteurs like 'CLASTRES%' And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+(YTUN YTAP)' IN BOOLEAN MODE) limit 15000"
+			'req_notices' => "Select id_notice from notices Where auteurs like 'CLASTRES%' And MATCH(facettes) AGAINST('+YMED1 +(YTUN YTAP)' IN BOOLEAN MODE) order by alpha_titres",
+			'req_comptage' => "Select count(*) from notices Where auteurs like 'CLASTRES%' And MATCH(facettes) AGAINST('+YMED1 +(YTUN YTAP)' IN BOOLEAN MODE)",
+			'req_facettes' => "Select id_notice,type_doc,facettes from notices Where auteurs like 'CLASTRES%' And MATCH(facettes) AGAINST('+YMED1 +(YTUN YTAP)' IN BOOLEAN MODE) limit 15000"
 			]  ,
 
 			[ ['rech_matieres' => 'Philosophie', 'operateur_matieres' => 'and not',
@@ -71,9 +110,9 @@ class MoteurRechercheAvanceeTest extends Storm_Test_ModelTestCase {
 				 'annee_fin' => '2013',
 				 'nouveaute' => '12',
 				 'type_recherche' => 'commence', 'pertinence' => true, 'tri' => 'alpha_titres'] ,
-				'req_notices' => "Select id_notice from notices Where  not matieres like 'PHILOSOPHIE%' and annee >='1960'  and annee <='2013'  and date_creation >'".$lastyear."'  And MATCH(facettes) AGAINST('+T1' IN BOOLEAN MODE) order by alpha_titres",
-				'req_comptage' => "Select count(*) from notices Where  not matieres like 'PHILOSOPHIE%' and annee >='1960'  and annee <='2013'  and date_creation >'".$lastyear."'  And MATCH(facettes) AGAINST('+T1' IN BOOLEAN MODE)",
-				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where  not matieres like 'PHILOSOPHIE%' and annee >='1960'  and annee <='2013'  and date_creation >'".$lastyear."'  And MATCH(facettes) AGAINST('+T1' IN BOOLEAN MODE) limit 15000"
+				'req_notices' => "Select id_notice from notices Where not matieres like 'PHILOSOPHIE%' and annee >='1960'  and annee <='2013'  and date_creation >'".$this->lastyear."'  And MATCH(facettes) AGAINST('+T1' IN BOOLEAN MODE) order by alpha_titres",
+				'req_comptage' => "Select count(*) from notices Where not matieres like 'PHILOSOPHIE%' and annee >='1960'  and annee <='2013'  and date_creation >'".$this->lastyear."'  And MATCH(facettes) AGAINST('+T1' IN BOOLEAN MODE)",
+				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where not matieres like 'PHILOSOPHIE%' and annee >='1960'  and annee <='2013'  and date_creation >'".$this->lastyear."'  And MATCH(facettes) AGAINST('+T1' IN BOOLEAN MODE) limit 15000"
 				]  ,
 
 
@@ -83,19 +122,21 @@ class MoteurRechercheAvanceeTest extends Storm_Test_ModelTestCase {
 					'selection_bib'=> 1,
 					'nouveaute' => '3',
 					'type_recherche' => 'nimportequoi', 'pertinence' => false, 'tri' => 'alpha_titres'] ,
-				'req_notices' => "Select id_notice from notices Where MATCH(titres) AGAINST('+(NOUVEAU NOUVEAUX NOUVO) +(CHIEN CHIENS CHIN) +(GARDE GARDES GARD)' IN BOOLEAN MODE)  or MATCH(editeur) AGAINST('+(RAISON RAISONS RAISON) +(D00 D00S ) +(AGIR AGIRS AJIR)' IN BOOLEAN MODE)  and date_creation >'".$last3months."'  And MATCH(facettes) AGAINST('+B1' IN BOOLEAN MODE) order by alpha_titres",
-				'req_comptage' => "Select count(*) from notices Where MATCH(titres) AGAINST('+(NOUVEAU NOUVEAUX NOUVO) +(CHIEN CHIENS CHIN) +(GARDE GARDES GARD)' IN BOOLEAN MODE)  or MATCH(editeur) AGAINST('+(RAISON RAISONS RAISON) +(D00 D00S ) +(AGIR AGIRS AJIR)' IN BOOLEAN MODE)  and date_creation >'2012-12-12'  And MATCH(facettes) AGAINST('+B1' IN BOOLEAN MODE)",
-				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(titres) AGAINST('+(NOUVEAU NOUVEAUX NOUVO) +(CHIEN CHIENS CHIN) +(GARDE GARDES GARD)' IN BOOLEAN MODE)  or MATCH(editeur) AGAINST('+(RAISON RAISONS RAISON) +(D00 D00S ) +(AGIR AGIRS AJIR)' IN BOOLEAN MODE)  and date_creation >'".$last3months."'  And MATCH(facettes) AGAINST('+B1' IN BOOLEAN MODE) limit 15000"
+				'req_notices' => "Select id_notice from notices Where MATCH(titres) AGAINST('+(NOUVEAU NOUVEAUX NOUVO) +(CHIEN CHIENS CHIN) +(GARDE GARDES GARD)' IN BOOLEAN MODE)  or MATCH(editeur) AGAINST('+(RAISON RAISONS RAISON) +(D00 D00S ) +(AGIR AGIRS AJIR)' IN BOOLEAN MODE)  and date_creation >'".$this->last3months."'  And MATCH(facettes) AGAINST('+B1' IN BOOLEAN MODE) order by alpha_titres",
+				'req_comptage' => "Select count(*) from notices Where MATCH(titres) AGAINST('+(NOUVEAU NOUVEAUX NOUVO) +(CHIEN CHIENS CHIN) +(GARDE GARDES GARD)' IN BOOLEAN MODE)  or MATCH(editeur) AGAINST('+(RAISON RAISONS RAISON) +(D00 D00S ) +(AGIR AGIRS AJIR)' IN BOOLEAN MODE)  and date_creation >'".$this->last3months."'  And MATCH(facettes) AGAINST('+B1' IN BOOLEAN MODE)",
+				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(titres) AGAINST('+(NOUVEAU NOUVEAUX NOUVO) +(CHIEN CHIENS CHIN) +(GARDE GARDES GARD)' IN BOOLEAN MODE)  or MATCH(editeur) AGAINST('+(RAISON RAISONS RAISON) +(D00 D00S ) +(AGIR AGIRS AJIR)' IN BOOLEAN MODE)  and date_creation >'".$this->last3months."'  And MATCH(facettes) AGAINST('+B1' IN BOOLEAN MODE) limit 15000"
 				],
+
 			[ ['rech_auteurs' => 'Stiegler', 'operateur_auteurs' => 'and', 
 				 'annexe' => 'MED1',
 				 'facettes' => 'G23-A345', 
 				 'selection_annexe' => 'TUN;TAP',
 				 'selection_sections' => '1;12;9',
+				 'geo_zone' => 2,
 				 'type_recherche' => 'commence', 'pertinence' => true, 'tri' => 'alpha_titres'] ,
-				'req_notices' => "Select id_notice from notices Where auteurs like 'STIEGLER%' And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+G23 +A345 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE) order by alpha_titres",
-				'req_comptage' => "Select count(*) from notices Where auteurs like 'STIEGLER%' And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+G23 +A345 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE)",
-				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where auteurs like 'STIEGLER%' And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+G23 +A345 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE) limit 15000"
+				'req_notices' => "Select id_notice from notices Where auteurs like 'STIEGLER%' And MATCH(facettes) AGAINST('+YMED1 +G23 +A345 +(YTUN YTAP)  +(S1 S12 S9)  +(B3 B4)' IN BOOLEAN MODE) order by alpha_titres",
+				'req_comptage' => "Select count(*) from notices Where auteurs like 'STIEGLER%' And MATCH(facettes) AGAINST('+YMED1 +G23 +A345 +(YTUN YTAP)  +(S1 S12 S9)  +(B3 B4)' IN BOOLEAN MODE)",
+				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where auteurs like 'STIEGLER%' And MATCH(facettes) AGAINST('+YMED1 +G23 +A345 +(YTUN YTAP)  +(S1 S12 S9)  +(B3 B4)' IN BOOLEAN MODE) limit 15000"
 				]  
   
 			
@@ -110,20 +151,9 @@ class MoteurRechercheAvanceeTest extends Storm_Test_ModelTestCase {
 	 */
 			public function lancerRechercheAvanceeShouldBe($params, $req_notices, $req_comptage ,$req_facettes) {
 				
-				$this->mock_sql
-					->expects($this->once())
-					->method('fetchOne')
-					->with($req_comptage)
-					->will($this->returnValue(10));
-				$profil = Class_Profil::getLoader()->newInstanceWithId(26)
-					->setTypeDoc('1');
-				if (isset($params['selection_annexe']))
-					$profil->setSelAnnexe($params['selection_annexe']);
-				if (isset($params['selection_bib']))
-					$profil->setIdSite($params['selection_bib']);
-				if (isset($params['selection_sections']))
-					$profil->setSelSection($params['selection_sections']);
-				Class_Profil::setCurrentProfil($profil);
+				
+				$this->mockReqProfilAndZone($req_comptage,$params);
+
 				$this->criteres_recherche->setParams($params);
 				$retour = $this->moteur_recherche->lancerRecherche( $this->criteres_recherche);
 				$this->assertEquals(['nombre' => 10,
@@ -138,18 +168,10 @@ class MoteurRechercheAvanceeTest extends Storm_Test_ModelTestCase {
 
 }
 
-class MoteurRechercheSimpleTest extends Storm_Test_ModelTestCase {
+class MoteurRechercheSimpleTest extends MoteurRechercheAbstractTest {
 	public function setUp() {
 		parent::setUp();
 
-		$this->_original_sql = Zend_Registry::get('sql');
-		$this->mock_sql = $this->getMockBuilder('Class_Systeme_Sql')
-                         			->disableOriginalConstructor()
-                        			->getMock();
-		Zend_Registry::set('sql', $this->mock_sql);
-
-		$this->criteres_recherche= new Class_CriteresRecherche();
-		$this->moteur_recherche = new Class_MoteurRecherche();
 	}
 
 
@@ -160,8 +182,7 @@ class MoteurRechercheSimpleTest extends Storm_Test_ModelTestCase {
 
 
 	public function expectedSql() {
-		$lastyear = date('Y-m-d',mktime(0, 0, 0, date("m"),   date("d")-1,   date("Y")-1));
-		$last3months = date('Y-m-d',mktime(0, 0, 0, date("m"),   date("d")+1,   date("Y"))-3*30.5 * 24 * 3600);
+
 		return 		[
 			[['expressionRecherche' => 'Bakounine'],
 				'nb_mots' => 1,
@@ -184,17 +205,18 @@ class MoteurRechercheSimpleTest extends Storm_Test_ModelTestCase {
 			 'selection_annexe' => 'TUN;TAP',
 			  'tri' => 'alpha_titres'] ,
 				'nb_mots' => 2,
-				'req_comptage' => "Select count(*) from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(COMMUNE COMMUNES KOMUN) +(PARI PARIS PARI)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+(YTUN YTAP)' IN BOOLEAN MODE)",
-				'req_liste' => "Select id_notice from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(COMMUNE COMMUNES KOMUN) +(PARI PARIS PARI)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+(YTUN YTAP)' IN BOOLEAN MODE) order by alpha_titres",
-				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(COMMUNE COMMUNES KOMUN) +(PARI PARIS PARI)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+(YTUN YTAP)' IN BOOLEAN MODE) limit 15000"
+				'req_comptage' => "Select count(*) from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(COMMUNE COMMUNES KOMUN) +(PARI PARIS PARI)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1 +(YTUN YTAP)' IN BOOLEAN MODE)",
+				'req_liste' => "Select id_notice from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(COMMUNE COMMUNES KOMUN) +(PARI PARIS PARI)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1 +(YTUN YTAP)' IN BOOLEAN MODE) order by alpha_titres",
+				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(COMMUNE COMMUNES KOMUN) +(PARI PARIS PARI)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1 +(YTUN YTAP)' IN BOOLEAN MODE) limit 15000"
 			]  ,
 
 			[ ['expressionRecherche' => '2-7427-3315-9',
+				 'geo_zone' => 2,
 				  'tri' => 'alpha_auteurs'] ,
 				'nb_mots'=> null,
-				'req_comptage' => "Select count(*) from notices Where (isbn='2-7427-3315-9' or isbn='978-2-7427-3315-6') ",
-				'req_liste' => "Select id_notice from notices Where (isbn='2-7427-3315-9' or isbn='978-2-7427-3315-6')  order by alpha_auteurs",
-				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where (isbn='2-7427-3315-9' or isbn='978-2-7427-3315-6')  limit 15000"
+				'req_comptage' => "Select count(*) from notices Where (isbn='2-7427-3315-9' or isbn='978-2-7427-3315-6')  And MATCH(facettes) AGAINST('+(B3 B4)' IN BOOLEAN MODE)",
+				'req_liste' => "Select id_notice from notices Where (isbn='2-7427-3315-9' or isbn='978-2-7427-3315-6')  And MATCH(facettes) AGAINST('+(B3 B4)' IN BOOLEAN MODE) order by alpha_auteurs",
+				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where (isbn='2-7427-3315-9' or isbn='978-2-7427-3315-6')  And MATCH(facettes) AGAINST('+(B3 B4)' IN BOOLEAN MODE) limit 15000"
 
 				]  ,
 
@@ -229,9 +251,9 @@ class MoteurRechercheSimpleTest extends Storm_Test_ModelTestCase {
 				 'selection_sections' => '1;12;9'
 				 ] ,
 		 'nb_mots'=> 1,
-					'req_comptage' => "Select count(*) from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE)",
-					'req_liste' => "Select id_notice,MATCH(alpha_titre)  AGAINST(' (LOGO LOGOS LOGO)' ) as rel1, MATCH(alpha_auteur) AGAINST(' (LOGO LOGOS LOGO)' ) as rel2 from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE) order by (rel1 * 1.5)+(rel2) desc",
-				  'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE) limit 15000"  
+					'req_comptage' => "Select count(*) from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1 +M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE)",
+					'req_liste' => "Select id_notice,MATCH(alpha_titre)  AGAINST(' (LOGO LOGOS LOGO)' ) as rel1, MATCH(alpha_auteur) AGAINST(' (LOGO LOGOS LOGO)' ) as rel2 from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1 +M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE) order by (rel1 * 1.5)+(rel2) desc",
+				  'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1 +M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE) limit 15000"  
   
 			
 					]
@@ -244,21 +266,7 @@ class MoteurRechercheSimpleTest extends Storm_Test_ModelTestCase {
 	 * @test 
 	 */
 	public function lancerRechercheSimpleShouldBe($params, $nb_mots,$req_comptage ,$req_notices ,$req_facettes) {
-				
-				$this->mock_sql
-					->expects($this->once())
-					->method('fetchOne')
-					->with($req_comptage)
-					->will($this->returnValue(10));
-				$profil = Class_Profil::getLoader()->newInstanceWithId(26)
-					->setTypeDoc('1');
-				if (isset($params['selection_annexe']))
-					$profil->setSelAnnexe($params['selection_annexe']);
-				if (isset($params['selection_bib']))
-					$profil->setIdSite($params['selection_bib']);
-				if (isset($params['selection_sections']))
-					$profil->setSelSection($params['selection_sections']);
-				Class_Profil::setCurrentProfil($profil);
+				$this->mockReqProfilAndZone($req_comptage,$params);				
 				$this->criteres_recherche->setParams($params);
 				$retour = $this->moteur_recherche->lancerRecherche( $this->criteres_recherche);
 				$this->assertEquals(['nombre' => 10,
@@ -275,18 +283,9 @@ class MoteurRechercheSimpleTest extends Storm_Test_ModelTestCase {
 
 
 
-class MoteurRechercheRebondTest extends Storm_Test_ModelTestCase {
+class MoteurRechercheRebondTest extends MoteurRechercheAbstractTest {
 	public function setUp() {
 		parent::setUp();
-
-		$this->_original_sql = Zend_Registry::get('sql');
-		$this->mock_sql = $this->getMockBuilder('Class_Systeme_Sql')
-                         			->disableOriginalConstructor()
-                        			->getMock();
-		Zend_Registry::set('sql', $this->mock_sql);
-
-		$this->criteres_recherche= new Class_CriteresRecherche();
-		$this->moteur_recherche = new Class_MoteurRecherche();
 	}
 
 
@@ -297,119 +296,167 @@ class MoteurRechercheRebondTest extends Storm_Test_ModelTestCase {
 
 
 	public function expectedSql() {
-		$lastyear = date('Y-m-d',mktime(0, 0, 0, date("m"),   date("d")-1,   date("Y")-1));
-		$last3months = date('Y-m-d',mktime(0, 0, 0, date("m"),   date("d")+1,   date("Y"))-3*30.5 * 24 * 3600);
+
 		return 		[
 			[['expressionRecherche' => 'Un titre juste pour l\'historique',
 					'code_rebond'=> 'A774'],
-				'nb_mots' => 1,
-			'req_comptage' => "Select count(*) from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(BAKOUNINE BAKOUNINES BAKOUNIN)' IN BOOLEAN MODE)",
-			 'req_liste' => "Select id_notice,MATCH(alpha_titre)  AGAINST(' (BAKOUNINE BAKOUNINES BAKOUNIN)' ) as rel1, MATCH(alpha_auteur) AGAINST(' (BAKOUNINE BAKOUNINES BAKOUNIN)' ) as rel2 from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(BAKOUNINE BAKOUNINES BAKOUNIN)' IN BOOLEAN MODE) order by (rel1 * 1.5)+(rel2) desc",
+		
+			 'req_comptage' =>"Select count(*) from notices Where MATCH(facettes) AGAINST('+A774' IN BOOLEAN MODE)",
+			 'req_liste' => "Select id_notice from notices Where MATCH(facettes) AGAINST('+A774' IN BOOLEAN MODE)",
 	
-			 'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(BAKOUNINE BAKOUNINES BAKOUNIN)' IN BOOLEAN MODE) limit 15000"
+			 'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(facettes) AGAINST('+A774' IN BOOLEAN MODE) limit 15000"
 					],
 
 		[ ['expressionRecherche' => 'Davodeau',  
 			 'tri' => 'alpha_titres',
-				'code_rebond' => 'A888'] ,
-				'nb_mots' => 2,
-			'req_comptage' => "Select count(*) from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(SLAVOJ SLAVOJS SLAVOJ) +(ZIZEK ZIZEKS ZIZEK)' IN BOOLEAN MODE)",
-			'req_liste' => "Select id_notice from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(SLAVOJ SLAVOJS SLAVOJ) +(ZIZEK ZIZEKS ZIZEK)' IN BOOLEAN MODE) order by alpha_titres",
-			'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(SLAVOJ SLAVOJS SLAVOJ) +(ZIZEK ZIZEKS ZIZEK)' IN BOOLEAN MODE) limit 15000"
+			 'code_rebond' => 'A888',
+				'geo_zone' => 2] ,
+		
+			'req_comptage' => "Select count(*) from notices Where MATCH(facettes) AGAINST('+A888 +(B3 B4)' IN BOOLEAN MODE)",
+			'req_liste' => "Select id_notice from notices Where MATCH(facettes) AGAINST('+A888 +(B3 B4)' IN BOOLEAN MODE) order by alpha_titres",
+			'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(facettes) AGAINST('+A888 +(B3 B4)' IN BOOLEAN MODE) limit 15000"
 
 			]  ,
 
 			[ ['rech_auteurs' =>  'The Ex',
 				 'operateur_auteurs' => 'or',
 				 'code_rebond' => 'A111',
-			 'annexe' => 'MED1',
 			 'selection_annexe' => 'TUN;TAP',
 			  'tri' => 'alpha_titres'] ,
-				'nb_mots' => 2,
-				'req_comptage' => "Select count(*) from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(COMMUNE COMMUNES KOMUN) +(PARI PARIS PARI)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+(YTUN YTAP)' IN BOOLEAN MODE)",
-				'req_liste' => "Select id_notice from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(COMMUNE COMMUNES KOMUN) +(PARI PARIS PARI)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+(YTUN YTAP)' IN BOOLEAN MODE) order by alpha_titres",
-				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(COMMUNE COMMUNES KOMUN) +(PARI PARIS PARI)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+(YTUN YTAP)' IN BOOLEAN MODE) limit 15000"
+		
+				'req_comptage' => "Select count(*) from notices Where MATCH(facettes) AGAINST('+A111 +(YTUN YTAP)' IN BOOLEAN MODE)",
+				'req_liste' => "Select id_notice from notices Where MATCH(facettes) AGAINST('+A111 +(YTUN YTAP)' IN BOOLEAN MODE) order by alpha_titres",
+				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(facettes) AGAINST('+A111 +(YTUN YTAP)' IN BOOLEAN MODE) limit 15000"
 			]  ,
 
 			[ ['expressionRecherche' => '2-7427-3315-9',
+				 'code_rebond' => 'A91919',
 				  'tri' => 'alpha_auteurs'] ,
-				'nb_mots'=> null,
-				'req_comptage' => "Select count(*) from notices Where (isbn='2-7427-3315-9' or isbn='978-2-7427-3315-6') ",
-				'req_liste' => "Select id_notice from notices Where (isbn='2-7427-3315-9' or isbn='978-2-7427-3315-6')  order by alpha_auteurs",
-				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where (isbn='2-7427-3315-9' or isbn='978-2-7427-3315-6')  limit 15000"
+			
+				'req_comptage' => "Select count(*) from notices Where MATCH(facettes) AGAINST('+A91919' IN BOOLEAN MODE)",
+				'req_liste' => "Select id_notice from notices Where MATCH(facettes) AGAINST('+A91919' IN BOOLEAN MODE) order by alpha_auteurs",
+				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(facettes) AGAINST('+A91919' IN BOOLEAN MODE) limit 15000"
 
 				]  ,
+			
+			[ ['expressionRecherche' => 'La nouvelle grille',
+				 'code_rebond' => 'A92929',
+				 'facettes' => 'M52291-A15067', 
+				 'selection_annexe' => 'TUN;TAP',
+				 'selection_sections' => '1;12;9'
+				 ] ,
+		
+				'req_comptage' => "Select count(*) from notices Where MATCH(facettes) AGAINST('+A92929 +M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE)",
+				'req_liste' => "Select id_notice from notices Where MATCH(facettes) AGAINST('+A92929 +M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE)",
+				  'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(facettes) AGAINST('+A92929 +M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE) limit 15000"
+  
+			
+					]
 
+			];
+	}
 
-			[ [ 'expressionRecherche' => '9782742761579' ] ,
-				'nb_mots'=> null,
-				'req_comptage' => "Select count(*) from notices Where (isbn='2-7427-6157-8' or isbn='978-2-7427-6157-9') ",
-				'req_liste' => "Select id_notice from notices Where (isbn='2-7427-6157-8' or isbn='978-2-7427-6157-9') ",
-				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where (isbn='2-7427-6157-8' or isbn='978-2-7427-6157-9')  limit 15000"
-				],
+	/** 
+	 * @dataProvider expectedSql
+	 * @test 
+	 */
+	public function lancerRechercheRebondShouldBe($params, $req_comptage ,$req_notices ,$req_facettes) {
+		$this->mockReqProfilAndZone($req_comptage,$params);				
+		$this->criteres_recherche->setParams($params);
+		$retour = $this->moteur_recherche->lancerRecherche($this->criteres_recherche);
+		$this->assertEquals(['nombre' => 10,
+												 'nb_mots' => 0,
+												 'statut' => '',
+											
+												 'req_liste' => $req_notices,
+												 'req_facettes' => $req_facettes],
+												$retour);
+		
+	}
 
-	/*		[ [ 'expressionRecherche' => 'Les ignorants' , 'clef_chapeau' => 'IGNORANTS'] ,
-				'nb_mots'=> null,
-				'req_comptage' => "Select count(*) from notices Where (isbn='2-7427-6157-8' or isbn='978-2-7427-6157-9') ",
-				'req_liste' => "select id_notice from notices Where (isbn='2-7427-6157-8' or isbn='978-2-7427-6157-9') ",
-				'req_facettes' => "select id_notice,type_doc,facettes from notices Where (isbn='2-7427-6157-8' or isbn='978-2-7427-6157-9')  limit 15000"
-				],
-	*/	
-			[ [ 'expressionRecherche' => '9782742761579', 'selection_bib'=> 1 ] ,
-				'nb_mots'=> null,
-				'req_comptage' => "Select count(*) from notices Where (isbn='2-7427-6157-8' or isbn='978-2-7427-6157-9')  And MATCH(facettes) AGAINST('+B1' IN BOOLEAN MODE)",
-				'req_liste' => "Select id_notice from notices Where (isbn='2-7427-6157-8' or isbn='978-2-7427-6157-9')  And MATCH(facettes) AGAINST('+B1' IN BOOLEAN MODE)",
-				'req_facettes' => "Select id_notice,type_doc,facettes from notices Where (isbn='2-7427-6157-8' or isbn='978-2-7427-6157-9')  And MATCH(facettes) AGAINST('+B1' IN BOOLEAN MODE) limit 15000"
-				],
 
-			
-			[ ['expressionRecherche' => 'logo',
-			
-				 'annexe' => 'MED1',
+}
+/*
+class MoteurRechercheGuideeTest extends MoteurRechercheAbstractTest {
+	public function setUp() {
+		parent::setUp();
+	}
+
+
+	public function tearDown() {
+		Zend_Registry::set('sql', $this->_original_sql);
+		parent::tearDown();
+	}
+
+
+	public function expectedSql() {
+
+		return 		[
+			[['expressionRecherche' => 'Un titre juste pour l\'historique',
+		'code_rebond'=> 'A774',
+		'rubrique' =>'D6'],
+	 'req_dewey' =>"select libelle from codif_dewey where id_dewey='6'",
+
+			 'req_comptage' =>"select count(*) from notices Where MATCH(facettes) AGAINST('+D6*' IN BOOLEAN MODE)'",
+//		
+			 'req_liste' => "select libelleeee from codif_dewey where id_dewey='6'",
+	
+			 'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(facettes) AGAINST('+A774' IN BOOLEAN MODE) limit 15000"
+					],
+
+		[ ['expressionRecherche' => 'Davodeau',  
+			 'tri' => 'alpha_titres',
+			 'code_rebond' => 'A888',
+			 'rubrique' =>'P4',
+				'geo_zone' => 2] ,
+		 'req_dewey' =>"select count(*) from notices Where MATCH(facettes) AGAINST('+D6*' IN BOOLEAN MODE)'",
+			'req_comptage' => "select libelle from codif_pcdm4 where id_pcdm4='4'",
+			'req_liste' => "select libelle from codif_pcdm4 where id_pcdm4='4'",
+			'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(facettes) AGAINST('+A888 +(B3 B4)' IN BOOLEAN MODE) limit 15000"
+
+			]  ,
+
+			[ ['expressionRecherche' => 'La nouvelle grille',
+				 'code_rebond' => 'A92929',
 				 'facettes' => 'M52291-A15067', 
 				 'selection_annexe' => 'TUN;TAP',
-				 'selection_sections' => '1;12;9'
+				 'selection_sections' => '1;12;9',
+				 'rubrique' =>'X1'
 				 ] ,
-		 'nb_mots'=> 1,
-					'req_comptage' => "Select count(*) from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE)",
-					'req_liste' => "Select id_notice,MATCH(alpha_titre)  AGAINST(' (LOGO LOGOS LOGO)' ) as rel1, MATCH(alpha_auteur) AGAINST(' (LOGO LOGOS LOGO)' ) as rel2 from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE) order by (rel1 * 1.5)+(rel2) desc",
-				  'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+YMED1' IN BOOLEAN MODE) And MATCH(facettes) AGAINST('+M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE) limit 15000"  
+				'req_dewey' =>"select count(*) from notices Where MATCH(facettes) AGAINST('+D6*' IN BOOLEAN MODE)'",
+				'req_comptage' => "Select count(*) from notices Where MATCH(facettes) AGAINST('+A92929 +M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE)",
+				'req_liste' => "Select id_notice from notices Where MATCH(facettes) AGAINST('+A92929 +M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE)",
+				  'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(facettes) AGAINST('+A92929 +M52291 +A15067 +(YTUN YTAP)  +(S1 S12 S9)' IN BOOLEAN MODE) limit 15000"
   
 			
 					]
 
 			];
 	}
-
+*/
 	/** 
 	 * @dataProvider expectedSql
 	 * @test 
 	 */
-	public function lancerRechercheSimpleShouldBe($params, $nb_mots,$req_comptage ,$req_notices ,$req_facettes) {
-				
-				$this->mock_sql
-					->expects($this->once())
-					->method('fetchOne')
-					->with($req_comptage)
-					->will($this->returnValue(10));
-				$profil = Class_Profil::getLoader()->newInstanceWithId(26)
-					->setTypeDoc('1');
-				if (isset($params['selection_annexe']))
-					$profil->setSelAnnexe($params['selection_annexe']);
-				if (isset($params['selection_bib']))
-					$profil->setIdSite($params['selection_bib']);
-				if (isset($params['selection_sections']))
-					$profil->setSelSection($params['selection_sections']);
-				Class_Profil::setCurrentProfil($profil);
-				$this->criteres_recherche->setParams($params);
-				$retour = $this->moteur_recherche->lancerRechercheRebond($this->criteres_recherche);
-				$this->assertEquals(['nombre' => 10,
-														 'nb_mots' => $nb_mots,
-														 'statut' => '',
-														 'req_liste' => $req_notices,
-														 'req_facettes' => $req_facettes],
-														$retour);
+/*	public function lancerRechercheGuideeShouldBe($params, $req_dewey,$req_comptage ,$req_notices ,$req_facettes) {
+
+		$this->mockReqProfilAndZone($req_comptage,$params);			
+
 
+		$profil = Class_Dewey::getLoader()->newInstanceWithId(6)->setLibelle('toto');
+
+	
+		$retour = $this->moteur_recherche->lancerRechercheGuidee($params['rubrique'],';X1',		Class_Profil::getCurrentProfil()->getIdSite());
+	
+		$this->assertEquals(['nombre' => 10,
+												 'nb_mots' => 0,
+												 'statut' => '',
+											
+												 'req_liste' => $req_notices,
+												 'req_facettes' => $req_facettes],
+												$retour);
+		
 	}
 
-}
\ No newline at end of file
+}
+*/
\ No newline at end of file
-- 
GitLab