From 09c3abb895b7dc42ab27620fb801981e8c31565a Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@afi-sa.fr> Date: Sat, 3 Oct 2015 18:03:02 +0200 Subject: [PATCH] dev #29558 improve search performances fix tests --- .../RechercheControllerAtomTest.php | 36 +++++++++++-------- .../RechercheControllerJsonTest.php | 32 ++++++++--------- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php b/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php index 0bac0d26fc4..e16a1bb0c3c 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php @@ -77,16 +77,26 @@ abstract class RechercheControllerAtomTestCase extends AbstractControllerTestCas class RechercheControllerAtomEmptyTestCase extends RechercheControllerAtomTestCase { protected function _prepareLoader($loader) { - $loader->whenCalled('findAllByRequeteRecherche')->answers([]); + $loader->whenCalled('findAllByIds') + ->with([], 5, null) + ->answers([]) + ->beStrict(); } protected function _prepareSql($sql) { - $sql->whenCalled('fetchOne') - ->answers(0) + $sql->whenCalled('fetchAll') + ->with("select id_notice, facettes from notices Where MATCH(titres, auteurs, editeur, collection, matieres, dewey) AGAINST('+(HARRY HARRYS ARI) +(POTTER POTTERS POT)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+S1 +G123' IN BOOLEAN MODE) order by (MATCH(alpha_titre) AGAINST(' HARRY POTTER') * 1.5) + (MATCH(alpha_auteur) AGAINST(' HARRY POTTER')) desc", + true, + false) + ->answers([]) - ->whenCalled('execute') - ->answers(true); + ->whenCalled('fetchAll') + ->with("select id_notice, facettes from notices Where MATCH(titres, auteurs, editeur, collection, matieres, dewey) AGAINST(' (HARRY HARRYS ARI) (POTTER POTTERS POT)') and MATCH(facettes) AGAINST('+S1 +G123' IN BOOLEAN MODE) order by (MATCH(alpha_titre) AGAINST(' HARRY POTTER') * 1.5) + (MATCH(alpha_auteur) AGAINST(' HARRY POTTER')) desc", + true, + false) + ->answers([]) + ->beStrict(); } @@ -142,20 +152,18 @@ abstract class RechercheControllerAtomWithTwoNoticesTestCase extends RechercheCo 'url_image' => 'http://media.universcine.com/e7/bc/e7bcedba-743a-11e2-a43d-fb3bf58b5f60.png']); - $loader->whenCalled('findAllByRequeteRecherche') + $loader->whenCalled('findAllByIds') + ->with([234, 10141532]) ->answers([$potter, $rdv]); } protected function _prepareSql($sql) { - $sql->whenCalled('fetchOne') - ->answers(2) - - ->whenCalled('execute') - ->answers(true) - - ->whenCalled('fetchAllByColumn') - ->answers([234, 10141532]); + $sql->whenCalled('fetchAll') + ->answers([ + [234, ''], + [10141532, ''] + ]); } } diff --git a/tests/application/modules/opac/controllers/RechercheControllerJsonTest.php b/tests/application/modules/opac/controllers/RechercheControllerJsonTest.php index 9affa42b785..7b7f686bc74 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerJsonTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerJsonTest.php @@ -20,8 +20,9 @@ */ abstract class RechercheControllerJsonTestCase extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - protected $_json; + protected + $_storm_default_to_volatile = true, + $_json; public function setUp() { parent::setUp(); @@ -55,21 +56,17 @@ abstract class RechercheControllerJsonTestCase extends AbstractControllerTestCas class RechercheControllerJsonEmptyResultTest extends RechercheControllerJsonTestCase { protected function _prepareLoader($loader) { - $loader->whenCalled('findAllByRequeteRecherche') - ->with('Select id_notice from notices', 10, null) + $loader->whenCalled('findAllByIds') + ->with([], 10, null) ->answers([]) ->beStrict(); } protected function _prepareSql($sql) { - $sql->whenCalled('fetchOne') - ->with('Select count(*) from notices') - ->answers(0) - - ->whenCalled('execute') - ->answers(true) - ; + $sql->whenCalled('fetchAll') + ->with('select id_notice, facettes from notices', true, false) + ->answers([]); } @@ -134,17 +131,20 @@ class RechercheControllerJsonWithResultTest extends RechercheControllerJsonTestC 'url_image' => 'http://media.universcine.com/e7/bc/e7bcedba-743a-11e2-a43d-fb3bf58b5f60.png']); - $loader->whenCalled('findAllByRequeteRecherche') - ->with('Select id_notice from notices', 5, null) + $loader->whenCalled('findAllByIds') + ->with([234, 10141532], 5, null) ->answers([$potter, $rdv]) ->beStrict(); } protected function _prepareSql($sql) { - $sql->whenCalled('fetchOne') - ->with('Select count(*) from notices') - ->answers(2) + $sql->whenCalled('fetchAll') + ->with('select id_notice, facettes from notices', true, false) + ->answers([ + ['234', ''], + ['10141532', ''] + ]) ->whenCalled('execute') ->answers(true) -- GitLab