diff --git a/VERSIONS_HOTLINE/158802 b/VERSIONS_HOTLINE/158802 new file mode 100644 index 0000000000000000000000000000000000000000..6e3a5d2c7fd381a97967e3415a2dd0ae1cf62a3d --- /dev/null +++ b/VERSIONS_HOTLINE/158802 @@ -0,0 +1,2 @@ + - correctif #158802 : Recherche : amélioration de la performance des recherches avec un domaine lié. + Magasin de thèmes: ajout d'un nouveau paramètre dans les boites de type carrousel pour désynchroniser l'affichage du contenu de celle-ci de l'affichage de la page. \ No newline at end of file diff --git a/application/modules/opac/controllers/WidgetController.php b/application/modules/opac/controllers/WidgetController.php index cd714067cddd5b599fc06aa34ecdd0d4f1d99f14..12806dfae70e5362c3b008ecc479317a6609ca15 100644 --- a/application/modules/opac/controllers/WidgetController.php +++ b/application/modules/opac/controllers/WidgetController.php @@ -21,6 +21,7 @@ class WidgetController extends ZendAfi_Controller_Action { + public function renderAction() { $callback = function() { @@ -32,11 +33,17 @@ class WidgetController extends ZendAfi_Controller_Action { Class_Template::setCurrentFrom($profile_id); - if ($widget = $this->_findWidgetBy($id, $profile_id)) - return Class_Template::current()->renderWidget($widget, $this->view); + if ( ! $widget = $this->_findWidgetBy($id, $profile_id)) + return ''; + + return ('body' === $this->_getParam('only', '') + ? Class_Template::current()->renderWidgetBody($widget, $this->view) + : Class_Template::current()->renderWidget($widget, $this->view)); }; - return $this->_helper->iframe($callback); + return ('ajax' == $this->_request->getParam('render')) + ? $this->_helper->ajax($callback) + : $this->_helper->iframe($callback); } diff --git a/library/Class/MoteurRecherche.php b/library/Class/MoteurRecherche.php index 81905415ea3f0305892179a36ba33a2391f7d42b..58019304ea2d215835ee7f00303ffa828ba30066 100644 --- a/library/Class/MoteurRecherche.php +++ b/library/Class/MoteurRecherche.php @@ -262,7 +262,18 @@ class Class_MoteurRecherche { public function visitFiltre($filtre) { - $this->all_facettes .= ' +(' . implode(' ', $filtre) . ') '; + $this->all_facettes .= $this->_optimizedFacetsForMatchAgaints($filtre); + } + + + protected function _optimizedFacetsForMatchAgaints(array $facets) : string { + if ( ! $facets) + return ''; + + return sprintf(' +%s ', + (1 === count($facets) + ? reset($facets) + : '(' . implode(' ', $facets) . ')')); } @@ -506,7 +517,7 @@ class Class_MoteurRecherche { protected function injectMultiFacets() { foreach($this->multi_facets as $facets) - $this->all_facettes .= ' +(' . implode(' ', $facets) . ')'; + $this->all_facettes .= $this->_optimizedFacetsForMatchAgaints($facets); } diff --git a/library/Class/Systeme/Widget/Abstract.php b/library/Class/Systeme/Widget/Abstract.php index 0b9c709b9cc41df6cda60c49d9552d48680f20b5..c3060e850edc373326473524ae797fa5f3069ae4 100644 --- a/library/Class/Systeme/Widget/Abstract.php +++ b/library/Class/Systeme/Widget/Abstract.php @@ -547,4 +547,14 @@ abstract class Class_Systeme_Widget_Abstract extends Class_Entity { ? $id : $parent_id . '_' . $id; } + + + public function setShouldRender(bool $value) : self { + return $this->set('should_render', $value); + } + + + public function getShouldRender() : bool { + return (bool) $this->get('should_render'); + } } diff --git a/library/ZendAfi/Form.php b/library/ZendAfi/Form.php index 6cff846147c8cdf09e8d7e1c1e31ef88af8f39da..f235748265df79445627ec6a5009a00ab2efb1d4 100644 --- a/library/ZendAfi/Form.php +++ b/library/ZendAfi/Form.php @@ -257,6 +257,18 @@ class ZendAfi_Form extends Zend_Form { } + public function addToTemplateGroup(array $elements) : self { + $key = Class_Template::current()->withNameSpace('group'); + + return ($group = $this->getDisplayGroup($key)) + ? $this->addToDisplayGroup($elements, $key) + : $this->addDisplayGroup($elements, + $key, + ['legend' => $this->_('Thème'), + 'order' => Intonation_Library_FormCustomizer_Abstract::FIRST]); + } + + public function addToDisplaySettingsGroup($elements) { $key = 'display_settings_group'; if($group = $this->getDisplayGroup($key)) diff --git a/library/ZendAfi/View/Helper/Template/Base.php b/library/ZendAfi/View/Helper/Template/Base.php index 660e0ea7ee805c311e94eda7bd6e441de377ec40..ecde4237457a6e245f52b7b737fa9e51376d951a 100644 --- a/library/ZendAfi/View/Helper/Template/Base.php +++ b/library/ZendAfi/View/Helper/Template/Base.php @@ -89,6 +89,13 @@ class ZendAfi_View_Helper_Template_Base extends ZendAfi_View_Helper_BaseHelper { } + public function getBodyHtml() : string { + return $this->_view_helper + ->setTemplateContext($this) + ->getBodyHtml(); + } + + protected function _initLegacyHtml() { $this->_view_helper ->setTemplateContext($this) @@ -139,6 +146,11 @@ class ZendAfi_View_Helper_Template_Base extends ZendAfi_View_Helper_BaseHelper { } + public function shouldRender() : bool { + return $this->_widget->getShouldRender(); + } + + protected function _visibleWhenHidden() { return $this->_view_helper->visibleWhenHidden(); } diff --git a/library/ZendAfi/View/Helper/Template/LoadingIcon.php b/library/ZendAfi/View/Helper/Template/LoadingIcon.php index e9be8d7f14605624f50c9bee57ecfd35e913519c..677f7b424332563268e1768e1e26cdccc0cd0a97 100644 --- a/library/ZendAfi/View/Helper/Template/LoadingIcon.php +++ b/library/ZendAfi/View/Helper/Template/LoadingIcon.php @@ -22,7 +22,7 @@ class ZendAfi_View_Helper_Template_LoadingIcon extends ZendAfi_View_Helper_BaseHelper { public function loadingIcon() : string { - return $this->_div(['class' => 'col-12 text-center'], + return $this->_div(['class' => 'col-12 text-center loading_icon_wrapper'], $this->_div(['class' => 'loading_icon'], $this->view->screenReaderOnly($this->_('Merci de patientier...')))); } diff --git a/library/templates/Intonation/Library/Widget/Carousel/Form.php b/library/templates/Intonation/Library/Widget/Carousel/Form.php index 5ab95bca0d3fc0a65a3b4b80c85fd0b45a828b5d..d92f3f9023c90b0fcacc04975b8e857a160e776d 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Form.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Form.php @@ -133,7 +133,11 @@ class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Configuration 'value' => 0, 'min' => 0, 'max' => 60]) - ; + + ->addExpertElement('checkbox', + 'delayed', + ['label' => $this->_('Affichage du contenu désynchronisé'), + 'value' => 0]); } @@ -141,7 +145,6 @@ class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Configuration parent::initDisplayGroups(); $this - ->addToSelectionGroup(['data_sources']) ->addToDisplaySettingsGroup(['layout', @@ -162,7 +165,7 @@ class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Configuration ->addToDisplayGroup(['description_length', 'description_html'], Class_Template::current()->withNameSpace('group')) - ; + ->addToTemplateGroup(['delayed']); return $this; } diff --git a/library/templates/Intonation/Library/Widget/Carousel/Record/View.php b/library/templates/Intonation/Library/Widget/Carousel/Record/View.php index 24e97c6dfbccb4a079d2b041add891b02a669177..6daed8f3329338a74c2811e1afc19cce0ddb592b 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Record/View.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Record/View.php @@ -24,6 +24,7 @@ class Intonation_Library_Widget_Carousel_Record_View extends Intonation_Library_ protected static $_storm_limit = 100; + protected function _findElements() { $order = $this->_settings->getOrder(); @@ -146,6 +147,6 @@ class Intonation_Library_Widget_Carousel_Record_View extends Intonation_Library_ protected function _getSize() { return ($size = $this->_settings->getSize()) ? $size - : 100; + : static::$_storm_limit; } } diff --git a/library/templates/Intonation/Library/Widget/Carousel/View.php b/library/templates/Intonation/Library/Widget/Carousel/View.php index 1b96e8f6c1a30dcdfd3db2f6d0bf8a04887e806a..163aa150a347c4e9e60555e00abd9f59f176ce31 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/View.php +++ b/library/templates/Intonation/Library/Widget/Carousel/View.php @@ -24,7 +24,6 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help protected $_template_context; - protected static $_helper_by_layout = [Intonation_Library_Widget_Carousel_Definition::WALL => Intonation_View_RenderWall::class, Intonation_Library_Widget_Carousel_Definition::CAROUSEL => ZendAfi_View_Helper_Template_LayoutCarousel::class, @@ -182,12 +181,37 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help protected function _getHTML() { + return $this->_isDelayed() + ? $this->_renderDelayed() + : $this->getBodyHTML(); + } + + + public function getBodyHTML() : string { return ($elements = $this->_findElements()) ? $this->_renderElements($elements) : $this->_emptyListMessage(); } + protected function _isDelayed() : bool { + return $this->_settings->isDelayed(); + } + + + protected function _renderDelayed () : string { + return $this->view->loadingIcon() + . $this->view->delayedLoad('widget', + 'render', + ['render' => 'ajax', + 'only' => 'body', + 'widget_id' => $this->getId(), + 'profile_id' => Class_Profil::getCurrentProfil()->getId()], + sprintf('$("#boite_%s").find(".loading_icon_wrapper").remove();', + $this->getIdModule())); + } + + protected function _renderElements($elements) { $content_callback = $this->_getContentCallback($this->_settings->getRendering()); diff --git a/library/templates/Intonation/System/Abstract.php b/library/templates/Intonation/System/Abstract.php index 4f809f1b6c7bdd46255bc88cbb5e64e8529a3345..e97c419c934cc62e93c88a6612d59ef35753eab7 100644 --- a/library/templates/Intonation/System/Abstract.php +++ b/library/templates/Intonation/System/Abstract.php @@ -49,6 +49,13 @@ abstract class Intonation_System_Abstract { } + public function renderBodyOn($view) : string { + return ($helper = $this->_getViewHelper($view)) + ? $helper->getBodyHtml() + : ''; + } + + public function getIdForHtml() : string { $parent_id = ($parent = $this->getParentInstance()) ? ($parent->getIdForHtml()) diff --git a/library/templates/Intonation/System/WidgetSettings.php b/library/templates/Intonation/System/WidgetSettings.php index f53f7ff2f2d298d81b73a4949304a59a57d0ed2c..9da049f6556af0c8476b9223d11da20bb6984e58 100644 --- a/library/templates/Intonation/System/WidgetSettings.php +++ b/library/templates/Intonation/System/WidgetSettings.php @@ -56,4 +56,9 @@ class Intonation_System_WidgetSettings { ? $id : $parent_id . '_' . $id; } + + + public function isDelayed() : bool { + return (bool) $this->_settings->getDelayed(); + } } diff --git a/library/templates/Intonation/Template.php b/library/templates/Intonation/Template.php index 971300af743131ef9186547a36d03a5aacd8cea8..12c5541c7bac7b3d9885a5ea0e4fcfd8d699a33c 100644 --- a/library/templates/Intonation/Template.php +++ b/library/templates/Intonation/Template.php @@ -52,10 +52,16 @@ class Intonation_Template extends Class_Template { } + public function renderWidgetBodyOn($instance, $view) { + return $instance->renderBodyOn($view); + } + + public function renderWidget($widget, $view) { Class_AnchorTarget::setTarget($widget->getAnchorTarget()); $widget + ->setShouldRender(true) ->setMenuAdminLinksHelper($view) ->setSection(new Class_Entity); @@ -63,6 +69,17 @@ class Intonation_Template extends Class_Template { } + public function renderWidgetBody($widget, $view) { + Class_AnchorTarget::setTarget($widget->getAnchorTarget()); + + $widget + ->setMenuAdminLinksHelper($view) + ->setSection(new Class_Entity); + + return $this->renderWidgetBodyOn((new Intonation_System_Widget($this))->setSettings($widget), $view); + } + + public function handleRecordView() { return true; } diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index fba973f5b4c96ed7410ca1b4518b2900dcc0f7b0..9691790104a94e79b8b7b755c36e8f1c3c5c6539 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -3741,7 +3741,7 @@ class RechercheControlleSimpleActionWithMultifacetsThesauriTest extends Recherch $this->mock_sql ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(facettes) AGAINST('+(HDOCU0001 HDOCU0002 HDOCU00020001) +(HMUSI0001)' IN BOOLEAN MODE)) and type=1", true, false) + ->with("select id_notice, facettes from notices Where (MATCH(facettes) AGAINST('+(HDOCU0001 HDOCU0002 HDOCU00020001) +HMUSI0001' IN BOOLEAN MODE)) and type=1", true, false) ->answers([ [1, ''] ]) ->whenCalled('fetchOne') diff --git a/tests/library/Class/MoteurRechercheTest.php b/tests/library/Class/MoteurRechercheTest.php index f2869086c8d1068bc98c2e5eefd78734488310a3..df1161c2772b2772157c0409dd87578184479579 100644 --- a/tests/library/Class/MoteurRechercheTest.php +++ b/tests/library/Class/MoteurRechercheTest.php @@ -112,7 +112,7 @@ class MoteurRechercheAvanceeTest extends MoteurRechercheTestCase { 'type_recherche' => 'nimportequoi', 'pertinence' => false, 'tri' => 'alpha_titre'], - 'req_notices' => $this->listSqlWith("date_creation >'2012-02-03' and (MATCH(titres) AGAINST('+(NOUVEAU NOUVEAUX NOUVO) +(CHIEN CHIENS CHIN) +(GARDE GARDES GARD)' IN BOOLEAN MODE) or MATCH(editeur) AGAINST('+(RAISON RAISONS RAISON) +(AGIR AGIRS AJIR)' IN BOOLEAN MODE)) and MATCH(facettes) AGAINST('+(B4)' IN BOOLEAN MODE)", + 'req_notices' => $this->listSqlWith("date_creation >'2012-02-03' and (MATCH(titres) AGAINST('+(NOUVEAU NOUVEAUX NOUVO) +(CHIEN CHIENS CHIN) +(GARDE GARDES GARD)' IN BOOLEAN MODE) or MATCH(editeur) AGAINST('+(RAISON RAISONS RAISON) +(AGIR AGIRS AJIR)' IN BOOLEAN MODE)) and MATCH(facettes) AGAINST('+B4' IN BOOLEAN MODE)", 'alpha_titre')], [['rech_auteurs' => 'Foucault', @@ -213,7 +213,7 @@ class MoteurRechercheAvanceeTest extends MoteurRechercheTestCase { 'type_recherche' => 'commence', 'pertinence' => true, 'tri' => 'alpha_titre'], - 'req_notices' => $this->listSqlWith("(auteurs like 'STIEGLER%') and MATCH(facettes) AGAINST('+YMED1 +G23 +A345 +(T1 Tbokeh_page) +(YTUN YTAP) +(S1 S12 S9) +(B3)' IN BOOLEAN MODE)", + 'req_notices' => $this->listSqlWith("(auteurs like 'STIEGLER%') and MATCH(facettes) AGAINST('+YMED1 +G23 +A345 +(T1 Tbokeh_page) +(YTUN YTAP) +(S1 S12 S9) +B3' IN BOOLEAN MODE)", 'alpha_titre')] ]; } @@ -329,7 +329,7 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { 'geo_bib' => 3, 'tri' => 'alpha_auteur'] , 'nb_mots'=> null, - 'req_liste' => $this->listSqlWith("(isbn='2-7427-3315-9' or isbn='978-2-7427-3315-6') and MATCH(facettes) AGAINST('+(B3)' IN BOOLEAN MODE)", + 'req_liste' => $this->listSqlWith("(isbn='2-7427-3315-9' or isbn='978-2-7427-3315-6') and MATCH(facettes) AGAINST('+B3' IN BOOLEAN MODE)", "alpha_auteur")], [['expressionRecherche' => '9782742761579'], @@ -346,7 +346,7 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { [['expressionRecherche' => '9782742761579', 'selection_bib'=> 1], 'nb_mots'=> null, - 'req_liste' => $this->listSqlWith("(isbn='2-7427-6157-8' or isbn='978-2-7427-6157-9') and MATCH(facettes) AGAINST('+(B1)' IN BOOLEAN MODE)")], + 'req_liste' => $this->listSqlWith("(isbn='2-7427-6157-8' or isbn='978-2-7427-6157-9') and MATCH(facettes) AGAINST('+B1' IN BOOLEAN MODE)")], [['expressionRecherche' => 'logo', 'annexe' => 'MED1', @@ -360,7 +360,7 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { [['expressionRecherche' => 'logo', 'multifacets' => 'Tper_title'], 'nb_mots'=> 1, - 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+(Tper_title)' IN BOOLEAN MODE)", + 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+Tper_title' IN BOOLEAN MODE)", "MATCH(auteurs) AGAINST('P_LOGO') desc, MATCH(titres) AGAINST('P_LOGO') desc, MATCH(titres) AGAINST('LOGO') desc, MATCH(auteurs) AGAINST('LOGO') desc, date_creation desc")], [['expressionRecherche' => 'security', @@ -372,7 +372,7 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { 'type_doc' => 'delete("*"),1,uraiets,2', 'selection_sections' => '1;goup<ip;9'], 'nb_mots'=> 1, - 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(SECURITY SECURITYS SEKURITI)' IN BOOLEAN MODE) and type_doc in('1','2') and MATCH(facettes) AGAINST('+(Y8) +(S1 S9) +(E34) +(B12)' IN BOOLEAN MODE)", + 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(SECURITY SECURITYS SEKURITI)' IN BOOLEAN MODE) and type_doc in('1','2') and MATCH(facettes) AGAINST('+Y8 +(S1 S9) +E34 +B12' IN BOOLEAN MODE)", "MATCH(auteurs) AGAINST('P_SECURITY') desc, MATCH(titres) AGAINST('P_SECURITY') desc, MATCH(titres) AGAINST('SECURITY') desc, MATCH(auteurs) AGAINST('SECURITY') desc, date_creation desc")], [['expressionRecherche' => '', @@ -402,7 +402,7 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { // see http://forge.afi-sa.fr/issues/46007 [['filtres' => 'T1;-HFOND0003*;'], 'nb_mots'=> 0, - 'req_liste' => $this->listSqlWith('MATCH(facettes) AGAINST(\'+(T1) +(HFOND0003*)\' IN BOOLEAN MODE)')], + 'req_liste' => $this->listSqlWith('MATCH(facettes) AGAINST(\'+T1 +HFOND0003*\' IN BOOLEAN MODE)')], // see http://forge.afi-sa.fr/issues/111788 [['expressionRecherche' => 'coeur cabossés', @@ -560,7 +560,7 @@ class MoteurRechercheRebondTest extends MoteurRechercheTestCase { 'tri' => 'alpha_titre', 'code_rebond' => 'A888', 'geo_bib' => 3] , - 'req_liste' => $this->listSqlWith("MATCH(facettes) AGAINST('+A888 +(B3)' IN BOOLEAN MODE)", "alpha_titre")], + 'req_liste' => $this->listSqlWith("MATCH(facettes) AGAINST('+A888 +B3' IN BOOLEAN MODE)", "alpha_titre")], [['rech_auteurs' => 'Fred Frith', @@ -605,7 +605,7 @@ class MoteurRechercheRebondTest extends MoteurRechercheTestCase { 'rubrique' =>'P4', 'selection_annexe' => ' ', 'geo_bib' => 3] , - 'req_liste' => $this->listSqlWith("MATCH(facettes) AGAINST('+A888 +(B3)' IN BOOLEAN MODE)", "alpha_titre")]]; + 'req_liste' => $this->listSqlWith("MATCH(facettes) AGAINST('+A888 +B3' IN BOOLEAN MODE)", "alpha_titre")]]; } @@ -881,7 +881,7 @@ class MoteurRechercheCatalogueTest extends MoteurRechercheTestCase { [['id_catalogue' => 101], '', - $this->listSqlWith("MATCH(facettes) AGAINST('+(T1) +(HFOND0003*)' IN BOOLEAN MODE)", + $this->listSqlWith("MATCH(facettes) AGAINST('+T1 +HFOND0003*' IN BOOLEAN MODE)", "annee desc, alpha_titre asc")] ]; } @@ -915,7 +915,7 @@ class MoteurRechercheCatalogueTest extends MoteurRechercheTestCase { $this->mock_sql ->whenCalled('fetchAll') - ->with($this->listSqlWith("date_creation >'2012-05-03' and MATCH(facettes) AGAINST('+(YANNECY YSEYNOD) +(HNANA0001 HNANA0002)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+(HNANA0001 HNANA0002) +(F565)' IN BOOLEAN MODE)", + ->with($this->listSqlWith("date_creation >'2012-05-03' and MATCH(facettes) AGAINST('+(YANNECY YSEYNOD) +(HNANA0001 HNANA0002)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+(HNANA0001 HNANA0002) +F565' IN BOOLEAN MODE)", "annee desc, alpha_titre asc"), true, false) diff --git a/tests/scenarios/Numel/NumelMapTest.php b/tests/scenarios/Numel/NumelMapTest.php index 43d4c7fa6f7378a087897388cffaa820bf00d6d4..a9ee63319b078be3179ccabbf9f8b58e68ab0081 100644 --- a/tests/scenarios/Numel/NumelMapTest.php +++ b/tests/scenarios/Numel/NumelMapTest.php @@ -19,9 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -abstract class NumelKioskMapTestCase extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; +abstract class NumelKioskMapTestCase extends AbstractControllerTestCase { public function setUp() { parent::setUp(); @@ -227,7 +226,7 @@ class NumelKioskMapLimit1000Test extends AbstractControllerTestCase { $preferences) ->assertSave(); - $this->dispatch('/opac/index'); + $this->dispatch('/index'); } diff --git a/tests/scenarios/SearchResult/SearchResultTest.php b/tests/scenarios/SearchResult/SearchResultTest.php index f8cf836be4358d48e6a92858fb4be353b8d17c1d..493fa6a04b1e7c3e5658f48f37f766c3163705ac 100644 --- a/tests/scenarios/SearchResult/SearchResultTest.php +++ b/tests/scenarios/SearchResult/SearchResultTest.php @@ -131,7 +131,7 @@ class SearhResultFilterDomainsFromProfilTest extends AbstractControllerTestCase $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(TROLL TROLLS TROL) +(TROY TROYS TROI)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+(T2) +(HCCCC0001 HCCCC0002)' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"TROLLS DE TROY\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"TROLLS DE TROY\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_TROLLS P_TROY') desc, MATCH(titres) AGAINST('P_TROLLS P_TROY') desc, MATCH(titres) AGAINST('TROLLS TROY') desc, MATCH(auteurs) AGAINST('TROLLS TROY') desc, date_creation desc", true, false) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(TROLL TROLLS TROL) +(TROY TROYS TROI)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+T2 +(HCCCC0001 HCCCC0002)' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"TROLLS DE TROY\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"TROLLS DE TROY\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_TROLLS P_TROY') desc, MATCH(titres) AGAINST('P_TROLLS P_TROY') desc, MATCH(titres) AGAINST('TROLLS TROY') desc, MATCH(auteurs) AGAINST('TROLLS TROY') desc, date_creation desc", true, false) ->answers([ ['1', 'T1 T2']]) ->beStrict(); @@ -162,7 +162,7 @@ class SearchResultFilterFromProfilTest extends AbstractControllerTestCase { $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(TROLL TROLLS TROL) +(TROY TROYS TROI)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+(T2)' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"TROLLS DE TROY\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"TROLLS DE TROY\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_TROLLS P_TROY') desc, MATCH(titres) AGAINST('P_TROLLS P_TROY') desc, MATCH(titres) AGAINST('TROLLS TROY') desc, MATCH(auteurs) AGAINST('TROLLS TROY') desc, date_creation desc", true, false) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(TROLL TROLLS TROL) +(TROY TROYS TROI)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+T2' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"TROLLS DE TROY\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"TROLLS DE TROY\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_TROLLS P_TROY') desc, MATCH(titres) AGAINST('P_TROLLS P_TROY') desc, MATCH(titres) AGAINST('TROLLS TROY') desc, MATCH(auteurs) AGAINST('TROLLS TROY') desc, date_creation desc", true, false) ->answers([ ['1' , 'T1 T2']]); Zend_Registry::set('sql', $sql); @@ -219,7 +219,7 @@ class SearchResultFilterFromProfilOnDomainTest extends AbstractControllerTestCas $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (date_creation >'2017-04-13' and MATCH(facettes) AGAINST('+(B1) +(E36 E112) +(HNNNN0001)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+(T2) +(B1)' IN BOOLEAN MODE)) and type=1 order by annee desc, alpha_titre asc", true, false) + ->with("select id_notice, facettes from notices Where (date_creation >'2017-04-13' and MATCH(facettes) AGAINST('+B1 +(E36 E112) +HNNNN0001' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+T2 +B1' IN BOOLEAN MODE)) and type=1 order by annee desc, alpha_titre asc", true, false) ->answers([ [1, 'T1 T2 B1 HNNNN0001 E36 A332'] ]) ->beStrict(); diff --git a/tests/scenarios/Templates/TemplatesLibraryNoveltiesTabTest.php b/tests/scenarios/Templates/TemplatesLibraryNoveltiesTabTest.php index 535c47e6d3991ef362a78df05e3485dd0495a428..52dd62bb72e78479aca4ce44d675729fd509b8ae 100644 --- a/tests/scenarios/Templates/TemplatesLibraryNoveltiesTabTest.php +++ b/tests/scenarios/Templates/TemplatesLibraryNoveltiesTabTest.php @@ -256,7 +256,7 @@ abstract class TemplatesLibraryNoveltiesTabWithAutoSelectionTestCase extends Abs ->mock() ->whenCalled('fetchAll') - ->with('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+(B1)\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="", date_creation desc, alpha_titre asc limit 20', true, false) + ->with('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+B1\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="", date_creation desc, alpha_titre asc limit 20', true, false) ->answers([[789, '']]) ->beStrict(); @@ -334,7 +334,7 @@ class TemplatesLibraryNoveltiesTabWidgetRenderAllTest extends TemplatesLibraryNo $sql = Zend_Registry::get('sql') ->whenCalled('fetchAll') - ->with('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+(B1)\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="", date_creation desc, alpha_titre asc limit 1000', true, false) + ->with('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+B1\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="", date_creation desc, alpha_titre asc limit 1000', true, false) ->answers([[789, '']]); $this->dispatch('widget/render-all/profile_id/23/widget_id/bib_novelties_1'); diff --git a/tests/scenarios/Templates/TemplatesUserSettingsTest.php b/tests/scenarios/Templates/TemplatesUserSettingsTest.php index 905bb6e6ced2ec453d24a26b9b07556002e44c99..01eeba821b07bae1f63696b74f0b73b719193fa0 100644 --- a/tests/scenarios/Templates/TemplatesUserSettingsTest.php +++ b/tests/scenarios/Templates/TemplatesUserSettingsTest.php @@ -299,13 +299,14 @@ class TemplatesUserSettingsSearchSaveChiliAndDomainBDTest extends TemplatesUserS class TemplatesUserSettingsSearchSaveChiliAndDomainBDAndWidgetDomainTest extends TemplatesUserSettingsSearchSaveTestCase { + public function setUp() { parent::setUp(); $profile = $this->_buildTemplateProfil(['id' => '78979', 'template' => 'CHILI']); - $this->fixture('Class_Catalogue', + $this->fixture(Class_Catalogue::class, ['id' => 2, 'libelle' => 'BD', 'auteur' => '1']); @@ -352,21 +353,20 @@ class TemplatesUserSettingsSearchSaveChiliAndDomainBDAndWidgetDomainTest extends /** @test */ - public function orderForCarouselShouldBeTitleAsc() { + public function orderForCarouselShouldBeAlphaTitreAsc() { $this->dispatch('/recherche/simple/tri/alpha_auteur+desc/id_catalogue/2'); - $this->assertEquals('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+(A1)\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="", alpha_titre asc limit 9', - Zend_Registry::get('sql')->getFirstAttributeForMethodCallAt('fetchAll', 1)); + $this->assertEquals('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+A1\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="", alpha_titre asc limit 9', + Zend_Registry::get('sql')->getFirstAttributeForLastCallOn('fetchAll')); } /** @test */ - public function withUserSettingsOrderForCarouselShouldBeTitleAsc() { + public function withUserSettingsOrderForCarouselShouldRemainAlphaTitreAsc() { (new Class_User_Settings(Class_Users::find('898'))) ->setSearchOrder('alpha_titre desc') ->save(); - $this->dispatch('/recherche/simple/tri/alpha_auteur+desc/id_catalogue/2'); - $this->assertEquals('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+(A1)\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="", alpha_titre asc limit 9', - Zend_Registry::get('sql')->getFirstAttributeForMethodCallAt('fetchAll', 1)); + $this->assertEquals('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+A1\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="", alpha_titre asc limit 9', + Zend_Registry::get('sql')->getFirstAttributeForLastCallOn('fetchAll')); } } diff --git a/tests/scenarios/Templates/TemplatesWidgetCarouselTest.php b/tests/scenarios/Templates/TemplatesWidgetCarouselTest.php index db304a2a918e9bb7c811dd14c6a10853536af3d6..abf78e2725db792d127a262d1acbefc76a36f5f7 100644 --- a/tests/scenarios/Templates/TemplatesWidgetCarouselTest.php +++ b/tests/scenarios/Templates/TemplatesWidgetCarouselTest.php @@ -256,7 +256,7 @@ class TemplatesWidgetCarouselRecordRandomTest extends AbstractControllerTestCase Zend_Registry::set('sql', $this->mock() ->whenCalled('fetchAll') - ->with('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+(T1)\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="" limit 100', true, false) + ->with('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+T1\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="" limit 100', true, false) ->answers($search_result)); $this->dispatch('/index'); @@ -265,7 +265,7 @@ class TemplatesWidgetCarouselRecordRandomTest extends AbstractControllerTestCase /** @test */ public function carouselShouldBePresentWithTwoRandomRecords() { - $this->assertXpathCount('//div[contains(@class, "boite kiosque")]//div[contains(@class, "card-deck")]//div[contains(@class, "card_with_overlay")]', + $this->assertXpathCount('//div[contains(@class, "card-deck")]//div[contains(@class, "card_with_overlay")]', 2); } @@ -281,8 +281,6 @@ class TemplatesWidgetCarouselRecordRandomTest extends AbstractControllerTestCase abstract class TemplatesWidgetCarouselRecordDomainTestCase extends AbstractControllerTestCase { - protected - $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); @@ -293,6 +291,7 @@ abstract class TemplatesWidgetCarouselRecordDomainTestCase extends AbstractContr Intonation_Library_Widget_Carousel_Record_Definition::CODE, ['layout' => 'horizontal_list', 'rendering' => 'card-overlay', + 'delayed' => 1, 'size' => 2, 'rss' => 0, 'embeded_code' => 0, @@ -338,7 +337,7 @@ abstract class TemplatesWidgetCarouselRecordDomainTestCase extends AbstractContr Zend_Registry::set('sql', $mock_sql); $mock_sql ->whenCalled('fetchAll') - ->with('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+(T3)\' IN BOOLEAN MODE) and MATCH(facettes) AGAINST(\'+(S2 S3)\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="" limit 100', + ->with('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+T3\' IN BOOLEAN MODE) and MATCH(facettes) AGAINST(\'+(S2 S3)\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="" limit 100', true, false) ->answers([[2, 'T3'], @@ -350,10 +349,10 @@ abstract class TemplatesWidgetCarouselRecordDomainTestCase extends AbstractContr -class TemplatesWidgetRecordDomainTest extends TemplatesWidgetCarouselRecordDomainTestCase { +class TemplatesWidgetCarouselRecordDomainTest extends TemplatesWidgetCarouselRecordDomainTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/index'); + $this->dispatch('/widget/render/only/body/widget_id/1/profile_id/1'); } @@ -387,4 +386,32 @@ class TemplatesWidgetCarouselRecordDomainEmptyTest extends TemplatesWidgetCarous public function carouselShouldBeEmpty() { $this->assertNotXpath('//div[contains(@class, "card-title")]'); } +} + + + + +class TemplatesWidgetCarouselDelayedRecordWithDomainTest extends TemplatesWidgetCarouselRecordDomainTestCase { + + /** @test */ + public function responseShouldContainsDelayedLoadWithWidgetBodyWidgetIdOneAndProfileIdOne() { + $this->dispatch('/index'); + $this->assertXpathContentContains('//script[contains(text(), ".load(")]' + . '[contains(text(), "/widget/render/render/ajax/only/body/widget_id/1/profile_id/1")]', + '$("#boite_1").find(".loading_icon_wrapper").remove();'); + } + + + /** @test */ + public function carouselCardTitleShouldDisplayRecordLaJeuneFille() { + $this->dispatch('/widget/render/render/ajax/only/body/widget_id/1/profile_id/1/render/ajax'); + $this->assertXpath('//div[contains(@class, "card-title")][text()="La jeune fille"]'); + } + + + /** @test */ + public function editWidgetOneShouldHaveInputCheckboxDelayedChecked() { + $this->dispatch('/admin/widget/edit-widget/id/1/id_profil/1'); + $this->assertXPath('//form//input[@name="delayed"][@type="checkbox"][@data-level="expert"][@checked]'); + } } \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesWidgetTest.php b/tests/scenarios/Templates/TemplatesWidgetTest.php index 606e10d1fee99efdc20bbabaabe5de672d69ce1a..5707fe7f53911804bb57631aff21306eaf9d3cfb 100644 --- a/tests/scenarios/Templates/TemplatesWidgetTest.php +++ b/tests/scenarios/Templates/TemplatesWidgetTest.php @@ -1861,7 +1861,7 @@ class TemplatesWidgetCarouselWithDomainTest extends TemplatesWidgetCarouselWithD public function setUp() { parent::setUp(); - $this->dispatch('/widget/render/widget_id/1/profile_id/2890'); + $this->dispatch('/index'); } @@ -1905,7 +1905,7 @@ class TemplatesWidgetCarouselWithDomainFindByIdsTest extends TemplatesWidgetCaro Class_Profil::DIV_MAIN, $params); - $this->dispatch('/widget/render/widget_id/1/profile_id/2890'); + $this->dispatch('/index'); }