diff --git a/VERSIONS_HOTLINE/152338 b/VERSIONS_HOTLINE/152338 new file mode 100644 index 0000000000000000000000000000000000000000..3bc396239a8f2c41b05772138ef50cb36ed3321a --- /dev/null +++ b/VERSIONS_HOTLINE/152338 @@ -0,0 +1 @@ + - correctif #152338 : Boite Kiosque : correction d'un effet de bord sur les boites kiosque utilisant le paramètre "Basculer automatiquement sur le profil" du thème Historique \ No newline at end of file diff --git a/application/modules/opac/controllers/JavaController.php b/application/modules/opac/controllers/JavaController.php index 5d255392a116f25eb81217842da10cb4cc6f94f9..87d0178e74da8a338a10cbf75642ea24b5ddf985 100644 --- a/application/modules/opac/controllers/JavaController.php +++ b/application/modules/opac/controllers/JavaController.php @@ -36,20 +36,21 @@ class JavaController extends ZendAfi_Controller_Action { public function kiosqueAction() { - $preferences = array_merge(Class_Systeme_ModulesAccueil::getInstance()->getValeursParDefaut('KIOSQUE'), - $this->getRequest()->getParams()); + $type_code = Class_Systeme_ModulesAccueil_Kiosque::CODE; + $preferences = array_merge(Class_Systeme_ModulesAccueil::getInstance()->getValeursParDefaut($type_code), + $this->_getParams()); + $profil = $this->extractProfilFromUrl(); + if ($id_module = $this->extractIdModuleFromUrl()) { $preferences = array_merge($preferences, - $profil->getModuleAccueilPreferences($id_module, 'KIOSQUE')); - - $preferences = Class_Systeme_ModulesAccueil_Kiosque::updatePreferencesForProfileRedirect($id_module, - $preferences); + $profil->getModuleAccueilPreferences($id_module, $type_code)); + $preferences['id_module'] = $id_module; + $preferences['id_profil'] = $profil->getId(); } - $this->view->notices = Class_Catalogue::getNoticesByPreferences($preferences); - $this->view->preferences = $preferences; + $this->view->preferences = Class_Systeme_ModulesAccueil_Kiosque::updatePreferencesForProfileRedirect($preferences); $viewRenderer = $this->getHelper('ViewRenderer'); @@ -59,7 +60,6 @@ class JavaController extends ZendAfi_Controller_Action { return; } - // Redirection vers la bonne vue $vue = '/java/' . $this->_getParam('vue', 'diaporama').'.phtml'; $viewRenderer->renderScript($vue); } diff --git a/library/Class/Systeme/ModulesAccueil/Kiosque.php b/library/Class/Systeme/ModulesAccueil/Kiosque.php index 3acae89225fe44cdfa0a5c89e16aacef35d7c6ab..57e572760560b1686c0ec32ca375000ff41fa2fc 100644 --- a/library/Class/Systeme/ModulesAccueil/Kiosque.php +++ b/library/Class/Systeme/ModulesAccueil/Kiosque.php @@ -34,7 +34,7 @@ class Class_Systeme_ModulesAccueil_Kiosque extends Class_Systeme_ModulesAccueil_ $_styles; - public function __construct() { + public function __construct() { $this->_libelle = $this->_('Boite kiosque'); $this->_form = 'ZendAfi_Form_Configuration_Widget_Carousel'; $this->_defaultValues = ['titre' => $this->_libelle, @@ -59,18 +59,22 @@ class Class_Systeme_ModulesAccueil_Kiosque extends Class_Systeme_ModulesAccueil_ 'id_panier' => 0, 'profil_redirect' => '', // affiche les notices dans ce profil ]; - } + } + + + public static function updatePreferencesForProfileRedirect(array $preferences) : array { + if (!isset($preferences['profil_redirect']) || !$preferences['profil_redirect']) + return $preferences; + if (isset($preferences['id_module'])) + $preferences['id_module'] = + ($preferences['id_profil'] ?? Class_Profil::getCurrentProfil()->getId()) + . '-' + . $preferences['id_module']; - public static function updatePreferencesForProfileRedirect($id_module, $preferences) { - $preferences['id_module'] = $id_module; - $preferences['id_profil'] = Class_Profil::getCurrentProfil()->getId(); + $preferences['id_profil'] = $preferences['profil_redirect']; + unset($preferences['profil_redirect']); - if ('' != $preferences['profil_redirect']) { - $preferences['id_profil'] = $preferences['profil_redirect']; - $preferences['id_module'] = Class_Profil::getCurrentProfil()->getId() - . '-' . $id_module; - } return $preferences; } diff --git a/library/ZendAfi/View/Helper/Accueil/Kiosque.php b/library/ZendAfi/View/Helper/Accueil/Kiosque.php index 89e05a11f1085c87c246191d3ca1bf4eb78952ac..81e49d0e32d8b19ebd39ddc93b69282fd1032fcd 100644 --- a/library/ZendAfi/View/Helper/Accueil/Kiosque.php +++ b/library/ZendAfi/View/Helper/Accueil/Kiosque.php @@ -25,8 +25,8 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba public function __construct($id_module, $params) { parent::__construct($id_module, $params); - $this->preferences = Class_Systeme_ModulesAccueil_Kiosque::updatePreferencesForProfileRedirect($id_module, - $this->preferences); + $this->preferences['id_module'] = $id_module; + $this->preferences['id_profil'] = Class_Profil::getCurrentProfil()->getId(); } @@ -43,8 +43,9 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba public function shouldCacheContent() { - return parent::shouldCacheContent() && in_array($this->preferences['style_liste'], - ['mur', 'vignettes', 'chrono', 'simple_wall']); + return parent::shouldCacheContent() + && in_array($this->preferences['style_liste'], + ['mur', 'vignettes', 'chrono', 'simple_wall']); } @@ -291,10 +292,11 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba public function getKiosqueHtml($page = 1) { - if ($this->isModeChrono() || $this->isModeSimpleWall() || (1 === (int)$this->preferences['aleatoire'])) + if ($this->isModeChrono() + || $this->isModeSimpleWall() + || (1 === (int)$this->preferences['aleatoire'])) return $this->_noPagerKioskHtml(); - $this->_nombre_notices_par_page = $this->preferences['nb_notices']; $nombre_total_notices = 0; $this->preferences['nb_notices'] = 0; @@ -308,13 +310,13 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba $page); } - if(!$notices) - return $this->view->tag('p',$this->view->_('Aucun résultat')); + if (!$notices) + return $this->view->tag('p', $this->_('Aucun résultat')); return $this->getPagerHtml($page, - $this->_nombre_notices_par_page, - $nombre_total_notices) + $this->_nombre_notices_par_page, + $nombre_total_notices) . $this->renderNoticesKiosqueHtml($notices); } @@ -322,7 +324,7 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba protected function _noPagerKioskHtml() { if (!$records = Class_Catalogue::getNoticesByPreferences($this->preferences)) - return $this->view->tag('p',$this->view->_('Aucun résultat')); + return $this->view->tag('p', $this->_('Aucun résultat')); return $this->renderNoticesKiosqueHtml($records); } diff --git a/library/ZendAfi/View/Helper/ListeNotices/Abstract.php b/library/ZendAfi/View/Helper/ListeNotices/Abstract.php index 860c36569c0c052d7c9b03ef2470a2a6bd5ef556..9745968bb502fd61cad27ee2c787afdedd08d198 100644 --- a/library/ZendAfi/View/Helper/ListeNotices/Abstract.php +++ b/library/ZendAfi/View/Helper/ListeNotices/Abstract.php @@ -57,11 +57,13 @@ abstract class ZendAfi_View_Helper_ListeNotices_Abstract extends ZendAfi_View_He } - protected function _updatePreferences($preferences) { - return array_merge(['liste_codes' => 'TANE', - 'display_add_to_cart' => true, - 'display_select_record' => false], - $preferences); + protected function _updatePreferences(array $preferences) : array { + $preferences = array_merge(['liste_codes' => 'TANE', + 'display_add_to_cart' => true, + 'display_select_record' => false], + $preferences); + + return Class_Systeme_ModulesAccueil_Kiosque::updatePreferencesForProfileRedirect($preferences); } diff --git a/library/ZendAfi/View/Helper/ListeNotices/ChronoSource.php b/library/ZendAfi/View/Helper/ListeNotices/ChronoSource.php index 88b63ef8ce16a16cf33a306cfb51b8657aadf362..17f146f0a2edec8f05dae045e450eef64787fd18 100644 --- a/library/ZendAfi/View/Helper/ListeNotices/ChronoSource.php +++ b/library/ZendAfi/View/Helper/ListeNotices/ChronoSource.php @@ -28,8 +28,8 @@ class ZendAfi_View_Helper_ListeNotices_ChronoSource $_current_date, $_preferences; - public function listeNotices_ChronoSource($notices, $preferences = []) { - $this->_preferences = $preferences; + public function listeNotices_ChronoSource($notices, $preferences=[]) { + $this->_preferences = $this->_updatePreferences($preferences); $this->_dates = []; array_map([$this, 'visitNotice'], $notices); @@ -38,6 +38,11 @@ class ZendAfi_View_Helper_ListeNotices_ChronoSource } + protected function _updatePreferences(array $preferences) : array { + return Class_Systeme_ModulesAccueil_Kiosque::updatePreferencesForProfileRedirect($preferences); + } + + public function visitNotice($notice) { $this->_url_notice = $this->view->urlNotice($notice, $this->_preferences); diff --git a/library/ZendAfi/View/Helper/ListeNotices/SimpleWall.php b/library/ZendAfi/View/Helper/ListeNotices/SimpleWall.php index 5974e602165ae3f666f445fe74fb963c4afe0001..53d326e2ac665c4bea15406c7f291f6e72731d10 100644 --- a/library/ZendAfi/View/Helper/ListeNotices/SimpleWall.php +++ b/library/ZendAfi/View/Helper/ListeNotices/SimpleWall.php @@ -18,11 +18,14 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class ZendAfi_View_Helper_ListeNotices_SimpleWall extends ZendAfi_View_Helper_ListeNotices_Abstract { + +class ZendAfi_View_Helper_ListeNotices_SimpleWall + extends ZendAfi_View_Helper_ListeNotices_Abstract { + public function listeNotices_SimpleWall($data, $preferences=[]) { $records = []; - $preferences = array_merge(['thumbnail_style' => ''], - $preferences); + $preferences = $this->_updatePreferences(array_merge(['thumbnail_style' => ''], + $preferences)); foreach($data as $record) $records[] = $this->_renderRecord($record, $preferences); @@ -32,6 +35,11 @@ class ZendAfi_View_Helper_ListeNotices_SimpleWall extends ZendAfi_View_Helper_Li } + public function _updatePreferences(array $preferences) : array { + return Class_Systeme_ModulesAccueil_Kiosque::updatePreferencesForProfileRedirect($preferences); + } + + protected function _renderRecord($record, $preferences) { return $this->view->notice_Vignette($record, $preferences); } diff --git a/tests/application/modules/opac/controllers/JavaControllerTest.php b/tests/application/modules/opac/controllers/JavaControllerTest.php index 6fae25df9ac0f1d2b0e6165831107a71a672b4e4..ab8913b24c5479e66a0f5733f24f10b8e2eca33c 100644 --- a/tests/application/modules/opac/controllers/JavaControllerTest.php +++ b/tests/application/modules/opac/controllers/JavaControllerTest.php @@ -18,27 +18,37 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -require_once 'AbstractControllerTestCase.php'; class JavaControllerWidthDefaultKiosqueTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); + $cfg_accueil = ['modules' => ['1' => ['division' => 1, - 'type_module' => 'KIOSQUE']], + 'type_module' => 'KIOSQUE', + 'preferences' => ['nb_notices' => 20]]], 'options' => []]; - - - $this->profil_cache = Class_Profil::getLoader()->newInstanceWithId(5345) - ->setBrowser('opac') - ->setLibelle('Profil cache') - ->setCfgAccueil($cfg_accueil); + $this->profil_cache = $this->fixture(Class_Profil::class, + ['id' => 5345, + 'browser' => 'opac', + 'Profil cache', + 'cfg_accueil' => $cfg_accueil + ]); Class_Profil::setCurrentProfil(Class_Profil::getLoader()->newInstanceWithId(2) ->setLibelle('Accueil')); $_SESSION['id_profil'] = 2; - $this->dispatch('java/kiosque?id_module=1&id_profil=5345', true); + $this->onLoaderOfModel(Class_Catalogue::class) + ->whenCalled('getNoticesByPreferences') + ->answers([$this->fixture(Class_Notice::class, + ['id' => 4, + 'titre' => 'Madagascar', + 'vignette' => 'http://thumbnail.com/madagascar.jpg'])]); + + $this->dispatch('java/kiosque?id_module=1&id_profil=5345'); } @@ -58,9 +68,12 @@ class JavaControllerWidthDefaultKiosqueTest extends AbstractControllerTestCase { abstract class JavaControllerCarrouselHorizontalTestCase extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { parent::setUp(); - $this->fixture('Class_Profil', + $this->fixture(Class_Profil::class, ['id' => 3, 'browser' => 'opac', 'libelle' => 'kiosque test', @@ -72,12 +85,12 @@ abstract class JavaControllerCarrouselHorizontalTestCase extends AbstractControl 'options' => []]]) ->beCurrentProfil(); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue') - ->whenCalled('getNoticesByPreferences') - ->answers([$this->fixture('Class_Notice', - ['id' => 4, - 'titre' => 'Madagascar', - 'vignette' => 'http://thumbnail.com/madagascar.jpg'])]); + $this->onLoaderOfModel('Class_Catalogue') + ->whenCalled('getNoticesByPreferences') + ->answers([$this->fixture(Class_Notice::class, + ['id' => 4, + 'titre' => 'Madagascar', + 'vignette' => 'http://thumbnail.com/madagascar.jpg'])]); } } @@ -87,29 +100,31 @@ abstract class JavaControllerCarrouselHorizontalTestCase extends AbstractControl class JavaControllerCarrouselHorizontalTest extends JavaControllerCarrouselHorizontalTestCase { public function setUp() { parent::setUp(); - $this->dispatch('java/kiosque/id_module/1/titre/title+%2F+with+some+%2F+slashes/vue/mycarousel_horizontal', true); + $this->dispatch('java/kiosque/id_module/1/titre/title+%2F+with+some+%2F+slashes/vue/mycarousel_horizontal'); } /** @test */ - public function titleShouldBeRemovedBecauseOfPossibleApacheMisconfigurationOfAllowEncodedSlashes() { + public function titleShouldNotBeInRecordUrlBecauseAllowEncodedSlashesCanBeMisconfigured() { $this->assertXPath('//div[@class="jMyCarousel"]//a[@href="/recherche/viewnotice/id/4/id_module/1/tri/1/id_profil/3"]'); } /** @test */ public function jMyCarouselShouldBeLoaded() { - $this->assertContains('jMyCarousel', $this->_response->getBody()); + $this->assertXPath('//script[contains(@src, "jMyCarousel.min.js")]'); } } -class JavaControllerCarrouselHorizontalWithoutIdModuleTest extends JavaControllerCarrouselHorizontalTestCase { +class JavaControllerCarrouselHorizontalWithoutIdModuleTest + extends JavaControllerCarrouselHorizontalTestCase { + public function setUp() { parent::setUp(); - $this->dispatch('java/kiosque/titre/title+%2F+with+some+%2F+slashes/vue/mycarousel_horizontal/id_catalogue/7', true); + $this->dispatch('java/kiosque/titre/title+%2F+with+some+%2F+slashes/vue/mycarousel_horizontal/id_catalogue/7'); } @@ -117,7 +132,6 @@ class JavaControllerCarrouselHorizontalWithoutIdModuleTest extends JavaControlle public function recordLinkShouldContainsIdCatalogue() { $this->assertXPath('//div[@class="jMyCarousel"]//a[@href="/recherche/viewnotice/id/4/id_catalogue/7/tri/1"]'); } - } @@ -137,7 +151,7 @@ class JavaControllerWithKiosqueMurPageTest extends AbstractControllerTestCase { Class_Profil::getCurrentProfil()->setCfgAccueil($cfg_accueil); - $this->dispatch('java/page/no/2/id_module/1', true); + $this->dispatch('java/page/no/2/id_module/1'); } @@ -155,7 +169,7 @@ class JavaControllerWithKiosqueMurPageTest extends AbstractControllerTestCase { /** @test */ public function pageShouldBeAccessible() { - $this->assertAccessible(false,$this->_response->getBody()); + $this->assertAccessible(false, $this->_response->getBody()); } } @@ -175,7 +189,7 @@ class JavaControllerWithKiosqueMurAndPanierDeletedTest extends AbstractControlle Class_Profil::getCurrentProfil()->setCfgAccueil($cfg_accueil); - $this->dispatch('/', true); + $this->dispatch('/'); } @@ -189,184 +203,144 @@ class JavaControllerWithKiosqueMurAndPanierDeletedTest extends AbstractControlle class JavaControllerKiosqueSlideShowWidthWrongParamsTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); - - Class_Notice::beVolatile(); - $cfg_accueil = ['modules' => ['1' => ['division' => 1, 'type_module' => 'MENU']], 'options' => []]; - - - $this->profil = Class_Profil::newInstanceWithId(5345, ['browser' => 'opac', - 'libelle' => 'Profil cache', - 'cfg_acceuil' => $cfg_accueil]); - - } + $this->profil = $this->fixture(Class_Profil::class, + ['id' => 5345, + 'browser' => 'opac', + 'libelle' => 'Profil cache', + 'cfg_acceuil' => $cfg_accueil]); + } /** @test */ public function vueShouldDefaultsToDiaporama() { - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue') - ->whenCalled('getNoticesByPreferences') - ->answers( $this->fixture('Class_Notice', - ['id' => 1, - 'titres' => 'Pomme'])); - $this->dispatch('java/kiosque?id_module=1&id_profil=5345', true); + $this->onLoaderOfModel(Class_Catalogue::class) + ->whenCalled('getNoticesByPreferences') + ->answers($this->fixture(Class_Notice::class, + ['id' => 1, + 'titres' => 'Pomme'])); + + $this->dispatch('java/kiosque?id_module=1&id_profil=5345'); $this->assertXPathContentContains('//script', 'slideshow'); } /** @test */ public function withNoRecordsFoundBodyShouldContainsNoRecordsFoundMessage() { - $this->dispatch('java/kiosque?id_module=1&id_profil=5345', true); - $this->assertXPathContentContains('//p', utf8_encode('Aucun document n\'a été trouvé'), $this->_response->getBody()); + $this->dispatch('java/kiosque?id_module=1&id_profil=5345'); + $this->assertXPathContentContains('//p', + utf8_encode('Aucun document n\'a été trouvé')); } } -class JavaControllerKiosqueSlideShowWithRedirectSettingsTest extends AbstractControllerTestCase { + +class JavaControllerKiosqueWithRedirectSettingsTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); + $cfg_accueil = ['modules' => ['1' => ['division' => '1', + 'type_module' => 'KIOSQUE', + 'preferences' => ['titre' => "My Kiosk", + 'profil_redirect' => 123]]]]; - $this->fixture('Class_Profil', + $this->fixture(Class_Profil::class, ['id' => 3, 'libelle' => 'modules', - 'cfg_accueil' => ['modules' => ['1' => ['division' => '1', - 'type_module' => 'KIOSQUE', - 'preferences' => ['titre' => "My Kiosk", - 'profil_redirect' => 123]]]] - ])->beCurrentProfil(); - - - $notice = Storm_Test_ObjectWrapper::mock(); - $notice - ->whenCalled('getId') - ->answers(10) - ->whenCalled('getTypeDoc') - ->answers(Class_TypeDoc::LIVRE) - ->whenCalled('isArticleCms') - ->answers(false) - ->whenCalled('isRSS') - ->answers(false) - ->whenCalled('isSite') - ->answers(false) - ->whenCalled('isPage') - ->answers(false) - ->whenCalled('getTitrePrincipal') - ->answers('Programmers <br> Hell\'s "code"') - ->whenCalled('fetchUrlLocalVignette') - ->answers('/img/hell_code.png') - ->whenCalled('getClefAlpha') - ->answers('PROGRAMMER_HELL'); - - $article = Storm_Test_ObjectWrapper::mock(); - $article - ->whenCalled('getId') - ->answers(12) - - ->whenCalled('getTypeDoc') - ->answers(Class_TypeDoc::ARTICLE) - - ->whenCalled('isArticleCms') - ->answers(true) - - ->whenCalled('isPage') - ->answers(false) - - ->whenCalled('getTitrePrincipal') - ->answers('Return of Harlock') - - ->whenCalled('getChamp856b') - ->answers(23) - - ->whenCalled('getClefAlpha') - ->answers('HARLOCK') - - ->whenCalled('fetchUrlLocalVignette') - ->answers('/img/harlock.png'); - - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue') - ->whenCalled('getNoticesByPreferences') - ->answers([$notice, $article]); - } - - - protected function javaUrlWithPreferences($display_mode, $redirect_profil) { - return 'java/kiosque/id_module/3-1/titre/title+%2F+with+some+%2F+slashes/vue/' . $display_mode. '/id_profil/'.$redirect_profil; - } - - - public function datas() { - $xpath_title = 'concat("Programmers <br> Hell", "\'", "s ", \'"\', \'code\', \'"\')'; - $url_notice = '/recherche/viewnotice/clef/PROGRAMMER_HELL/id/10/id_module/3-1/tri/1/id_profil/123'; - return [ - [ - $this->javaUrlWithPreferences('slide_show', 3), - - ['//div[@id="theImages"]//a[@href="' . $url_notice . '"]', - - '//div[@id="theImages"]//a[contains(@href, "id_profil/123")][contains(@href, "cms/articleview")][contains(@href, "id/23")]', - - '//a/img[@title=' . $xpath_title . ']' ]], - - [$this->javaUrlWithPreferences('protoflow', 3), - ['//div[@id="protoflow"]//a[@href="' . $url_notice . '"]', - - '//a[contains(@href, "id_profil/123")][contains(@href, "cms/articleview")][contains(@href, "id/23")][contains(@target, "_parent")]', - - '//a/img[@alt=' . $xpath_title . ']']], - - [$this->javaUrlWithPreferences('cube', 3), - ['//div[@id="linksCube"]//a[@href="' . $url_notice . '"]', - - '//a[contains(@href, "id_profil/123")][contains(@href, "cms/articleview")][contains(@href, "id/23")]', - - '//a/img[@title=' . $xpath_title . ']' ]], - - - [$this->javaUrlWithPreferences('diaporama', 3), - ['//div[@class="slideshow"]//img[contains(@onclick, "' . $url_notice . '")]', - - '//img[contains(@onclick, "id_profil/123")][contains(@onclick, "cms/articleview")][contains(@onclick, "id/23")]', + 'cfg_accueil' => $cfg_accueil]) + ->beCurrentProfil(); - '//img[@title=' . $xpath_title . ']' ]], - [$this->javaUrlWithPreferences('jcarousel', 3), - ['//ul[@id="mycarousel"]//a[@href="' . $url_notice . '"]', + $programmers = $this->fixture(Class_Notice::class, + ['id' => 10, + 'type_doc' => Class_TypeDoc::LIVRE, + 'titre_principal' => 'Programmers <br> Hell\'s "code"', + 'url_vignette' => '/img/hell_code.png', + 'clef_alpha' => 'PROGRAMMER_HELL']); - '//a[contains(@href, "id_profil/123")][contains(@href, "cms/articleview")][contains(@href, "id/23")]', + $unimarc = (new Class_NoticeUnimarc_Fluent) + ->zoneWithChildren('856', ['b' => 23]); - '//a/img[@title=' . $xpath_title . ']' ]], + $harlock = $this->fixture(Class_Notice::class, + ['id' => 12, + 'type_doc' => Class_TypeDoc::ARTICLE, + 'titre_principal' => 'Return of Harlock', + 'unimarc' => $unimarc->render(), + 'clef_alpha' => 'HARLOCK', + 'url_vignette' => '/img/harlock.png']); - [$this->javaUrlWithPreferences('mycarousel_horizontal', 3), - ['//div[@class="jMyCarousel"]//a[@href="' . $url_notice . '"]', + $this->onLoaderOfModel(Class_Catalogue::class) + ->whenCalled('getNoticesByPreferences') + ->answers([$programmers, $harlock]); + } - '//a[contains(@href, "id_profil/123")][contains(@href, "cms/articleview")][contains(@href, "id/23")]', - '//a/img[@title=' . $xpath_title . ']' ]], + public function datas() { + $xpath_title = 'concat("Programmers br Hell\'s ", \'"\', "code", \'"\')'; + $xpath_link_image_with_title = '//a/img[contains(@alt, ' . $xpath_title . ')]'; + + return + [['slide_show', + [$this->_tagWithRecordLink('//div[@id="theImages"]'), + '//div[@id="theImages"]//a[contains(@href, "id_profil/123")][contains(@href, "cms/articleview")][contains(@href, "id/23")]', + $xpath_link_image_with_title]], + + ['protoflow', + [$this->_tagWithRecordLink('//div[@id="protoflow"]'), + '//a[contains(@href, "id_profil/123")][contains(@href, "cms/articleview")][contains(@href, "id/23")][contains(@target, "_parent")]', + $xpath_link_image_with_title]], + + ['cube', + [$this->_tagWithRecordLink('//div[@id="linksCube"]'), + '//a[contains(@href, "id_profil/123")][contains(@href, "cms/articleview")][contains(@href, "id/23")]', + $xpath_link_image_with_title]], + + ['diaporama', + [$this->_tagWithRecordLink('//div[@class="slideshow"]', + '//img[contains(@onclick, "{URL}")]'), + '//img[contains(@onclick, "id_profil/123")][contains(@onclick, "cms/articleview")][contains(@onclick, "id/23")]', + '//img[@title=' . $xpath_title . ']']], + + ['jcarousel', + [$this->_tagWithRecordLink('//ul[@id="mycarousel"]'), + '//a[contains(@href, "id_profil/123")][contains(@href, "cms/articleview")][contains(@href, "id/23")]', + $xpath_link_image_with_title]], + + ['mycarousel_horizontal', + [$this->_tagWithRecordLink('//div[@class="jMyCarousel"]'), + '//a[contains(@href, "id_profil/123")][contains(@href, "cms/articleview")][contains(@href, "id/23")]', + $xpath_link_image_with_title]], + + ['mycarousel_vertical', + [$this->_tagWithRecordLink('//div[@class="jMyCarousel"]'), + '//a[contains(@href, "id_profil/123")][contains(@href, "cms/articleview")][contains(@href, "id/23")]', + $xpath_link_image_with_title]] + ]; + } - [$this->javaUrlWithPreferences('mycarousel_vertical', 3), - ['//div[@class="jMyCarousel"]//a[@href="' . $url_notice . '"]', - '//a[contains(@href, "id_profil/123")][contains(@href, "cms/articleview")][contains(@href, "id/23")]', + /** @test @dataProvider datas */ + public function contentFromUrlShouldSatisfyXPaths(string $display_mode, array $xpaths) { + $this->dispatch('java/kiosque/id_module/1/titre/title+%2F+with+some+%2F+slashes/vue/' . $display_mode . '/id_profil/3'); - '//a/img[@title=' . $xpath_title . ']' ]] - ]; + foreach($xpaths as $xpath) + $this->assertXPath($xpath, $this->_response->getBody()); } - /** - * @test - * @dataProvider datas - */ - public function contentFromUrlShouldSatisfyXPaths($url, $xpaths) { - $this->dispatch($url, true); - foreach($xpaths as $xpath) - $this->assertXPath($xpath, $this->_response->getBody()); + protected function _tagWithRecordLink(string $xpath_tag, + string $xpath_link='//a[@href="{URL}"]') : string { + return $xpath_tag + . str_replace('{URL}', + '/recherche/viewnotice/clef/PROGRAMMER_HELL/id/10/id_module/3-1/tri/1/id_profil/123', + $xpath_link); } } diff --git a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php index acc0d5604fecd529f1a1e85ffeccabffc42bdd59..2d244a4e5f96762b61b581f9ffb58b6c581f41f3 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php @@ -569,6 +569,7 @@ class ZendAfi_View_Helper_Accueil_KiosqueTitle extends ViewHelperTestCase { + class ZendAfi_View_Helper_Accueil_KiosqueProfileRedirectTest extends ViewHelperTestCase { public function setUp() { parent::setUp(); @@ -583,33 +584,33 @@ class ZendAfi_View_Helper_Accueil_KiosqueProfileRedirectTest extends ViewHelperT } - protected function getPreferencesWith($display_mode, $id_profil='142') { + protected function getPreferencesWith($display_mode) { $result = $this->getPreferences(); $result['preferences'] = ['style_liste' => $display_mode, - 'profil_redirect' => $id_profil]; + 'profil_redirect' => '142']; return $result; } public function datas() { $iframe_xpath = '//iframe' - . '[contains(@src, "id_profil=142")]' - . '[contains(@src, "id_module=2-3")]' - . '[not(contains(@src, "id_module/2-3"))]'; // see #121711 + . '[contains(@src, "id_profil=2")]' + . '[contains(@src, "id_module=3")]' + . '[contains(@src, "profil_redirect=142")]' + . '[not(contains(@src, "id_module/3"))]'; // see #121711 - return - [[$this->getPreferencesWith('mur'), - '//a[contains(@href, "id_profil/142")][contains(@href, "id_module/2-3")]'], + $record_href_xpath = '//a[contains(@href, "id_profil/142")][contains(@href, "id_module/2-3")]'; - [$this->getPreferencesWith('vignettes'), - '//a[contains(@href, "id_profil/142")][contains(@href, "id_module/2-3")]'], + return + [[$this->getPreferencesWith('mur'), $record_href_xpath], + [$this->getPreferencesWith('vignettes'), $record_href_xpath], + [$this->getPreferencesWith('simple_wall'), $record_href_xpath], [$this->getPreferencesWith('chrono'), '//script[contains(., "id_profil\\/142")][contains(., "id_module\\/2-3")]'], [$this->getPreferencesWith('slide_show'), - $iframe_xpath - . '[contains(@title, "Boite kiosque")]'], + $iframe_xpath . '[contains(@title, "Boite kiosque")]'], [$this->getPreferencesWith('protoflow'), $iframe_xpath], [$this->getPreferencesWith('cube'), $iframe_xpath], @@ -626,7 +627,7 @@ class ZendAfi_View_Helper_Accueil_KiosqueProfileRedirectTest extends ViewHelperT */ public function recordLinksShouldBeAsExpected($prefs, $xpath) { $this->_helper = new ZendAfi_View_Helper_Accueil_Kiosque(3, $prefs); - $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); + $this->_helper->setView($this->view); $this->_html = $this->_helper->getHtml()['CONTENU']; $this->assertXPath($this->_html, $xpath, $this->_html); @@ -634,6 +635,8 @@ class ZendAfi_View_Helper_Accueil_KiosqueProfileRedirectTest extends ViewHelperT } + + abstract class ZendAfi_View_Helper_Accueil_KiosqueWithDomainSetTestCase extends ViewHelperTestCase { public function setUp() { parent::setUp();