Skip to content
Snippets Groups Projects
Commit 81c662ad authored by Henri-Damien LAURENT's avatar Henri-Damien LAURENT
Browse files

Merge branch 'hotline#180221_pb_regroupement_oeuvre' into 'master'

Hotline#180221 pb regroupement oeuvre

See merge request !4745
parents 5b1e3b78 a3fa3ab2
Branches
Tags
1 merge request!4745Hotline#180221 pb regroupement oeuvre
Pipeline #23629 passed with stage
in 25 minutes and 53 seconds
- ticket#180221 : Résultat de recherche : Problème de typage résolu quand on fait un regroupement par oeuvre combiné à une surbrilance des termes recherchés.
\ No newline at end of file
...@@ -321,6 +321,12 @@ class Class_MoteurRecherche_ResultWork extends Class_MoteurRecherche_Result { ...@@ -321,6 +321,12 @@ class Class_MoteurRecherche_ResultWork extends Class_MoteurRecherche_Result {
} }
public function getRecords() : array {
return array_map(fn($notice_work)=> $notice_work->getRecord(),
$this->_records);
}
public function fetchRecords() { public function fetchRecords() {
if (!$this->_records_query || $this->_records) if (!$this->_records_query || $this->_records)
return $this->_records; return $this->_records;
......
<?php
/**
* Copyright (c) 2012-2022, 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
*/
trait Trait_DecorateLabelCallback {
protected
$_decorate_label_callback;
public function setDecorateLabelCallback(Closure $callback) : self {
$this->_decorate_label_callback = $callback;
return $this;
}
}
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
class Intonation_Library_View_Wrapper_Record class Intonation_Library_View_Wrapper_Record
extends Intonation_Library_View_Wrapper_Abstract { extends Intonation_Library_View_Wrapper_Abstract {
use Trait_DecorateLabelCallback;
protected protected
$_picture_cache, $_picture_cache,
$_selectable_action = false, $_selectable_action = false,
...@@ -30,8 +32,7 @@ class Intonation_Library_View_Wrapper_Record ...@@ -30,8 +32,7 @@ class Intonation_Library_View_Wrapper_Record
$_secondary_title_cache, $_secondary_title_cache,
$_description, $_description,
$_badges, $_badges,
$_allow_XSL = false, $_allow_XSL = false;
$_decorate_label_callback;
public function getMainTitle() : string { public function getMainTitle() : string {
...@@ -781,12 +782,6 @@ class Intonation_Library_View_Wrapper_Record ...@@ -781,12 +782,6 @@ class Intonation_Library_View_Wrapper_Record
public function getTimelineEventsDates() : Intonation_Library_TimelineEventsDates { public function getTimelineEventsDates() : Intonation_Library_TimelineEventsDates {
return new Intonation_Library_TimelineEventsDates((string) $this->_model->getAnnee()); return new Intonation_Library_TimelineEventsDates((string) $this->_model->getAnnee());
} }
public function setDecorateLabelCallback(Closure $callback) : self {
$this->_decorate_label_callback = $callback;
return $this;
}
} }
......
...@@ -20,7 +20,11 @@ ...@@ -20,7 +20,11 @@
*/ */
class Intonation_Library_View_Wrapper_Work extends Intonation_Library_View_Wrapper_Abstract { class Intonation_Library_View_Wrapper_Work
extends Intonation_Library_View_Wrapper_Abstract {
use Trait_DecorateLabelCallback;
protected $_record_wrapper; protected $_record_wrapper;
protected function _getRecordWrapper() { protected function _getRecordWrapper() {
......
...@@ -241,6 +241,7 @@ abstract class SearchResultByWorkWithTemplatingWorkTestCase extends SearchResult ...@@ -241,6 +241,7 @@ abstract class SearchResultByWorkWithTemplatingWorkTestCase extends SearchResult
class SearchResultByWorkWithTemplatingWorkAccrocDuRocTest class SearchResultByWorkWithTemplatingWorkAccrocDuRocTest
extends SearchResultByWorkWithTemplatingWorkTestCase { extends SearchResultByWorkWithTemplatingWorkTestCase {
...@@ -516,3 +517,102 @@ class SearchResultByWorkViewWithoutCriteriaTest extends SearchResultByWorkTestCa ...@@ -516,3 +517,102 @@ class SearchResultByWorkViewWithoutCriteriaTest extends SearchResultByWorkTestCa
$this->assertNotXpathContentContains('//span[contains(@class, "btn")]', '1 / 1'); $this->assertNotXpathContentContains('//span[contains(@class, "btn")]', '1 / 1');
} }
} }
/* @see https://forge.afi-sa.net/issues/180221 */
class SearchResultByWorkForLapinWithHighlightedTermTest
extends SearchResultByWorkTestCase {
public function setUp() {
parent::setUp();
$unimarc = (new Class_NoticeUnimarc_Fluent)
->zoneWithContent('001', '12345')
->zoneWithChildren('200', ['a' => 'Accroc du roc'])
->zoneWithChildren('330', ['a' => 'Kreskenn, jeune barde, quitte Ker-Gselzehc pour Ankh-Morpork où il espère devenir un grand musicien.'])
->zoneWithChildren('700', ['a' => 'Pratchett', 'b' => 'Terry'])
;
$this->fixture(Class_Notice::class,
['id' => 1,
'type_doc' => Class_TypeDoc::LIVRE,
'clef_oeuvre' => 'ACCROCDUROC-PRATCHETTT',
'unimarc' => $unimarc->render()]);
$this->fixture(Class_Exemplaire::class,
['id' => 1,
'id_notice' => 1,
'id_bib' => 1]);
$unimarc = (new Class_NoticeUnimarc_Fluent)
->zoneWithContent('001', '987654')
->zoneWithChildren('200', ['a' => 'Le conte de Jeannot Lapin'])
->zoneWithChildren('330', ['a' => 'L\'histoire de Jeannot Lapin.'])
->zoneWithChildren('700', ['a' => 'Potter', 'b' => 'Beatrix'])
;
$this->fixture(Class_Notice::class,
['id' => 4,
'type_doc' => Class_TypeDoc::LIVRE,
'clef_oeuvre' => 'LECONTEDEJEANNOTLAPIN-POTTERBEATRIX',
'unimarc' => $unimarc->render()]);
$this->fixture(Class_Exemplaire::class,
['id' => 4,
'id_notice' => 4,
'id_bib' => 1]);
Zend_Registry::set('sql', $this->mock()
->whenCalled('fetchOne')
->with('select count(*) from stats_notices where annee=2020 and mois=10')
->answers(1)
->whenCalled('execute')
->with('update stats_notices set nb_visu = nb_visu + 1 where annee=2020 and mois=10')
->answers(1)
->whenCalled('fetchAll')
->with("select id_notice, facettes, clef_oeuvre from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(LAPIN LAPINS)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_LAPIN') desc, MATCH(titres) AGAINST('P_LAPIN') desc, MATCH(titres) AGAINST('LAPIN') desc, MATCH(auteurs) AGAINST('LAPIN') desc, date_creation desc",
true,
false)
->answers([[1, 'T1', 'ACCROCDUROC-PRATCHETTT'],
[2, 'T2', 'ACCROCDUROC-PRATCHETTT'],
[4, 'T1', 'LECONTEDEJEANNOTLAPIN-POTTERBEATRIX']])
);
$this->_buildTemplateProfil(['id' => 1]);
(new Class_Profil_Preferences())
->setModulePref(Class_Profil::find(1),
(new Class_Profil_ModuleDefinition('recherche',
'resultat',
'simple')),
['highlight_search_terms' => '1']);
$this->dispatch('/opac/recherche/simple/by_work/1/tri/*/expressionRecherche/lapin');
}
/** @test */
public function liResultCountShouldContains2Documents() {
$this->assertXPathContentContains('//li[contains(@class,"result_count")]', '2 documents');
}
/** @test */
public function oneDivCardTitleShouldContainsAccrocDuRoc() {
$this->assertXPathContentContains('//div[contains(@class,"card-title")]', 'Accroc du roc');
}
/** @test */
public function oneDivCardTitleShouldContainsConteDeJeannotLapin() {
$this->assertXPathContentContains('//div[contains(@class,"card-title")]', 'Le conte de Jeannot Lapin');
}
/** @test */
public function resultsShouldContainsLapinWithHighlightClass() {
$this->assertXPathContentContains('//div//span[@class="highlight font-weight-bold text_decoration_underline"]', 'Lapin');
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment