From e7bd27802656dc20464d6aaa37e7026e9daa5542 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@afi-sa.fr> Date: Mon, 5 Oct 2015 11:24:20 +0200 Subject: [PATCH] dev #29558 improve search performances test fix --- library/Class/MoteurRecherche/Result.php | 1 - .../RechercheControllerPrintActionTest.php | 10 ++--- .../controllers/RechercheControllerTest.php | 40 ++++++++++++------- .../View/Helper/Notice/NavigationTest.php | 20 ++++++++-- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/library/Class/MoteurRecherche/Result.php b/library/Class/MoteurRecherche/Result.php index 76ef81a73fe..1f69072c35f 100644 --- a/library/Class/MoteurRecherche/Result.php +++ b/library/Class/MoteurRecherche/Result.php @@ -58,7 +58,6 @@ class Class_MoteurRecherche_Result { public function fetchFacetsAndTags($preferences) { $search_facets = new Class_MoteurRecherche_Facettes(); - return isset($this->_facets) ? $search_facets->buildFacetsData($preferences, $search_facets->fetchFacetsRows($this->_facets), diff --git a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php index d031b70f434..8fe479988c7 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php @@ -37,13 +37,13 @@ class RechercheControllerPrintActionLinkTest extends AbstractControllerTestCase 'auteur' => 'Paul']); $mock_sql = $this->mock() - ->whenCalled('fetchAllByColumn') - ->answers([1]) - ->whenCalled('fetchOne') - ->answers(1) + ->whenCalled('fetchAll') + ->with("select id_notice, facettes from notices Where MATCH(facettes) AGAINST('+(APaul)' IN BOOLEAN MODE) order by annee desc", true, false) + ->answers([ [1, ''] ]) ->whenCalled('fetchAll') ->answers([$this->fixture('Class_Notice', - ['id' => 1])->toArray()]); + ['id' => 1])->toArray()]) + ->beStrict(); Zend_Registry::set('sql', $mock_sql); $this->dispatch('/recherche/simple/id_catalogue/3/id_module/9/aleatoire/1', true); } diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index dbf08a2fba0..4a6cb51b04f 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -1777,13 +1777,22 @@ abstract class RechercheControllerSearchResultGuideeFixtures extends AbstractCon ->willDo( function($criteres) { return (new Class_MoteurRecherche_Result($this->mock_moteur_recherche, $criteres)) - ->setRecordsQuery('select') - ->setFacetsQuery('select'); + ->setRecordsQuery('mock select query') + ->setFacetsQuery('mock select query'); }); Class_Codification::setInstance($this->mock_codif); Class_MoteurRecherche::setInstance($this->mock_moteur_recherche); $this->mock_sql + ->whenCalled('fetchAllByColumn') + ->with('mock select query') + ->answers([ 'D3', 'M1355']) + + + ->whenCalled('fetchAll') + ->with('mock select query', true, false) + ->answers([ 'D3', 'M1355']) + ->whenCalled('fetchOne') ->with('select libelle from codif_dewey where id_dewey=\'66\'') ->answers( 'Generalites')->beStrict(); @@ -1810,7 +1819,8 @@ class RechercheControllerGuideeWithFiltersSelectedTest extends RechercheControll /** @test */ public function facettesShouldBeRemovedInRetirerUrl() { - $this->assertXPathContentContains("//a[contains(@href,'recherche/simple/rubrique/D66')]", "suppression",$this->_response->getBody()); + $this->assertXPathContentContains("//a[contains(@href,'recherche/simple/rubrique/D66')]", + "suppression",$this->_response->getBody()); } } @@ -1835,12 +1845,8 @@ class RechercheControllerWithPanierTest extends RechercheControllerNoticeTestCas $mock_sql = Storm_Test_ObjectWrapper::mock(); Zend_Registry::set('sql', $mock_sql); $mock_sql - ->whenCalled('fetchOne') - ->with("Select count(*) from notices Where notices.clef_alpha in('COMBAT ORDINAIRE', 'BLACKSAD')") - ->answers(2) - ->whenCalled('fetchAll') - ->with("Select id_notice, facettes from notices Where notices.clef_alpha in('COMBAT ORDINAIRE', 'BLACKSAD')", true, false) + ->with("select id_notice, facettes from notices Where notices.clef_alpha in('COMBAT ORDINAIRE', 'BLACKSAD')", true, false) ->answers([ [1, ''], @@ -2753,13 +2759,14 @@ class RechercheControlleSimpleActionWithEmptyDomainSettingsAndSiteLinkedTest ext Class_Sitotheque::find(1)->index(); $mock_sql = $this->mock() - ->whenCalled('fetchAllByColumn') - ->with("Select id_notice from notices Where MATCH(facettes) AGAINST('Q3' IN BOOLEAN MODE) order by annee desc") - ->answers([1]) + ->whenCalled('fetchAll') + ->with("select id_notice, facettes from notices Where MATCH(facettes) AGAINST('Q3' IN BOOLEAN MODE) order by annee desc", true, false) + ->answers([ [1, ''] ]) ->whenCalled('fetchOne') ->answers(1) ->whenCalled('fetchAll') - ->answers([Class_Notice::find(1)->toArray()]); + ->answers([Class_Notice::find(1)->toArray()]) + ->beStrict(); Zend_Registry::set('sql', $mock_sql); Class_Profil::getCurrentProfil() @@ -2813,12 +2820,15 @@ class RechercheControlleSimpleActionWithEmptyDomainSettingsAndArticlesLinkedTest Class_Article::find(1)->index(); $mock_sql = $this->mock() - ->whenCalled('fetchAllByColumn') - ->answers([1]) + ->whenCalled('fetchAll') + ->with("select id_notice, facettes from notices Where MATCH(facettes) AGAINST('Q3' IN BOOLEAN MODE) order by annee desc", true, false) + ->answers([ [1, ''] ]) + ->whenCalled('fetchOne') ->answers(1) ->whenCalled('fetchAll') - ->answers([Class_Notice::find(1)->toArray()]); + ->answers([Class_Notice::find(1)->toArray()]) + ->beStrict(); Zend_Registry::set('sql', $mock_sql); Class_Profil::getCurrentProfil() diff --git a/tests/library/ZendAfi/View/Helper/Notice/NavigationTest.php b/tests/library/ZendAfi/View/Helper/Notice/NavigationTest.php index 032a3d0dada..2abfc2d29f2 100644 --- a/tests/library/ZendAfi/View/Helper/Notice/NavigationTest.php +++ b/tests/library/ZendAfi/View/Helper/Notice/NavigationTest.php @@ -29,16 +29,28 @@ abstract class ZendAfi_View_Helper_Notice_NavigationTestCase extends ViewHelperT $this->_helper = new ZendAfi_View_Helper_Notice_Navigation(); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice') - ->whenCalled('getNoticeIdsByRequeteRecherche') - ->answers([10,99,88,1,2,34,4]); + + $mock_sql = $this->mock() + ->whenCalled('fetchAll') + ->with("select id_notice, facettes from notices", true, null) + ->answers([ + [10, ''], + [99, ''], + [88, ''], + [1, ''], + [2, ''], + [34,''], + [4, ''] + ]) + ->beStrict(); + Zend_Registry::set('sql', $mock_sql); $mock_moteur = Storm_Test_ObjectWrapper::mock(); $mock_moteur ->whenCalled('lancerRecherche') ->answers((new Class_MoteurRecherche_Result($mock_moteur, new Class_CriteresRecherche())) - ->setRecordsQuery('select * from notices')); + ->setRecordsQuery('select id_notice, facettes from notices')); $this->notice_navigation = new Class_Notice_NavigationRecherche(new Class_CriteresRecherche(), $mock_moteur, -- GitLab