From cb2c446a4c92dc417d81431bb600adc0cd87214f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ANDRE=20s=C3=A9bastien?= <sandre@afi-sa.fr> Date: Thu, 30 Jun 2022 17:15:08 +0200 Subject: [PATCH] hotline : #159175 : not display current date id birth date is null --- VERSIONS_HOTLINE/159175 | 1 + .../Intonation/View/User/Informations.php | 5 +- .../Templates/TemplatesAbonneTest.php | 48 +++++++++++++++++-- 3 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 VERSIONS_HOTLINE/159175 diff --git a/VERSIONS_HOTLINE/159175 b/VERSIONS_HOTLINE/159175 new file mode 100644 index 00000000000..5a578d653ed --- /dev/null +++ b/VERSIONS_HOTLINE/159175 @@ -0,0 +1 @@ + - correctif #159175 : fiche Abonnés : Si la date de naissance n'est pas renseignée, ne plus afficher par défault la date du jour \ No newline at end of file diff --git a/library/templates/Intonation/View/User/Informations.php b/library/templates/Intonation/View/User/Informations.php index 9bb9e85fe0b..e26f050d6db 100644 --- a/library/templates/Intonation/View/User/Informations.php +++ b/library/templates/Intonation/View/User/Informations.php @@ -99,7 +99,10 @@ class Intonation_View_User_Informations extends ZendAfi_View_Helper_BaseHelper { $this->_('Numéro de téléphone') => $user->getTelephone(), $this->_('Numéro de téléphone mobile') => $user->getMobile(), - $this->_('Date de naissance') => (new DateTime($user->getNaissance()))->format($this->_('d / m / Y')), + $this->_('Date de naissance') => (($naissance = $user->getNaissance()) + ? (new DateTime($naissance)) + ->format($this->_('d / m / Y')) + : ''), $this->_('Numéro de carte') => $user->getIdabon(), $this->_('Bibliothèque') => $this->_getLibrary($user), diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index b84db6df7c3..88ac85cabb7 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -1462,16 +1462,58 @@ class TemplatesAbonneDispatchAccountTest extends TemplatesIntonationAccountTestC +/* hotline: https://forge.afi-sa.net/issues/159175 */ class TemplatesAbonneInformationsTest extends TemplatesIntonationAccountTestCase { + public function setUp() { parent::setUp(); + $this->dispatch('/opac/abonne/informations/id_profil/72'); } - /** @test */ - public function shouldDisplayPaulInDD() { - $this->assertXpathContentContains('//div//dd', 'Paul'); + public function fieldsWithContent() : array { + return [ + ['nom', 'Nom', 'AutoTest'], + ['pr_nom', 'Prénom', 'Zoro'], + ['pseudo', 'Pseudo', 'Paul'], + ['num_ro_de_carte', 'Numéro de carte', '123456'], + ]; + } + + + /** + * @test + * @dataProvider fieldsWithContent + */ + public function allFieldsShouldBeDisplayedWithContent($class_name, $name, $content) { + $classes = 'user_info ' . $class_name . ' col-12 col-sm-6'; + $this->assertXPath(sprintf('//dt[@class="%s"][text()="%s"]', $classes, $name)); + $this->assertXPath(sprintf('//dd[@class="%s"][text()="%s"]', $classes, $content)); + } + + + public function fieldsWithoutContent() : array { + return [ + ['adresse', 'Adresse'], + ['code_postal', 'Code postal'], + ['ville', 'Ville'], + ['courriel', 'Courriel'], + ['num_ro_de_t_lphone', 'Numéro de téléphone'], + ['num_ro_de_t_lphone_mobile', 'Numéro de téléphone mobile'], + ['date_de_naissance', 'Date de naissance'], + ]; + } + + + /** + * @test + * @dataProvider fieldsWithoutContent + */ + public function allFieldsShouldBeDisplayedWithoutContent($class_name, $name) { + $classes = 'user_info ' . $class_name . ' col-12 col-sm-6'; + $this->assertXPath(sprintf('//dt[@class="%s"][text()="%s"]', $classes, $name)); + $this->assertXPath(sprintf('//dd[@class="%s"][not(text())]', $classes)); } -- GitLab