diff --git a/cosmogramme/sql/patch/patch_351.php b/cosmogramme/sql/patch/patch_351.php new file mode 100644 index 0000000000000000000000000000000000000000..538e8da86102a033db405f1726d3d5523f31e47a --- /dev/null +++ b/cosmogramme/sql/patch/patch_351.php @@ -0,0 +1,2 @@ +<?php +(new Class_Migration_DigitalResource_ToutApprendre())->run(); \ No newline at end of file diff --git a/library/Class/DigitalResource.php b/library/Class/DigitalResource.php index ff24075ae7b0828a30e4dc870efe4d3bb645ff65..defe972d8750e75fd7754bfcba6b1fb7bef30536 100644 --- a/library/Class/DigitalResource.php +++ b/library/Class/DigitalResource.php @@ -108,6 +108,15 @@ class Class_DigitalResource extends Class_Entity { } + public function getSsoActionForPlugin($name) { + return $this->getPlugins() + ->detect(function($config) use ($name) + { + return ($name == $config->getName()) ? $config->getSsoAction() : ''; + }); + } + + public function getPluginsDescription() { return $this->pluginsByName(function($config) { diff --git a/library/Class/Migration/DigitalResource/ToutApprendre.php b/library/Class/Migration/DigitalResource/ToutApprendre.php new file mode 100644 index 0000000000000000000000000000000000000000..791b760519e5a1d1fc1e13ce0983647d3007a0e8 --- /dev/null +++ b/library/Class/Migration/DigitalResource/ToutApprendre.php @@ -0,0 +1,50 @@ +<?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_Migration_DigitalResource_ToutApprendre extends Class_Migration_DigitalResource_Abstract { + + + protected function _getOldRightToken() { + return 6; + } + + + protected function _getAdminVarMapping() { + return ['TOUTAPPRENDRE_BIB_ID' => 'ToutApprendre_BIB_ID', + 'TOUTAPPRENDRE_KEY' => 'ToutApprendre_KEY']; + } + + + protected function _getConfig() { + return ToutApprendre_Config::getInstance(); + } + + + protected function _getOldMenuName() { + return 'TOUTAPPRENDRE'; + } + + + protected function _getOldBatchName() { + return 'MOISSONNAGE_TOUTAPPRENDRE'; + } +} \ No newline at end of file diff --git a/library/Class/Systeme/ModulesMenu/ToutApprendre.php b/library/Class/Systeme/ModulesMenu/ToutApprendre.php index 84038b6e36496dde0728a2e5250eacc309c7bfa5..c26a790cd2355a21a546847b82075f6ee7b952fa 100644 --- a/library/Class/Systeme/ModulesMenu/ToutApprendre.php +++ b/library/Class/Systeme/ModulesMenu/ToutApprendre.php @@ -34,9 +34,6 @@ class Class_Systeme_ModulesMenu_ToutApprendre extends Class_Systeme_ModulesMenu_ public function urlForUser($user) { - if (!$user->hasRightAccesToutApprendre()) - return ''; - return Class_ToutApprendreLink::forUser($user)->url(); } diff --git a/library/Class/UserGroup.php b/library/Class/UserGroup.php index 8607c8185ff8da6ec01c8c8ddd5be8b0dcebb79f..0f88f7d6038379c512bf7d75f45b0947a8a697df 100644 --- a/library/Class/UserGroup.php +++ b/library/Class/UserGroup.php @@ -136,7 +136,6 @@ class Class_UserGroup extends Storm_Model_Abstract { const RIGHT_ACCES_ARTEVOD = 2; const RIGHT_ACCES_NUMILOG = 3; const RIGHT_ACCES_VODECLIC = 5; - const RIGHT_ACCES_TOUTAPPRENDRE = 6; const RIGHT_ACCES_NUMERIQUEPREMIUM = 20; const RIGHT_ACCES_CYBERLIBRIS = 22; const RIGHT_ACCES_MYCOW = 24; @@ -179,7 +178,6 @@ class Class_UserGroup extends Storm_Model_Abstract { self::RIGHT_ACCES_NUMILOG => 'Bibliothèque numérique: accéder à Numilog', self::RIGHT_ACCES_CYBERLIBRIS => 'Bibliothèque numérique: accéder à Cyberlibris', self::RIGHT_ACCES_VODECLIC => 'Bibliothèque numérique: accéder à Vodéclic', - self::RIGHT_ACCES_TOUTAPPRENDRE => 'Bibliothèque numérique: accéder à Tout Apprendre', self::RIGHT_ACCES_NUMERIQUEPREMIUM => 'Bibliothèque numérique: accéder à Numérique Premium', self::RIGHT_ACCES_MYCOW => 'Bibliothèque numérique: accéder à MyCOW.EU', self::RIGHT_ACCES_PLANETNEMO => 'Bibliothèque numérique: accéder à planetnemo.fr', @@ -229,7 +227,6 @@ class Class_UserGroup extends Storm_Model_Abstract { 'ArteVod' => [Class_UserGroup::RIGHT_ACCES_ARTEVOD], 'Numilog' => [Class_UserGroup::RIGHT_ACCES_NUMILOG], 'Vodeclic' => [Class_UserGroup::RIGHT_ACCES_VODECLIC], - 'ToutApprendre' => [Class_UserGroup::RIGHT_ACCES_TOUTAPPRENDRE], 'NumeriquePremium' => [Class_UserGroup::RIGHT_ACCES_NUMERIQUEPREMIUM], 'MyCow' => [Class_UserGroup::RIGHT_ACCES_MYCOW], 'Kidilangues' => [Class_UserGroup::RIGHT_ACCES_KIDILANGUES], diff --git a/library/Class/Users.php b/library/Class/Users.php index 579dcf6c6814d97f3ec7f94a26b0ff392f29de5e..8ab61505e43f27e4cf86cc465e3549f23af37f6c 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -917,11 +917,6 @@ class Class_Users extends Storm_Model_Abstract { } - public function hasRightAccesToutApprendre() { - return $this->isAbonneAndHasRightToAccess(Class_UserGroup::RIGHT_ACCES_TOUTAPPRENDRE); - } - - public function hasRightAccessCyberlibris() { return $this->isAbonneAndHasRightToAccess(Class_UserGroup::RIGHT_ACCES_CYBERLIBRIS); } diff --git a/library/Class/WebService/BibNumerique/ToutApprendre.php b/library/Class/WebService/BibNumerique/ToutApprendre.php index 81542e0e19959a4f864edd85986333e7377f83a0..621492a5f970e726a23410b847e8abbfb2b59c22 100644 --- a/library/Class/WebService/BibNumerique/ToutApprendre.php +++ b/library/Class/WebService/BibNumerique/ToutApprendre.php @@ -94,6 +94,4 @@ class Class_WebService_BibNumerique_ToutApprendre extends Class_WebService_BibNu public function getName() { return 'Tout Apprendre'; } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/TagCoursToutApprendre.php b/library/ZendAfi/View/Helper/TagCoursToutApprendre.php index 3350176712c51d02fb81646168df1591f4b269d0..7088a0334a2c2fffcb4a9801921829883c5254cc 100644 --- a/library/ZendAfi/View/Helper/TagCoursToutApprendre.php +++ b/library/ZendAfi/View/Helper/TagCoursToutApprendre.php @@ -44,8 +44,6 @@ class ZendAfi_View_Helper_TagCoursToutApprendre extends ZendAfi_View_Helper_TagR function hasRightAccesRessourcesNumeriques($user) { - return $user->hasRightAccesToutApprendre(); + return true; } - -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/digital_resources/ToutApprendre/Batch.php b/library/digital_resources/ToutApprendre/Batch.php new file mode 100644 index 0000000000000000000000000000000000000000..08a8d1c58dc8785d9c163a029858b143390d8e7c --- /dev/null +++ b/library/digital_resources/ToutApprendre/Batch.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright (c) 2012-2018, 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 ToutApprendre_Batch extends Class_DigitalResource_Batch {} \ No newline at end of file diff --git a/library/digital_resources/ToutApprendre/Config.php b/library/digital_resources/ToutApprendre/Config.php new file mode 100644 index 0000000000000000000000000000000000000000..10295fc130940b5934f9c3db4eb7aa233a59d3b2 --- /dev/null +++ b/library/digital_resources/ToutApprendre/Config.php @@ -0,0 +1,70 @@ +<?php +/** + * Copyright (c) 2012-2017, 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 ToutApprendre_Config extends Class_DigitalResource_Config { + public function getConfig() { + return ['Introduction' => $this->_('ToutApprendre'), + 'HelpLink' => 'http://wiki.bokeh-library-portal.org/index.php/ToutApprendre', + 'Url' => '', + 'Icon' => '', + + 'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à la ressource ToutApprendre'), + 'NotAllowedMessage' => $this->_('Votre compte n\'est pas autorisé à accéder à cette ressource.'), + + 'SsoAction' => true, + + 'MenuLabel' => $this->_('Lien vers ToutApprendre'), + 'ModuleMenu' => $this->withNameSpace('ModuleMenu'), + + 'Service' => $this->withNameSpace('Service'), + 'Batch' => $this->withNameSpace('Batch'), + + 'DocTypeLabel' => $this->_('Cours en ligne Tout Apprendre'), + + 'AdminVars' => ['SSO_URL' => Class_AdminVar_Meta::newDefault($this->_('URL SSO de la plateforme ToutApprendre'), + ['value' => 'http://biblio.toutapprendre.com/ws/wsUrl.aspx'])->bePrivate(), + 'HARVEST_URL' => Class_AdminVar_Meta::newDefault($this->_('URL du catalogue de la plateforme ToutApprendre'), + ['value' => 'http://biblio.toutapprendre.com/cours/catalogue.aspx'])->bePrivate()] + ]; + } + + + public function isEnabled() { + return '' != $this->getAdminVar('SSO_URL'); + } + + + public function getSsoUrl($user) { + if(!$user) + return ''; + + return $this->getAdminVar('SSO_URL'); + } + + + public function getAlbumSsoUrl($user, $album) { + if(!$album) + return ''; + + return $this->getAdminVar('SSO_URL'); + } +} \ No newline at end of file diff --git a/library/digital_resources/ToutApprendre/ModuleMenu.php b/library/digital_resources/ToutApprendre/ModuleMenu.php new file mode 100644 index 0000000000000000000000000000000000000000..3002d4c9accbdfb41d33a2b39718624541cfad75 --- /dev/null +++ b/library/digital_resources/ToutApprendre/ModuleMenu.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright (c) 2012-2017, 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 ToutApprendre_ModuleMenu extends Class_DigitalResource_ModuleMenu {} \ No newline at end of file diff --git a/library/digital_resources/ToutApprendre/Service.php b/library/digital_resources/ToutApprendre/Service.php new file mode 100644 index 0000000000000000000000000000000000000000..5786adf3a4405389b2b571d35a56d5364eeff332 --- /dev/null +++ b/library/digital_resources/ToutApprendre/Service.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright (c) 2012-2018, 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 ToutApprendre_Service extends Class_DigitalResource_Service {} \ No newline at end of file diff --git a/library/digital_resources/ToutApprendre/Service/Album.php b/library/digital_resources/ToutApprendre/Service/Album.php new file mode 100644 index 0000000000000000000000000000000000000000..b28e238f5a77a679bd463cfd69753b0333e94295 --- /dev/null +++ b/library/digital_resources/ToutApprendre/Service/Album.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright (c) 2012-2018, 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 ToutApprendre_Service_Album extends Class_WebService_BibNumerique_RessourceNumerique { + + + public function getBaseUrl() { + return ToutApprendre_Config::getInstance()->getAdminVar('SSO_URL'); + } + + + protected function getTypeDoc() { + return ToutApprendre_Config::getInstance()->getDocType(); + } + + public function fillAlbum($album) { + $album + ->setTypeDocId($this->getTypeDoc()); + + return $this; + } + + + public function getRessourceCategorieLibelle() { + return ToutApprendre_Config::getInstance()->getDocTypeLabel(); + } +} \ No newline at end of file diff --git a/library/digital_resources/ToutApprendre/Service/Parser.php b/library/digital_resources/ToutApprendre/Service/Parser.php new file mode 100644 index 0000000000000000000000000000000000000000..cd4a026a36af06fd430994b0ac4d59a67344aea3 --- /dev/null +++ b/library/digital_resources/ToutApprendre/Service/Parser.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright (c) 2012-2018, 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 ToutApprendre_Service_Parser { + + protected + $_albums = [], + $_current_album; + + + public function parseXML($xml) { + $this->_parser = new Class_WebService_FasterXMLParser(); + $this->_parser->setElementHandler($this); + $this->_parser->parse($xml); + return $this; + } + + + public function startAlbum($attributes) { + $this->_current_album = new ToutApprendre_Service_Album(); + } + + + public function endAlbum() { + $this->_albums[] = $this->_current_album; + } + + + public function getAlbums() { + return $this->_albums; + } +} \ No newline at end of file diff --git a/library/digital_resources/ToutApprendre/View/Helper/Album.php b/library/digital_resources/ToutApprendre/View/Helper/Album.php new file mode 100644 index 0000000000000000000000000000000000000000..3381965f0c0d4533a5493d6574f92d5ec1b36704 --- /dev/null +++ b/library/digital_resources/ToutApprendre/View/Helper/Album.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright (c) 2012-2018, 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 ToutApprendre_View_Helper_Album extends Class_DigitalResource_AlbumViewHelper {} \ No newline at end of file diff --git a/library/digital_resources/ToutApprendre/controllers/IndexController.php b/library/digital_resources/ToutApprendre/controllers/IndexController.php new file mode 100644 index 0000000000000000000000000000000000000000..4c3b2100aeb20c597cd3952027b312bb25671308 --- /dev/null +++ b/library/digital_resources/ToutApprendre/controllers/IndexController.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright (c) 2012-2018, 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 ToutApprendre_Plugin_IndexController extends Class_DigitalResource_Controller {} \ No newline at end of file diff --git a/library/digital_resources/ToutApprendre/images/icon.png b/library/digital_resources/ToutApprendre/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..fa0a161f006f5f2adb42e80b53ae706d9975ddc3 Binary files /dev/null and b/library/digital_resources/ToutApprendre/images/icon.png differ diff --git a/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php b/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4fec32da70b9561b439a0f10610c65fe6931536e --- /dev/null +++ b/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php @@ -0,0 +1,162 @@ +<?php +/** + * Copyright (c) 2012-2018, 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 + */ + + +abstract class ToutApprendreActivatedTestCase extends AbstractControllerTestCase { + protected + $_storm_default_to_volatile = true, + $_user; + + public function setUp() { + parent::setUp(); + Class_AdminVar::set('ToutApprendre_SSO_URL', 'https://test.org/api/bokeh/login'); + + $group = $this->fixture('Class_UserGroup', + ['id' => 1, + 'libelle' => 'Digital resources']); + + $this->_user = $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'Tom', + 'password' => 'pwd']) + ->setUserGroups([$group]); + + $this->fixture('Class_Permission', + ['id' => 1, + 'code' => 'ToutApprendre']) + ->permitTo($group, new Class_Entity()); + } +} + + + +class ToutApprendreSsoTest extends ToutApprendreActivatedTestCase { + + public function setUp() { + parent::setUp(); + ZendAfi_Auth::getInstance()->logUser($this->_user); + $this->dispatch('/opac/modules/' . Class_DigitalResource::getSsoActionForPlugin('ToutApprendre'), true); + } + + + /** @test */ + public function shouldRedirectToResource() { + $this->assertXPathContentContains('//script' , 'document.location.href="PLACEHOLDER', $this->_response->getBody()); + } + + + /** @test */ + public function scriptShouldContainsCheckUrl() { + $this->assertXPathContentContains('//script[contains(text(), "&check_url=")]' , '/ToutApprendre_Plugin/auth/validate'); + } +} + + + + +class ToutApprendreDashboardUnactivatedTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + $this->dispatch('/ToutApprendre_Plugin', true); + } + + + /** @test */ + public function shouldDisplayDeactivated() { + $this->assertXPathContentContains('//button', 'Désactivé'); + } + + + /** @test */ + public function ssoUrlShoudlBeDisplay() { + $this->assertXPathContentContains('//table', 'ToutApprendre_SSO_URL'); + } +} + + + + +class ToutApprendreDashboardActivatedTest extends ToutApprendreActivatedTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + $album = $this->fixture('Class_Album', + ['id' => 20, + 'titre' => '10 moutons', + 'type_doc_id' => 'ToutApprendre' + ]); + + ZendAfi_Auth::getInstance()->logUser($this->fixture('Class_Users', + ['id' => 2, + 'login' => 'admin', + 'password' => 'admin', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN])); + $this->dispatch('/ToutApprendre_Plugin', true); + } + + + /** @test */ + public function shouldDisplayActivated() { + $this->assertXPathContentContains('//button', 'Activé'); + } + + + /** @test */ + public function urlSsoTitleBeDisplay() { + $this->assertXPathContentContains('//h4', 'URL SSO générée par /modules/story-play-r pour l\'utilisateur "ToutApprendre_test_user"'); + } + + + /** @test */ + public function testSsoValidateUrlMessageShoudlBeDisplay() { + $this->assertXPathContentContains('//h4', 'URL de validation du ticket de connexion générée pour l\'utilisateur "ToutApprendre_test_user"'); + } + + + /** @test */ + public function testSsoValidateUrlShoudlBeDisplay() { + $this->assertXPathContentContains('//pre', '/ToutApprendre_Plugin/auth/validate?sessionid=ST-'); + } + + + /** @test */ + public function sourceImageShouldBeValid() { + $this->assertXPathContentContains('//pre','Image source : https://preprod'); + } + + + /** @test */ + public function vignetteShouldBePresent() { + $this->assertXPath("//img[contains(@src,'userfiles/album/20/thumb_20_large_10Moutons.jpeg')]"); + } + + + /** @test */ + public function doctypeImageUrlShouldBePresent() { + $this->assertXPath('//h4/img[contains(@src, "/digital-resource/typedoc-icon/id/ToutApprendre")]'); + } +} diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php index 06bbc4e9fb786f4cc7cd579318a1d57b5ce429a6..9ed143f88163dd869acb5c214be316ddee2a1308 100644 --- a/tests/db/UpgradeDBTest.php +++ b/tests/db/UpgradeDBTest.php @@ -2165,4 +2165,14 @@ class UpgradeDB_350_Test extends UpgradeDBTestCase { public function fieldShouldBe($field, $type) { $this->assertFieldType('template_settings', $field, $type); } -} \ No newline at end of file +} + + + + +class UpgradeDB_351_Test extends UpgradeDBTestCase { + public function prepare() {} + + /** @test */ + public function placeholderForToutApprendreMigrationPatch() {} +} diff --git a/tests/library/Class/Migration/DigitalResource/ToutApprendreTest.php b/tests/library/Class/Migration/DigitalResource/ToutApprendreTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4a646a7585ff801478a9abb55aed129052f6d441 --- /dev/null +++ b/tests/library/Class/Migration/DigitalResource/ToutApprendreTest.php @@ -0,0 +1,156 @@ +<?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_Migration_DigitialResource_ToutApprendreTest extends ModelTestCase { + protected + $_storm_default_to_volatile = true, + $_migration; + + public function setUp() { + parent::setUp(); + Class_DigitalResource::resetInstance(); + + $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' => 'TOUTAPPRENDRE', + 'libelle' => 'Lien vers ToutApprendre', + 'preferences' => [], + 'picto' => 'vide.gif'] ]]]]]; + + $cfg_menus_without_toutapprendre = ['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' => ''] ]]]]]; + + + $profil_adulte = $this->fixture('Class_Profil', + ['id' => 22, + 'parent_id' => null]) + ->setBrowser('opac') + ->setLibelle('Profil Adulte') + ->setCfgMenus($cfg_menus); + + $profil_without_toutapprendre = $this->fixture('Class_Profil', + ['id' => 23, + 'rewrite_url' => 'adulte']) + ->setBrowser('opac') + ->setLibelle('Profil Adulte') + ->setCfgMenus($cfg_menus_without_toutapprendre); + + + Class_Profil::setCurrentProfil($profil_adulte); + + $this->fixture('Class_UserGroup', + ['id' => 2, + 'libelle' => 'team ONE', + 'rights_token' => pow(2, 6)]); + + $this->fixture('Class_AdminVar', + ['id' => 'TOUTAPPRENDRE_URL', + 'valeur' => 'http://mediathequefr.ToutApprendre.com/']); + + $this->fixture('Class_AdminVar', + ['id' => 'TOUTAPPRENDRE_BIB_ID', + 'valeur' => '2100']); + + $this->fixture('Class_AdminVar', + ['id' => 'TOUTAPPRENDRE_KEY', + 'valeur' => '1111']); + + $this->_migration = (new Class_Migration_DigitalResource_ToutApprendre()) + ->setMemoryCleaner(function(){}) + ->run(); + } + + + public function tearDown() { + Class_DigitalResource::resetInstance(); + parent::tearDown(); + } + + + /** @test */ + public function adminVarToutApprendreSsoUrlShoudBeCreated() { + $this->assertEquals('http://biblio.toutapprendre.com/ws/wsUrl.aspx', Class_AdminVar::getValueOrDefault('ToutApprendre_SSO_URL')); + } + + + /** @test */ + public function adminVarToutApprendreHarvestUrlShoudBeCreated() { + $this->assertEquals('http://biblio.toutapprendre.com/cours/catalogue.aspx', Class_AdminVar::getValueOrDefault('ToutApprendre_HARVEST_URL')); + } + + + /** @test */ + public function adminVarToutApprendreBibIdShoudBeUpdated() { + $this->assertNotNull(Class_AdminVar::findFirstBy(['clef' => 'ToutApprendre_BIB_ID', + 'valeur' => '2100'])); + } + + + /** @test */ + public function adminVarToutApprendreKeyShoudBeUpdated() { + $this->assertNotNull(Class_AdminVar::findFirstBy(['clef' => 'ToutApprendre_KEY', + 'valeur' => '1111'])); + } + + + /** @test */ + public function profilMenuWithAssimilShouldContainsToutApprendre() { + $this->assertEquals('ToutApprendre', Class_Profil::find(22)->getCfgMenusAsArray()['H']['menus'][0]['sous_menus'][1]['type_menu']); + } + + + /** @test */ + public function teamOneShouldHavePermissionOnToutApprendre() { + if (!$permissions = Class_UserGroup::find(2)->getPermissions()) + return $this->fail(); + $this->assertEquals('ToutApprendre', array_shift($permissions)->getCode()); + } + + + /** @test */ + public function teamOneRightsShouldBeCleaned() { + $this->assertEmpty(Class_UserGroup::find(2)->getRightsToken()); + } +} diff --git a/tests/library/Class/Systeme/ModulesMenu/ToutApprendreTest.php b/tests/library/Class/Systeme/ModulesMenu/ToutApprendreTest.php index dc1690d7b69a0da0e17033e869b80a902a60d238..d23fff9d43fe329eb2adcf598be5c8f63fbbb240 100644 --- a/tests/library/Class/Systeme/ModulesMenu/ToutApprendreTest.php +++ b/tests/library/Class/Systeme/ModulesMenu/ToutApprendreTest.php @@ -35,7 +35,7 @@ class Class_Systeme_ModulesMenu_ToutApprendreTest extends Storm_Test_ModelTestCa 'user_groups' => [$this->fixture('Class_UserGroup', [ 'id' => 20, 'libelle' => 'ToutApprendre' - ])->addRight(Class_UserGroup::RIGHT_ACCES_TOUTAPPRENDRE)] + ])] ])->beAbonneSIGB(); ZendAfi_Auth::getInstance()->logUser($this->user); Zend_Registry::get('translate')->setLocale('fr'); diff --git a/tests/library/ZendAfi/View/Helper/TagCoursToutApprendreTest.php b/tests/library/ZendAfi/View/Helper/TagCoursToutApprendreTest.php index 1e4fa14d6d30eca4a3cbdd1e2cd55a8b79fa8526..d56e03a5e112105352fcf56bb790d84f2b9ab1dc 100644 --- a/tests/library/ZendAfi/View/Helper/TagCoursToutApprendreTest.php +++ b/tests/library/ZendAfi/View/Helper/TagCoursToutApprendreTest.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once('ViewHelperTestCase.php'); @@ -53,11 +53,9 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase { ->answers([]); $this->group_multimedia = $this->fixture('Class_UserGroup', - ['id' => 20, - 'libelle' => 'Numerique']) - ->addRight(Class_UserGroup::RIGHT_ACCES_TOUTAPPRENDRE); + ['id' => 20, + 'libelle' => 'Numerique']); - $this->_album = Class_Album::getLoader() ->newInstanceWithId(33) ->setTitre('Petit cours d\'autodefense intellectuelle') @@ -66,7 +64,7 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase { ->newInstanceWithId('8') ->setIdOrigine('889') ->setTitre('Pourquoi étudier la pensée critique ?'), - + '1' => Class_AlbumRessource::getLoader() ->newInstanceWithId('9') ->setIdOrigine('890') @@ -76,9 +74,9 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase { ->newInstanceWithId('10') ->setIdOrigine('891') ->setTitre('Deux expériences de psychologie sociale'), - - + + ]); $view = new ZendAfi_Controller_Action_Helper_View(); $this->_helper = new ZendAfi_View_Helper_TagCoursToutApprendre(); @@ -92,8 +90,8 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase { ->setUserGroups([$this->group_multimedia]) ->setDateFin('2023-09-12') ->beAbonneSIGB(); - - $this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album), + + $this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album), '//a[contains(@href, "&pkl=891")][@target="_blank"]', 'psychologie sociale'); @@ -109,7 +107,7 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase { ->setDateFin('2003-09-12') ->beAbonneSIGB(); - $this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album), + $this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album), '//a[contains(@href, "&pkl=891")]'); } @@ -122,7 +120,7 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase { ->setDateFin('2023-09-12') ->beAbonneSIGB(); - $this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album), + $this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album), '//a[contains(@href, "&pkl=891")]'); } @@ -131,7 +129,7 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase { /** @test */ public function withCurrentUserNotAbonneShouldNotDisplayLinkToutApprendre() { $this->_normand->beInvite(); - $this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album), + $this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album), '//a[contains(@href, "&pkl=891")]'); } @@ -140,7 +138,7 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase { public function withCurrentUserNotAbonneToutApprendreShouldDisplayErrorMessage() { $this->_normand->beInvite(); - $this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album), + $this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album), '//p', 'abonnement valide'); } @@ -149,7 +147,7 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase { public function withNoCurrentUserForToutApprendreShouldDisplayErrorMessage() { ZendAfi_Auth::getInstance()->getStorage()->clear(); - $this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album), + $this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album), '//p', 'abonnement valide'); }