From 43fee89a6dbc1df5d55b285747958940418735ed Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Mon, 9 Jul 2018 12:23:40 +0200 Subject: [PATCH] hotline #77068 : remove old calls to orthodidacte + complete dashboard --- .../opac/controllers/ModulesController.php | 1 - library/Class/AdminVar.php | 5 - library/Class/Systeme/ModulesMenu.php | 1 - .../Systeme/ModulesMenu/Orthodidacte.php | 48 ------- library/Class/Users.php | 4 - .../LesYeuxDoc/tests/LesYeuxDocTest.php | 4 +- .../digital_resources/Orthodidacte/Config.php | 9 ++ .../Orthodidacte/ModuleMenu.php} | 12 +- .../Orthodidacte/tests/OrthodidacteTest.php | 118 +++++++++++++++--- .../controllers/ModulesControllerTest.php | 101 --------------- .../fixtures/RessourcesNumeriquesFixtures.php | 11 -- .../ZendAfi/View/Helper/Status/JsonTest.php | 11 -- 12 files changed, 116 insertions(+), 209 deletions(-) delete mode 100644 library/Class/Systeme/ModulesMenu/Orthodidacte.php rename library/{Class/Orthodidacte/Link.php => digital_resources/Orthodidacte/ModuleMenu.php} (74%) diff --git a/application/modules/opac/controllers/ModulesController.php b/application/modules/opac/controllers/ModulesController.php index 2721f83c50b..8f317a733b0 100644 --- a/application/modules/opac/controllers/ModulesController.php +++ b/application/modules/opac/controllers/ModulesController.php @@ -28,7 +28,6 @@ class ModulesController extends ZendAfi_Controller_Action { 'mycow' => 'MyCow', 'planetnemo' => 'PlanetNemo', 'kidilangues' => 'Kidilangues', - 'orthodidacte' => 'Orthodidacte', 'cite-de-la-musique' => 'CiteDeLaMusique', 'artevod' => 'ArteVOD', 'numilog' => 'Numilog']; diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index d83897747b5..1f6aa88f063 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -674,11 +674,6 @@ class Class_AdminVarLoader extends Storm_Model_Loader { } - public function isOrthodidacteEnabled() { - return ('' != Class_AdminVar::get('ORTHODIDACTE')); - } - - public function isNumeriquePremiumEnabled() { return '' != Class_AdminVar::get('NUMERIQUE_PREMIUM_URL'); } diff --git a/library/Class/Systeme/ModulesMenu.php b/library/Class/Systeme/ModulesMenu.php index 5b7b948635d..1392f667925 100644 --- a/library/Class/Systeme/ModulesMenu.php +++ b/library/Class/Systeme/ModulesMenu.php @@ -117,7 +117,6 @@ class Class_Systeme_ModulesMenu extends Class_Systeme_ModulesAbstract { "TOUTAPPRENDRE" => new Class_Systeme_ModulesMenu_ToutApprendre(), "NUMILOG" => new Class_Systeme_ModulesMenu_Numilog(), "ARTEVOD" => new Class_Systeme_ModulesMenu_ArteVOD(), - "ORTHODIDACTE" => new Class_Systeme_ModulesMenu_Orthodidacte(), "MYCOW" => new Class_Systeme_ModulesMenu_MyCow(), "PLANETNEMO" => new Class_Systeme_ModulesMenu_PlanetNemo(), "KIDLILANGUES" => new Class_Systeme_ModulesMenu_Kidilangues(), diff --git a/library/Class/Systeme/ModulesMenu/Orthodidacte.php b/library/Class/Systeme/ModulesMenu/Orthodidacte.php deleted file mode 100644 index 7d59a30627c..00000000000 --- a/library/Class/Systeme/ModulesMenu/Orthodidacte.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/** - * Copyright (c) 2012-2014, 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 Class_Systeme_ModulesMenu_Orthodidacte extends Class_Systeme_ModulesMenu_SSOAbstract { - - protected - $_group = Class_Systeme_ModulesMenu::GROUP_MENU_ABONNES, - $_type_module = 'ORTHODIDACTE', - $_url = ['controller' => 'modules', - 'action' => 'orthodidacte']; - - - public function __construct() { - parent::__construct(); - $this->_libelle = $this->_('Lien vers Orthodidacte'); - } - - - public function urlForUser($user) { - if (!$user->hasRightAccesOrthodidacte()) - return ''; - - return Class_Orthodidacte_Link::newFor($user); - } - - - public function isVisibleForProfil($profil) { - return Class_AdminVar::isOrthodidacteEnabled(); - } -} \ No newline at end of file diff --git a/library/Class/Users.php b/library/Class/Users.php index fd8c356f1b8..b189fd12b17 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -960,10 +960,6 @@ class Class_Users extends Storm_Model_Abstract { } - public function hasRightAccesOrthodidacte() { - return $this->isAbonneAndHasRightToAccess(Class_UserGroup::RIGHT_ACCESS_ORTHODIDACTE); - } - public function hasRightAccessLeSocial() { return $this->isAbonneAndHasRightToAccess(Class_UserGroup::RIGHT_ACCESS_LESOCIAL); } diff --git a/library/digital_resources/LesYeuxDoc/tests/LesYeuxDocTest.php b/library/digital_resources/LesYeuxDoc/tests/LesYeuxDocTest.php index 699b732a924..fbdd9410e3f 100644 --- a/library/digital_resources/LesYeuxDoc/tests/LesYeuxDocTest.php +++ b/library/digital_resources/LesYeuxDoc/tests/LesYeuxDocTest.php @@ -44,12 +44,12 @@ abstract class LesYeuxDocActivatedTestCase extends Admin_AbstractControllerTestC ['id' => 1, 'libelle' => 'Premier groupe']); - LesYeuxDoc_Config::getInstance()->getPermissions(); + $config = LesYeuxDoc_Config::getInstance(); $this->fixture('Class_UserGroup_Permission', ['id' => 1, 'id_group' => 1, - 'id_permission' => Class_Permission::findFirstBy(['code' => 'LesYeuxDoc'])->getId(), + 'id_permission' => $config->getPermission()->getId(), 'id_model' => null, 'model_class' => null ]); diff --git a/library/digital_resources/Orthodidacte/Config.php b/library/digital_resources/Orthodidacte/Config.php index 677eb31e407..b7635df058a 100644 --- a/library/digital_resources/Orthodidacte/Config.php +++ b/library/digital_resources/Orthodidacte/Config.php @@ -27,6 +27,10 @@ class Orthodidacte_Config extends Class_DigitalResource_Config { 'Url' => 'https://www.orthodidacte.com/', 'Icon' => 'http://bokeh-library-portal.org/userfiles/media/ressources_numeriques/logo_orthodidacte_pastille.png', + 'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à la ressource Orthodidacte'), + + 'NotAllowedMessage' => $this->_('Votre compte n\'est pas autorisé à accéder à cette ressource.'), + 'SsoAction' => true, 'MenuLabel' => $this->_('Lien vers Orthodidacte'), @@ -40,4 +44,9 @@ class Orthodidacte_Config extends Class_DigitalResource_Config { public function isEnabled() { return $this->getAdminVar('SSO_URL'); } + + + public function getSsoUrl($user, $album = null) { + return $this->getAdminVar('SSO_URL'); + } } \ No newline at end of file diff --git a/library/Class/Orthodidacte/Link.php b/library/digital_resources/Orthodidacte/ModuleMenu.php similarity index 74% rename from library/Class/Orthodidacte/Link.php rename to library/digital_resources/Orthodidacte/ModuleMenu.php index 2f4a1ac68ef..b4a340cfa9c 100644 --- a/library/Class/Orthodidacte/Link.php +++ b/library/digital_resources/Orthodidacte/ModuleMenu.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * Copyright (c) 2012, 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 @@ -19,12 +19,4 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -class Class_Orthodidacte_Link { - protected $_id, $_last_name, $_first_name, $_mail; - - public static function newFor($user) { - return Class_AdminVar::get('ORTHODIDACTE'); - } -} -?> \ No newline at end of file +class Orthodidacte_ModuleMenu extends Class_DigitalResource_ModuleMenu {} diff --git a/library/digital_resources/Orthodidacte/tests/OrthodidacteTest.php b/library/digital_resources/Orthodidacte/tests/OrthodidacteTest.php index b15d5b7ac31..6e0f75442de 100644 --- a/library/digital_resources/Orthodidacte/tests/OrthodidacteTest.php +++ b/library/digital_resources/Orthodidacte/tests/OrthodidacteTest.php @@ -20,21 +20,7 @@ */ -class OrthodicadteDashboardTest extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - - - /** @test */ - public function shouldBeActivated() { - Class_AdminVar::set('Orthodidacte_SSO_URL', 'https://www.orthodidacte.com/'); - $this->dispatch('/Orthodidacte_Plugin', true); - $this->assertXPathContentContains('//div', 'Activ'); - } -} - - - -class OrthodicadteMigrationTest extends ModelTestCase { +class OrthodidacteMigrationTest extends ModelTestCase { protected $_storm_default_to_volatile = true, $_migration; @@ -144,3 +130,105 @@ protected $this->assertEmpty(Class_UserGroup::find(2)->getRightsToken()); } } + + + +abstract class OrthodidacteActivatedTestCase extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + Class_AdminVar::set('Orthodidacte_SSO_URL', 'https://orthodidacte.com/'); + $user = $this->fixture('Class_Users', + ['id' => 56, + 'login' => 'Pierre', + 'password' => 'eCRTY']); + + $group = $this->fixture('Class_UserGroup', + ['id' => 1, + 'libelle' => 'Orthodidacte accès']) + ->addUser($user); + + Orthodidacte_Config::getInstance()->getPermission()->permitTo($group, + new Class_Entity()); + } +} + + + +class OrthodidacteDashboardTest extends OrthodidacteActivatedTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/Orthodidacte_Plugin', true); + } + + + /** @test */ + public function shouldBeActivated() { + $this->assertXPathContentContains('//div', 'Activ'); + } + + + /** @test */ + public function ssoLinkShouldBeOrthodidacteDotCom() { + $this->assertXPathContentContains('//pre', 'https://orthodidacte.com'); + } +} + + + + +class OrthodidacteModulesTest extends OrthodidacteActivatedTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/modules/orthodidacte', true); + } + + + /** @test */ + public function shouldRedirectToSsoUrl() { + $this->assertXPathContentContains('//script', 'document.location.href="https://orthodidacte.com/";'); + } +} + + + + +class OrthodidacteMenuTest extends OrthodidacteActivatedTestCase { + + public function setUp() { + parent::setUp(); + $cfg_menus = ['H' => ['libelle' => 'Menu horizontal', + 'picto' => 'vide.gif', + 'menus' => [['type_menu' => 'MENU', + 'libelle' => 'Pratique', + 'picto' => 'bookmark.png', + 'preferences' => [], + 'sous_menus' => [['type_menu' => 'ACCUEIL', + 'libelle' => 'Accueil', + 'picto' => 'vide.gif', + 'preferences' => [], + 'sous_menus' => ''], + + ['type_menu' => 'Orthodidacte', + 'libelle' => 'Lien vers Orthodidacte', + 'preferences' => [], + 'picto' => 'vide.gif'] ]]]]]; + + $profil_adulte = $this->fixture('Class_Profil', ['id' => 22, 'rewrite_url' => 'adulte']) + ->setBrowser('opac') + ->setLibelle('Profil Adulte') + ->setCfgMenus($cfg_menus); + + Class_Profil::setCurrentProfil($profil_adulte); + $this->dispatch('/'); + } + + + /** @test */ + public function linkToOrthodidacteShouldBePresent() { + $this->assertXPathContentContains('//ul//li//a[contains(@href, "/modules/orthodidacte")]', + 'Lien vers Orthodidacte'); + } +} diff --git a/tests/application/modules/opac/controllers/ModulesControllerTest.php b/tests/application/modules/opac/controllers/ModulesControllerTest.php index ba4a50104dc..f680b751476 100644 --- a/tests/application/modules/opac/controllers/ModulesControllerTest.php +++ b/tests/application/modules/opac/controllers/ModulesControllerTest.php @@ -204,107 +204,6 @@ class ModulesControllerNumeriquepremiumTest extends AbstractControllerTestCase { -class ModulesControllerLoginRequiredOrthodidacteTest extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - - /** @test */ - public function shouldRedirectToLogin() { - RessourcesNumeriquesFixtures::activateOrthodidacte(); - - $_SERVER['HTTP_REFERER'] = '/opac/cms/articleview/id/23'; - ZendAfi_Auth::getInstance()->clearIdentity(); - - $this->dispatch('/opac/modules/orthodidacte'); - - $this->assertContains('/auth/login?redirect='.urlencode(Class_Url::absolute('/modules/orthodidacte')), - $this->_response->getBody()); - } -} - - - -class ModulesControllerOrthodidacteUserWithoutGroupTest extends AbstractControllerTestCase { - public function setUp() { - parent::setUp(); - RessourcesNumeriquesFixtures::activateOrthodidacte(); - $this->dispatch('/opac/modules/orthodidacte', true); - } - - - /** @test */ - public function shouldHaveAccessForbiddenMessage() { - $this->assertFlashMessengerContentContains('Votre abonnement ne permet pas'); - } -} - - - -class ModulesControllerOrthodidacteUserWithGroupWithoutRightTest extends AbstractControllerTestCase { - public function setUp() { - parent::setUp(); - RessourcesNumeriquesFixtures::activateOrthodidacte(); - $group = $this->fixture('Class_UserGroup', ['id' => 1]); - Class_Users::getIdentity()->setUserGroups([$group]); - $this->dispatch('/opac/modules/orthodidacte', true); - } - - - /** @test */ - public function shouldHaveAccessForbiddenMessage() { - $this->assertFlashMessengerContentContains('Votre abonnement ne permet pas'); - } -} - - - -class ModulesControllerOrthodidacteUserWithGroupWithRightTest extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - - public function setUp() { - parent::setUp(); - - RessourcesNumeriquesFixtures::activateOrthodidacte(); - $group = $this->fixture('Class_UserGroup', ['id' => 1]) - ->addRight(Class_UserGroup::RIGHT_ACCESS_ORTHODIDACTE); - Class_Users::getIdentity()->setUserGroups([$group]); - - $this->dispatch('/opac/modules/orthodidacte', true); - } - - - /** @test */ - public function shouldHaveAccessToOrthodidacte() { - $this->assertContains('http://bibliotheque.orthodidacte.com/mediatheque-barcelonnette.cas', $this->_response->getBody()); - } -} - - - -class ModulesControllerOrthodidacteUserWithGroupWithRightCasTest extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - - public function setUp() { - parent::setUp(); - - RessourcesNumeriquesFixtures::activateOrthodidacte(); - $group = $this->fixture('Class_UserGroup', ['id' => 1]) - ->addRight(Class_UserGroup::RIGHT_ACCESS_ORTHODIDACTE); - Class_Users::getIdentity()->setUserGroups([$group]); - $_SERVER['HTTP_REFERER'] = 'http://localhost/view/notice'; - - $this->dispatch('/opac/modules/orthodidacte', true); - } - - - /** @test */ - public function shouldHaveAccessToOrthodidacte() { - $this->assertContains('http://bibliotheque.orthodidacte.com/mediatheque-barcelonnette.cas', - $this->_response->getBody()); - } -} - - - class ModulesControllerBibliondemandSsoTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; diff --git a/tests/fixtures/RessourcesNumeriquesFixtures.php b/tests/fixtures/RessourcesNumeriquesFixtures.php index 9a51b3569dc..3c3ee7a2190 100644 --- a/tests/fixtures/RessourcesNumeriquesFixtures.php +++ b/tests/fixtures/RessourcesNumeriquesFixtures.php @@ -35,7 +35,6 @@ class RessourcesNumeriquesFixtures { self::deactivateKidilangues(); self::deactivateJamendo(); self::deactivateDilicom(); - self::deactivateOrthodidacte(); self::deactivateLeSocial(); self::deactivateCiteDeLaMusique(); } @@ -57,7 +56,6 @@ class RessourcesNumeriquesFixtures { self::activateKidilangues(); self::activateJamendo(); self::activateDilicom(); - self::activateOrthodidacte(); self::activateLeSocial(); self::activateCiteDeLaMusique(); } @@ -247,15 +245,6 @@ class RessourcesNumeriquesFixtures { } - public static function activateOrthodidacte() { - Class_AdminVar::newInstanceWithId('ORTHODIDACTE', ['valeur' => 'http://bibliotheque.orthodidacte.com/mediatheque-barcelonnette.cas']); - } - - public static function deactivateOrthodidacte() { - Class_AdminVar::newInstanceWithId('ORTHODIDACTE', ['valeur' => '']); - } - - public static function activateLeSocial() { Class_AdminVar::newInstanceWithId('LESOCIAL_ID', ['valeur' => '50']); Class_AdminVar::newInstanceWithId('LESOCIAL_URL', ['valeur' => 'http://www.lesocial.fr']); diff --git a/tests/library/ZendAfi/View/Helper/Status/JsonTest.php b/tests/library/ZendAfi/View/Helper/Status/JsonTest.php index e8420c98a44..7e1c9db2df3 100644 --- a/tests/library/ZendAfi/View/Helper/Status/JsonTest.php +++ b/tests/library/ZendAfi/View/Helper/Status/JsonTest.php @@ -313,17 +313,6 @@ class ZendAfi_View_Helper_Status_JsonTest extends ZendAfi_View_Helper_Status_Tes } - /** @test */ - public function OrthodidacteShouldEnabled() { - $this->assertContains(["code" => "ORTHODIDACTE", - "label" => "Orthodidacte", - "enabled" => true, - "features" => ["CAS"], - ], - $this->_report['digital_connectors']); - } - - /** @test */ public function LeSocialShouldEnabled() { $this->assertContains(["code" => "LESOCIAL", -- GitLab