From ddd9530d3f3cbda093fc392cb8910cd743d2e426 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT <hdlaurent@afi-sa.fr> Date: Mon, 9 Nov 2020 16:25:11 +0100 Subject: [PATCH] hotline#121248 : Associated Identities should be displayed only when Identity Providers are enabled --- VERSIONS_HOTLINE/121248 | 1 + .../Helper/Abonne/AssociatedProviders.php | 11 ++++--- .../controllers/AbonneControllerFicheTest.php | 31 +++++++++++++++++-- 3 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 VERSIONS_HOTLINE/121248 diff --git a/VERSIONS_HOTLINE/121248 b/VERSIONS_HOTLINE/121248 new file mode 100644 index 00000000000..b3b5588c713 --- /dev/null +++ b/VERSIONS_HOTLINE/121248 @@ -0,0 +1 @@ + - ticket #121248 : Fiche Abonné : Le bouton mes comptes associés dans le compte lecteur ne s\'affiche que si IdentityProviders est Activé. \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Abonne/AssociatedProviders.php b/library/ZendAfi/View/Helper/Abonne/AssociatedProviders.php index fb1c237d1b1..edba9ed57d1 100644 --- a/library/ZendAfi/View/Helper/Abonne/AssociatedProviders.php +++ b/library/ZendAfi/View/Helper/Abonne/AssociatedProviders.php @@ -22,9 +22,12 @@ class ZendAfi_View_Helper_Abonne_AssociatedProviders extends ZendAfi_View_Helper_Abonne_Abstract { public function abonne_associatedProviders($user) { - return $this->tagFicheAbonne($this->_('Mes comptes associés'), - 'cards', - $this->view->url(['controller' => 'abonne', - 'action' => 'associated-providers'])); + return (Class_AdminVar::isIdentityProvidersEnabled() + && (Class_IdentityProvider::countBy(['active'=>true]) > 0)) + ? $this->tagFicheAbonne($this->_('Mes comptes associés'), + 'cards', + $this->view->url(['controller' => 'abonne', + 'action' => 'associated-providers'])) + :''; } } diff --git a/tests/application/modules/opac/controllers/AbonneControllerFicheTest.php b/tests/application/modules/opac/controllers/AbonneControllerFicheTest.php index 4256da733c9..87c845043e9 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerFicheTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerFicheTest.php @@ -191,6 +191,29 @@ class AbonneControllerFicheAsAdminDisableSuggestAndBookmarkableLibrariesTest ext + +class AbonneControllerFicheWithIdentityProvidersEnabledTest extends AbstractAbonneControllerFicheTest { + + public function setUp() { + parent::setUp(); + Class_AdminVar::set('ENABLE_IDENTITY_PROVIDERS', 1); + Class_IdentityProvider::newInstance(['label' => 'cassifié', + 'type' => 'cas2', + 'config' => '{"client_id":"ABCD";"client_secret":"EFGH"}', + 'active' => true])->assertSave(); + $this->dispatch('/abonne/fiche', true); + } + + + /** @test */ + public function linkToAssociatedProvidersShouldBePresent() { + $this->assertXPath('//a[contains(@href, "/abonne/associated-providers")]'); + } +} + + + + class AbonneControllerFicheActionWithLoggedUserTest extends AbstractAbonneControllerFicheTest { public function setUp() { parent::setUp(); @@ -210,9 +233,11 @@ class AbonneControllerFicheActionWithLoggedUserTest extends AbstractAbonneContro } - /** @test */ - public function mesComptesAssociesLinkShouldBePresent() { - $this->assertXPath('//div//a[contains(@href, "/abonne/associated-providers")]'); + /** @test + * cf https://forge.afi-sa.net/issues/121248 + */ + public function withIdentityProvidersDisabledmesComptesAssociesLinkShouldNotBePresent() { + $this->assertNotXPath('//div//a[contains(@href, "/abonne/associated-providers")]'); } } -- GitLab