Skip to content
Snippets Groups Projects
Commit 5b5bc463 authored by Laurent's avatar Laurent
Browse files

hotline #147804 MT Record kiosk fix on empty domain

Also change algorithm in order to use CriteresRecherche. So profile
filter are taken in account
parent 54a67544
No related merge requests found
Pipeline #16186 failed with stage
in 22 minutes and 54 seconds
- correctif #147804 : Magasin de thèmes : correction de l'affichage des notices dans un kiosque lorsque le domaine associé ne retourne aucune notice. Le kiosque est maintenant bien vide
\ No newline at end of file
......@@ -61,10 +61,10 @@ class Intonation_Library_Widget_Carousel_Record_View extends Intonation_Library_
protected function _findRecords($params) {
$selection_id = $this->_settings->getIdPanier();
$order = $this->_settings->getOrder();
$domain_id = $this->_settings->getIdCatalogue();
$domain_id = (int)$this->_settings->getIdCatalogue();
if ($records = $this->_findRecordsInDomain($domain_id, $params))
return $records;
if ($domain_id > 0)
return $this->_findRecordsInDomain($domain_id, $params);
if ( ! $selection = Class_PanierNotice::find($selection_id))
return Class_Notice::findAllBy($params);
......@@ -79,27 +79,17 @@ class Intonation_Library_Widget_Carousel_Record_View extends Intonation_Library_
}
protected function _findRecordsInDomain($domain_id, $params) {
if ( ! $domain_id)
return [];
if ( ! Class_Catalogue::find($domain_id))
protected function _findRecordsInDomain(int $domain_id, array $params) : array {
if (!Class_Catalogue::find($domain_id))
return [];
$params['id_catalogue'] = $domain_id;
$params['tri'] = $params['order'];
$params['nb_notices'] = $params['limit'];
$request = Class_Catalogue::getRequetes($params);
if ( ! isset($request['req_ids']))
return [];
if ( ! $request_ids = $request['req_ids'])
return [];
$params['page_size'] = $params['limit'];
return Class_Notice::findAllByRequeteRecherche($request_ids,
$this->_getLimit(), 1);
$criteres = (new Class_CriteresRecherche)->setParams($params);
$result = (new Class_MoteurRecherche)->lancerRecherche($criteres);
return $result->fetchRecords();
}
......
00627nam0 22002291 450 00100080000001000180000802100070002610000410003310100130007410500390008720000690012621000360019521500290023122500230026067600060028368600100028970000290029983000270032883500060035593000140036193200220037500028922 a2-07-052818-9 aFR a20010130 d 0frea01 ba1 afreceng 1[2001-01-30-00.00.00.000000][][][]1 aHarry Potter et le prisonnier d'AzkabanfJoanne Kathleen Rowling aPariscGallimard jeunessed2000 a465 p.3465cill.d18 cm 2aFolio juniorv1006 10 aR ROW1 aRowlingbJoanne Kathleen 1A32A partir de 10 ans aJ aRomans4R aSorcier-Sorcière
\ No newline at end of file
No preview for this file type
......@@ -38,23 +38,25 @@ abstract class ZendAfi_View_Helper_Accueil_KiosqueTestCase extends ViewHelperTes
$this->_helper->setView(new ZendAfi_Controller_Action_Helper_View());
$this->_notices = [$this->fixture('Class_Notice' , ['id' => 2,
'unimarc' => "00627nam0 22002291 450 00100080000001000180000802100070002610000410003310100130007410500390008720000690012621000360019521500290023122500230026067600060028368600100028970000290029983000270032883500060035593000140036193200220037500028922 a2-07-052818-9 aFR a20010130 d 0frea01 ba1 afreceng 1[2001-01-30-00.00.00.000000][][][]1 aHarry Potter et le prisonnier d'AzkabanfJoanne Kathleen Rowling aPariscGallimard jeunessed2000 a465 p.3465cill.d18 cm 2aFolio juniorv1006 10 aR ROW1 aRowlingbJoanne Kathleen 1A32A partir de 10 ans aJ aRomans4R aSorcier-Sorcière",
'url_vignette' => 'hp.png',
'url_image' => 'hp_big.png',
'facettes' => 'D123 A400 Y2',
'clef_oeuvre' => 'HPELPA',
'clef_alpha' => 'POTTER',
'exemplaires' => []]),
$this->fixture('Class_Notice' , ['id' => 45,
'unimarc' => "01328ngm0 2200265 450 0010007000001000041000071010013000481020007000611150025000682000071000932100022001642150053001863000035002393000045002743300454003193450027007735100018008006060027008186060039008457000042008847020043009267020033009697020032010028010028010342247456 a20021213i20041975u y0frey0103 ba0 abamjfre aFR ac086baz|zba zz c1 aLa jeune fillebDVDdDen MusofSouleymane Cisse, réal., scénario cPathédcop. 2004 a1 DVD vidéo monoface zone 2 (1 h 26 min)ccoul. aDate de sortie du film : 1975. aFilm en bambara sous-titré en français aSékou est renvoyé de l'usine parce qu'il a osé demander une augmentation. Chômeur, il sort avec Ténin, une jeune fille muette ; il ignore qu'elle est la fille de son ancien patron. Ténin, qui sera violée par Sékou lors d'une sortie entre jeunes, se retrouve enceinte et subit la colère de ses parents. Elle se trouve alors confrontée brutalement à la morale de sa famille et à la lâcheté de Sékou, qui refuse de reconnaiîre l'enfant. b3388334509824d14.00 ?1 aDen Musozbam| 31070135aCinémayMali| 32243367aCinéma30076549yAfrique 131070144aCissébSouleymane43704690 132247457aCoulibalibDounamba Dani4590 132247458aDiabatebFanta4590 132247459aDiarrabOumou4590 0aFRbBNc20011120gAFNOR",
'url_vignette' => 'jeune_fille.png',
'url_image' => 'jeune_fille_big.png',
'facettes' => 'D13 A10 Y1',
'clef_oeuvre' => 'JF',
'clef_alpha' => 'JF',
'exemplaires' => []]),
$this->_notices = [$this->fixture(Class_Notice::class ,
['id' => 2,
'unimarc' => file_get_contents(ROOT_PATH.'/tests/fixtures/harry_potter_azkaban.uni'),
'url_vignette' => 'hp.png',
'url_image' => 'hp_big.png',
'facettes' => 'D123 A400 Y2',
'clef_oeuvre' => 'HPELPA',
'clef_alpha' => 'POTTER',
'exemplaires' => []]),
$this->fixture(Class_Notice::class ,
['id' => 45,
'unimarc' => file_get_contents(ROOT_PATH.'/tests/fixtures/jeune_fille_dvd.uni'),
'url_vignette' => 'jeune_fille.png',
'url_image' => 'jeune_fille_big.png',
'facettes' => 'D13 A10 Y1',
'clef_oeuvre' => 'JF',
'clef_alpha' => 'JF',
'exemplaires' => []]),
];
}
......
......@@ -30,7 +30,7 @@ class ZendAfi_View_Helper_ListeNotices_ChronoSourceTest extends ViewHelperTestCa
$notices =
[Class_Notice::newInstanceWithId(2,
['unimarc' => "00627nam0 22002291 450 00100080000001000180000802100070002610000410003310100130007410500390008720000690012621000360019521500290023122500230026067600060028368600100028970000290029983000270032883500060035593000140036193200220037500028922 a2-07-052818-9 aFR a20010130 d 0frea01 ba1 afreceng 1[2001-01-30-00.00.00.000000][][][]1 aHarry Potter et le prisonnier d'AzkabanfJoanne Kathleen Rowling aPariscGallimard jeunessed2000 a465 p.3465cill.d18 cm 2aFolio juniorv1006 10 aR ROW1 aRowlingbJoanne Kathleen 1A32A partir de 10 ans aJ aRomans4R aSorcier-Sorcière",
['unimarc' => file_get_contents(ROOT_PATH.'/tests/fixtures/harry_potter_azkaban.uni'),
'url_vignette' => 'hp.png',
'url_image' => 'hp_big.png',
'facettes' => 'D123 A400 Y2',
......
......@@ -157,73 +157,6 @@ class TemplatesWidgetCarouselLoaderTestTest extends ArticleLoaderGetArticlesByPr
/* hotline: #143811 */
class TemplatesWidgetCarouselRecordNewsTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->_buildTemplateProfil(['id' => 1,
'libelle' => 'Randomize carousel'])
->setBoiteOfTypeInDivision(2,
Intonation_Library_Widget_Carousel_Record_Definition::CODE,
['layout' => 'horizontal_list',
'rendering' => 'card-overlay',
'size' => 2,
'rss' => 0,
'embeded_code' => 0,
'link_to_all' => 1,
'all_layout' => 'list',
'all_rendering' => 'card-horizontal',
'description_length' => 20,
'titre' => 'Toutes les nouveautés',
'order' => 'RAND()',
'id_catalogue' => 10,
'type_module' => 'KIOSQUE'
])
->assertSave();
$this->fixture(Class_Catalogue::class,
['id' => 10,
'libelle' => 'Catalogue nouveauté',
'type_doc' => 1
]);
for ($i = 1; $i <= 100; $i++)
$this->fixture(Class_Notice::class,
['id' => $i]);
Zend_Registry::set('sql', null);
Storm_Cache::beVolatile();
$cache = (new Storm_Cache)
->memoize(['select notices.id_notice from notices Where (notices.type_doc=\'1\') and type=1 order by url_image="no", url_image="" LIMIT 0,100',
'NoticeLoader',
'getNoticeIdsByRequeteRecherche'],
function () {return range(1, 100);});
$this->dispatch('/index');
}
/** @test */
public function carouselShouldBePresentWithTwoRandomRecords() {
$this->assertXpathCount(2, '//div[contains(@class, "boite kiosque")]//div[contains(@class, "card-deck")]//div[contains(@class, "card_with_overlay")]');
}
/** @test */
public function carouselRecordsShouldBeShuffled() {
$this->assertRegExp('/.*(\/recherche\/viewnotice\/id\/(([^1-2]\/)|([0-9][0-9]0?\/)))./',
$this->_response->getBody());
}
}
/* hotline : #137145 */
class TemplatesWidgetCarouselNoticeReviewTest
extends AbstractControllerTestCase {
......
<?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
*/
/* hotline: #143811 */
class TemplatesWidgetKiosqueRandomTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->_buildTemplateProfil(['id' => 1,
'libelle' => 'Randomize carousel'])
->setBoiteOfTypeInDivision(2,
Intonation_Library_Widget_Carousel_Record_Definition::CODE,
['layout' => 'horizontal_list',
'rendering' => 'card-overlay',
'size' => 2,
'rss' => 0,
'embeded_code' => 0,
'link_to_all' => 1,
'all_layout' => 'list',
'all_rendering' => 'card-horizontal',
'description_length' => 20,
'titre' => 'Toutes les nouveautés',
'order' => 'RAND()',
'id_catalogue' => 10,
'type_module' => 'KIOSQUE'
])
->assertSave();
$this->fixture(Class_Catalogue::class,
['id' => 10,
'libelle' => 'Catalogue nouveauté',
'type_doc' => 1
]);
for ($i = 1; $i <= 100; $i++)
$this->fixture(Class_Notice::class,
['id' => $i]);
Zend_Registry::set('sql', null);
Storm_Cache::beVolatile();
$cache = (new Storm_Cache)
->memoize(['select notices.id_notice from notices Where (notices.type_doc=\'1\') and type=1 order by url_image="no", url_image="" LIMIT 0,100',
'NoticeLoader',
'getNoticeIdsByRequeteRecherche'],
function () {return range(1, 100);});
$this->dispatch('/index');
}
/** @test */
public function carouselShouldBePresentWithTwoRandomRecords() {
$this->assertXpathCount('//div[contains(@class, "boite kiosque")]//div[contains(@class, "card-deck")]//div[contains(@class, "card_with_overlay")]',
2);
}
/** @test */
public function carouselRecordsShouldBeShuffled() {
$this->assertRegExp('/.*(\/recherche\/viewnotice\/id\/(([^1-2]\/)|([0-9][0-9]0?\/)))./',
$this->_response->getBody());
}
}
abstract class TemplatesWidgetKiosqueDomainTestCase extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true,
$_mock_sql;
public function setUp() {
parent::setUp();
$this->_buildTemplateProfil(['id' => 1,
'libelle' => 'My domain'])
->setBoiteOfTypeInDivision(2,
Intonation_Library_Widget_Carousel_Record_Definition::CODE,
['layout' => 'horizontal_list',
'rendering' => 'card-overlay',
'size' => 2,
'rss' => 0,
'embeded_code' => 0,
'link_to_all' => 1,
'all_layout' => 'list',
'all_rendering' => 'card-horizontal',
'description_length' => 20,
'titre' => 'Toutes les nouveautés',
'order' => 'RAND()',
'id_catalogue' => 10,
'type_module' => 'KIOSQUE'
])
->setSelSection('2;3')
->assertSave();
$this->fixture(Class_Catalogue::class,
['id' => 10,
'libelle' => 'Catalogue nouveauté',
'type_doc' => 3
]);
$this->fixture(Class_Notice::class,
['id' => 2,
'unimarc' => file_get_contents(ROOT_PATH.'/tests/fixtures/harry_potter_azkaban.uni'),
'url_vignette' => 'hp.png',
'url_image' => 'hp_big.png',
'facettes' => 'D123 A400 Y2',
'clef_oeuvre' => 'HPELPA',
'clef_alpha' => 'POTTER',
'exemplaires' => []]);
$this->fixture(Class_Notice::class,
['id' => 45,
'unimarc' => file_get_contents(ROOT_PATH.'/tests/fixtures/jeune_fille_dvd.uni'),
'url_vignette' => 'jeune_fille.png',
'url_image' => 'jeune_fille_big.png',
'facettes' => 'D13 A10 Y1',
'clef_oeuvre' => 'JF',
'clef_alpha' => 'JF',
'exemplaires' => []]);
$this->_mock_sql = $this->mock();
Zend_Registry::set('sql', $this->_mock_sql);
$this->_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 annee desc, alpha_titre asc',
true,
false)
->answers([[2, 'T3'],
[45, 'T3']])
->beStrict();
}
}
class TemplatesWidgetKiosqueDomainTest extends TemplatesWidgetKiosqueDomainTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/index');
}
/** @test */
public function carouselCardTitleShouldDisplayRecordLaJeuneFille() {
$this->assertXpath('//div[contains(@class, "card-title")][text()="La jeune fille"]');
}
/** @test */
public function carouselCardTitleShouldDisplayRecordHarryPotter() {
$this->assertXpath('//div[contains(@class, "card-title")][text()="Harry Potter et le prisonnier d\'Azkaban"]');
}
}
class TemplatesWidgetKiosqueDomainEmptyTest extends TemplatesWidgetKiosqueDomainTestCase {
public function setUp() {
parent::setUp();
$this->_mock_sql
->whenCalled('fetchAll')
->with('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+(T3)\' IN BOOLEAN MODE)) and type=1 order by annee desc, alpha_titre asc',
true,
false)
->answers([])
->beStrict();
$this->dispatch('/index');
}
/** @test */
public function carouselShouldBeEmpty() {
$this->assertNotXpath('//div[contains(@class, "card-title")]');
}
}
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