diff --git a/library/Class/MoteurRecherche.php b/library/Class/MoteurRecherche.php index bae2610eaa38bba8ca9f1af86b7bc750e270e106..a2c339d19626f1917e260a5ccc53ba289dafe446 100644 --- a/library/Class/MoteurRecherche.php +++ b/library/Class/MoteurRecherche.php @@ -609,8 +609,10 @@ class Class_MoteurRecherche { private function addStatEchec($type_recherche,$criteres) { - $criteres = addslashes(serialize($criteres)); - sqlExecute("insert into stats_recherche_echec(type_recherche,criteres) values($type_recherche,'$criteres')"); + (new Class_StatRechercheEchec()) + ->setTypeRecherche($type_recherche) + ->setCriteres(addslashes(serialize($criteres))) + ->save(); } diff --git a/library/Class/StatRechercheEchec.php b/library/Class/StatRechercheEchec.php new file mode 100644 index 0000000000000000000000000000000000000000..cfbf4aa0a3e07fae0cd4113084fbd09e37aaad0d --- /dev/null +++ b/library/Class/StatRechercheEchec.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * 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 + */ + +class Class_StatRechercheEchec extends Storm_Model_Abstract { + protected + $_table_name = 'stats_recherche_echec'; + +} + +?> \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index ca1fb83588bcaa567a2e2d5f9eec00908f602581..dbf08a2fba0553332634659962a52d634b0d1d8c 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -2139,6 +2139,22 @@ class RechercheControllerNavigationTest extends RechercheControllerNoticeTestCas $tarzan = Class_Notice::newInstanceWithId(99, ['clef_alpha'=>'lesarbres']); + + $this->mock_sql = $this->mock() + ->whenCalled('fetchAll') + ->with('select id_notice, facettes from notices order by alpha_titre', true, false) + ->answers([ + [28, ''], + [12, ''], + [345, ''], + [1, ''], + [99, ''] + ] + ) + ->beStrict(); + + Zend_Registry::set('sql', $this->mock_sql); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice') ->whenCalled('getNoticeIdsByRequeteRecherche') ->with('Select id_notice from notices order by alpha_titre') @@ -2188,10 +2204,12 @@ class RechercheControllerNavigationTest extends RechercheControllerNoticeTestCas /** @test */ public function navigationSuivantOnNoticeLesarbresWhenResultatRechercheIsEmptyShouldRedirectToCurrentNoticeLsearbres() { - Class_Notice::whenCalled('getNoticeIdsByRequeteRecherche') - ->with('Select id_notice from notices order by alpha_titre') + $this->mock_sql + ->whenCalled('fetchAll') + ->with('select id_notice, facettes from notices order by alpha_titre', true, false) ->answers([]); + $this->dispatch('/recherche/viewnotice/id/99/tri/alpha_titre/navigation/suivant',true); $this->assertRedirectRegex('|/recherche/viewnotice/id/99/tri/alpha_titre/clef/lesarbres|'); } @@ -2199,9 +2217,10 @@ class RechercheControllerNavigationTest extends RechercheControllerNoticeTestCas /** @test */ public function navigationSuivantOnNoticeLesarbresWhenResultatRechercheAsMussoResultShouldRedirectToCurrentNoticeMusso() { - Class_Notice::whenCalled('getNoticeIdsByRequeteRecherche') - ->with('Select id_notice from notices order by alpha_titre') - ->answers([28]); + $this->mock_sql + ->whenCalled('fetchAll') + ->with('select id_notice, facettes from notices order by alpha_titre', true, false) + ->answers([ [28, '' ] ]); $this->dispatch('/recherche/viewnotice/id/28/tri/alpha_titre/navigation/suivant',true); $this->assertRedirectRegex('|/recherche/viewnotice/id/28/tri/alpha_titre/clef/musso|');