From 0c2a1c45e10268f044c4288c22c8188ed6356bc6 Mon Sep 17 00:00:00 2001 From: Laurent Laffont <llaffont@afi-sa.fr> Date: Thu, 20 Jan 2022 11:12:07 +0100 Subject: [PATCH] hotline #149057 MT : in page, fix loading of parent settings for header --- VERSIONS_HOTLINE/149057 | 1 + .../templates/Intonation/System/Section.php | 11 ++- .../Intonation/System/Section/Header.php | 6 +- .../modules/AbstractControllerTestCase.php | 1 + .../TemplatesProfileWithPageTest.php | 69 +++++++++++++++++++ tests/scenarios/Templates/TemplatesTest.php | 2 +- 6 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 VERSIONS_HOTLINE/149057 create mode 100644 tests/scenarios/Templates/TemplatesProfileWithPageTest.php diff --git a/VERSIONS_HOTLINE/149057 b/VERSIONS_HOTLINE/149057 new file mode 100644 index 00000000000..a9c4001b416 --- /dev/null +++ b/VERSIONS_HOTLINE/149057 @@ -0,0 +1 @@ + - correctif #149057 : Magasin de thèmes : affichage de la bannière dans les pages : correction de la prise en compte des classes personnalisés sélectionnées dans le profil \ No newline at end of file diff --git a/library/templates/Intonation/System/Section.php b/library/templates/Intonation/System/Section.php index 28313e3e8fc..5d863d6c61f 100644 --- a/library/templates/Intonation/System/Section.php +++ b/library/templates/Intonation/System/Section.php @@ -21,16 +21,21 @@ class Intonation_System_Section extends Intonation_System_Abstract { - protected $_widgets_cache = []; - public function __construct($template) { + public function __construct(Class_Template $template) { parent::__construct($template); + $this->_loadSettings($template); + } + + + protected function _loadSettings(Class_Template $template) : self { $profile = $template->getProfile(); $this->setSettings($this->getSettingsInstance() ->setProfileId($profile->getId()) ->load()); + return $this; } @@ -98,4 +103,4 @@ class Intonation_System_Section extends Intonation_System_Abstract { $function_name = 'get' . Class_Template::current()->withNameSpace('display_mode'); return call_user_func([$this->_settings, $function_name]); } -} \ No newline at end of file +} diff --git a/library/templates/Intonation/System/Section/Header.php b/library/templates/Intonation/System/Section/Header.php index 7314c652cee..2c1c59e8b35 100644 --- a/library/templates/Intonation/System/Section/Header.php +++ b/library/templates/Intonation/System/Section/Header.php @@ -21,8 +21,7 @@ class Intonation_System_Section_Header extends Intonation_System_Section { - public function __construct($template) { - parent::__construct($template); + protected function _loadSettings(Class_Template $template) : self { $profile = Class_Profil::getCurrentProfil(); $profile_id = $profile->hasParentId() ? $profile->getParentId() @@ -31,6 +30,7 @@ class Intonation_System_Section_Header extends Intonation_System_Section { $this->setSettings($this->getSettingsInstance() ->setProfileId($profile_id) ->load()); + return $this; } @@ -49,4 +49,4 @@ class Intonation_System_Section_Header extends Intonation_System_Section { [Class_Template::current()->withNameSpace('width_xsmall') => 12, Class_Template::current()->withNameSpace('display_mode') => Intonation_Library_Constants::SECTION_DISPLAY_MODE_ROW]); } -} \ No newline at end of file +} diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php index 0a04c018fa6..3265e6631e5 100644 --- a/tests/application/modules/AbstractControllerTestCase.php +++ b/tests/application/modules/AbstractControllerTestCase.php @@ -159,6 +159,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe Class_Systeme_Report_Portal::setIp('0.0.0.0'); Class_Systeme_ModulesMenu::reset(); Class_AdminVar_Cookies::setManager(new Class_Cookies_Base()); + Class_Systeme_Widget_Abstract::reset(); } diff --git a/tests/scenarios/Templates/TemplatesProfileWithPageTest.php b/tests/scenarios/Templates/TemplatesProfileWithPageTest.php new file mode 100644 index 00000000000..99e407633cb --- /dev/null +++ b/tests/scenarios/Templates/TemplatesProfileWithPageTest.php @@ -0,0 +1,69 @@ +<?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 + */ + + +class TemplatesProfileWithPageTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + $profile = $this->_buildTemplateProfil(['id' => 1, + 'libelle' => 'Accueil', + 'rewrite_url' => 'home', + 'cfg_accueil' => + ['modules' => [ + '1' => ['division' => Class_Profil::DIV_BANNIERE, + 'type_module' => 'IMAGE', + 'preferences' => ['image' => 'wedontcare.jpg', + 'link' => '/home']]], + 'section' => [ + Class_Profil::DIV_BANNIERE => [ + 'boite' => ['black_and_white']]]]]); + $page = $this->fixture(Class_Profil::class, + ['id' => 2, + 'parent_id' => 1, + 'libelle' => 'agenda', + 'rewrite_url' => 'agenda']); + } + + + /** @test */ + public function homeProfileHeaderShouldHaveClassBlackAndWhite() { + $this->dispatch('/home'); + $this->assertXPathContentContains('//header/@class', 'black_and_white'); + } + + + /** @test */ + public function agendaPageHeaderShouldHaveParentClassBlackAndWhite() { + $this->dispatch('/agenda'); + $this->assertXPathContentContains('//header/@class', 'black_and_white'); + } + + + /** @test */ + public function agendaPageHeaderShouldContainsWidgetImageWithWeDontCareDotJPG() { + $this->dispatch('/agenda'); + $this->assertXPath('//header//div[contains(@class, "boite image")]//img[@src="' . Class_Url::absolute('wedontcare.jpg') . '"]'); + } +} diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index c5dbaf04fa0..82c69ee69de 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -317,7 +317,7 @@ abstract class TemplatesIntonationTestCase extends TemplatesEnabledTestCase { 'preferences' => ['layout' => Intonation_Library_Widget_Carousel_Menu_Definition::LAYOUT_VERTICAL]], ], - 'section' => [ '1' => ['boite' => ['ultra_light_widget']]] + 'section' => [ Class_Profil::DIV_FIRST_SIDE => ['boite' => ['ultra_light_widget']]] ]; $this->fixture('Class_AdminVar', -- GitLab