From e26694cf4ca02bd299d6bf2c88503a6877fcfd82 Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@git-test.afi-sa.fr>
Date: Wed, 3 Apr 2013 17:43:22 +0000
Subject: [PATCH] Refacto recheche guidee (en cours de dev)

---
 .../admin/controllers/UsersController.php     |  1 -
 .../opac/controllers/RechercheController.php  |  2 +-
 library/Class/Dewey.php                       | 10 ++++-
 .../View/Helper/TagCriteresRecherche.php      |  1 -
 tests/library/Class/MoteurRechercheTest.php   | 38 ++++++++++---------
 5 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/application/modules/admin/controllers/UsersController.php b/application/modules/admin/controllers/UsersController.php
index 81b32b54825..38200d2ea8f 100644
--- a/application/modules/admin/controllers/UsersController.php
+++ b/application/modules/admin/controllers/UsersController.php
@@ -145,7 +145,6 @@ class Admin_UsersController extends Zend_Controller_Action
 				else
 					$this->view->erreurs = implode(BR, $user->getErrors());
 			} catch (Exception $e) {
-				xdebug_break();
 				$this->view->erreurs = $e->getMessage();
 			}
 		}
diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php
index 91dcd0ff4ae..076f13ac47a 100644
--- a/application/modules/opac/controllers/RechercheController.php
+++ b/application/modules/opac/controllers/RechercheController.php
@@ -367,7 +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
diff --git a/library/Class/Dewey.php b/library/Class/Dewey.php
index 29c77ca8ede..716677f61f9 100644
--- a/library/Class/Dewey.php
+++ b/library/Class/Dewey.php
@@ -22,9 +22,10 @@
 // OPAC 3 :INDICES DEWEY
 ///////////////////////////////////////////////////////////////////////////////////////
 
-class Class_Dewey extends Storm_Model_Loader
+class Class_Dewey extends Storm_Model_Abstract
 {
 
+	static $_libelle;
 // ----------------------------------------------------------------
 // Rend une liste pour un champ suggestion
 // ----------------------------------------------------------------
@@ -97,10 +98,17 @@ class Class_Dewey extends Storm_Model_Loader
 		}
 		return $new;
 	}
+	
+	static  function setLibelle($libelle) {
+		Class_Dewey::$_libelle=$libelle; 
+	}
 // ----------------------------------------------------------------
 // Rend le libelle ou le code si le libelle est vide
 // ----------------------------------------------------------------
 	static function getLibelle($indice)	{
+
+		if (Class_Dewey::$_libelle)
+			return Class_Dewey::$_libelle;
 		$libelle = Zend_Registry::get('sql')->fetchOne("select libelle from codif_dewey where id_dewey='$indice'");
 		if(!$libelle) $libelle=Class_Dewey::formatIndice($indice);
 		return $libelle;
diff --git a/library/ZendAfi/View/Helper/TagCriteresRecherche.php b/library/ZendAfi/View/Helper/TagCriteresRecherche.php
index bed2b831117..85a5b0c1244 100644
--- a/library/ZendAfi/View/Helper/TagCriteresRecherche.php
+++ b/library/ZendAfi/View/Helper/TagCriteresRecherche.php
@@ -85,7 +85,6 @@ class ZendAfi_View_Helper_TagCriteresRecherche extends Zend_View_Helper_HtmlElem
 
 
 	public function visitFacette($facette) {
-		xdebug_break();
 		$libelle = Class_Codification::getNomFacette($facette).': '.Class_Codification::getLibelleFacette($facette);
 		$facettes = array_diff($this->_current_facettes, [$facette] );
 		$url=$this->_criteres_recherche->getUrlRetourListe();
diff --git a/tests/library/Class/MoteurRechercheTest.php b/tests/library/Class/MoteurRechercheTest.php
index 46ca2a2e073..7639dfd88cc 100644
--- a/tests/library/Class/MoteurRechercheTest.php
+++ b/tests/library/Class/MoteurRechercheTest.php
@@ -45,7 +45,7 @@ abstract class MoteurRechercheAbstractTest extends Storm_Test_ModelTestCase {
 
 	public function mockReqProfilAndZone($req_comptage,$params) {
 		$this->mock_sql
-			->expects($this->once())
+			->expects($this->any())
 			->method('fetchOne')
 			->with($req_comptage)
 			->will($this->returnValue(10));
@@ -367,7 +367,7 @@ class MoteurRechercheRebondTest extends MoteurRechercheAbstractTest {
 		$this->assertEquals(['nombre' => 10,
 												 'nb_mots' => 0,
 												 'statut' => '',
-											
+												 'req_comptage' => $req_comptage,
 												 'req_liste' => $req_notices,
 												 'req_facettes' => $req_facettes],
 												$retour);
@@ -376,7 +376,7 @@ class MoteurRechercheRebondTest extends MoteurRechercheAbstractTest {
 
 
 }
-/*
+
 class MoteurRechercheGuideeTest extends MoteurRechercheAbstractTest {
 	public function setUp() {
 		parent::setUp();
@@ -395,13 +395,14 @@ class MoteurRechercheGuideeTest extends MoteurRechercheAbstractTest {
 			[['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_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_liste' => "select id_notice from notices Where MATCH(facettes) AGAINST('+D6*' IN BOOLEAN MODE) order by alpha_titre",
 	
-			 'req_facettes' => "Select id_notice,type_doc,facettes from notices Where MATCH(facettes) AGAINST('+A774' IN BOOLEAN MODE) limit 15000"
+			 'req_facettes' => "select id_notice,type_doc,facettes from notices Where MATCH(facettes) AGAINST('+D6*' IN BOOLEAN MODE)"
 					],
 
 		[ ['expressionRecherche' => 'Davodeau',  
@@ -409,7 +410,7 @@ class MoteurRechercheGuideeTest extends MoteurRechercheAbstractTest {
 			 '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"
@@ -423,7 +424,7 @@ class MoteurRechercheGuideeTest extends MoteurRechercheAbstractTest {
 				 'selection_sections' => '1;12;9',
 				 'rubrique' =>'X1'
 				 ] ,
-				'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"
@@ -433,30 +434,33 @@ class MoteurRechercheGuideeTest extends MoteurRechercheAbstractTest {
 
 			];
 	}
-*/
+
 	/** 
 	 * @dataProvider expectedSql
 	 * @test 
 	 */
-/*	public function lancerRechercheGuideeShouldBe($params, $req_dewey,$req_comptage ,$req_notices ,$req_facettes) {
-
+	public function lancerRechercheGuideeShouldBe($params, $req_comptage ,$req_notices ,$req_facettes) {
+//		$deway = Class_Dewey::getLoader()->newInstanceWithId('6')->setLibelle('toto');
+		Class_Dewey::setLibelle('dewey');
+		
 		$this->mockReqProfilAndZone($req_comptage,$params);			
 
 
-		$profil = Class_Dewey::getLoader()->newInstanceWithId(6)->setLibelle('toto');
-
 	
+
+			
+
+//		$this->criteres_recherche->setParams($params);
 		$retour = $this->moteur_recherche->lancerRechercheGuidee($params['rubrique'],';X1',		Class_Profil::getCurrentProfil()->getIdSite());
 	
 		$this->assertEquals(['nombre' => 10,
 												 'nb_mots' => 0,
 												 'statut' => '',
-											
+												 'fil_ariane' => [],
 												 'req_liste' => $req_notices,
 												 'req_facettes' => $req_facettes],
 												$retour);
 		
 	}
 
-}
-*/
\ No newline at end of file
+}
\ No newline at end of file
-- 
GitLab