diff --git a/Logo_biblioaccess.png b/Logo_biblioaccess.png new file mode 100644 index 0000000000000000000000000000000000000000..6e1818f2a1b0e37477c6a24e0b733087138e8ea3 Binary files /dev/null and b/Logo_biblioaccess.png differ diff --git a/UPGRADE.fr.md b/UPGRADE.fr.md index 1ce866e80e51c02d3a1d8df1b3c596b0c23a3382..11a9269d4b0eea1a4f7c088bc942f11d2c306a63 100644 --- a/UPGRADE.fr.md +++ b/UPGRADE.fr.md @@ -96,6 +96,8 @@ vous devez procéder à l'étape d'installation de chacune d'elle. - 8.0.152 - 15/02/2022 : cosmogramme/sql/patch/patch_426.php + - 8.0.157 - 21/04/2022 : cosmogramme/sql/patch/patch_429.php + ## Changement de structure HTML pouvant impacter votre charte graphique diff --git a/VERSIONS_HOTLINE/152147 b/VERSIONS_HOTLINE/152147 new file mode 100644 index 0000000000000000000000000000000000000000..8241f8266345a0a43f7185a85b2fd60b498e9328 --- /dev/null +++ b/VERSIONS_HOTLINE/152147 @@ -0,0 +1 @@ + - correctif #152147 : Connecteurs : Création du tableau de bord pour Numilog. \ No newline at end of file diff --git a/application/modules/admin/controllers/HarvestController.php b/application/modules/admin/controllers/HarvestController.php index 8469aacbc8f1d237bf6f1e3c2a877d3e337fc4c6..45e717e6d1dec3149a789c82a59f2fd515780dd4 100644 --- a/application/modules/admin/controllers/HarvestController.php +++ b/application/modules/admin/controllers/HarvestController.php @@ -64,7 +64,6 @@ class Admin_HarvestController extends ZendAfi_Controller_Action { protected function getServices() { return array_merge( ['vodeclic' => new Class_WebService_BibNumerique_Vodeclic(), - 'numilog' => new Class_WebService_BibNumerique_Numilog(), 'cyberlibris' => new Class_WebService_BibNumerique_Cyberlibris(), 'numerique-premium' => new Class_WebService_BibNumerique_NumeriquePremium(), 'orphea' => new Class_WebService_BibNumerique_Orphea(), diff --git a/application/modules/opac/controllers/ModulesController.php b/application/modules/opac/controllers/ModulesController.php index 87388946d57c26e7a025fc07709ac45991a4dbb4..ad986d9917bb5d5b17ab2de396fa6727bf3b8250 100644 --- a/application/modules/opac/controllers/ModulesController.php +++ b/application/modules/opac/controllers/ModulesController.php @@ -30,8 +30,7 @@ class ModulesController extends ZendAfi_Controller_Action { 'planetnemo' => 'PlanetNemo', 'kidilangues' => 'Kidilangues', 'cite-de-la-musique' => 'CiteDeLaMusique', - 'artevod' => 'ArteVOD', - 'numilog' => 'Numilog']; + 'artevod' => 'ArteVOD']; $action = $this->_request->getActionName(); diff --git a/cosmogramme/sql/patch/patch_429.php b/cosmogramme/sql/patch/patch_429.php new file mode 100644 index 0000000000000000000000000000000000000000..6c2024ee508130461e4253bacea87c38aa082983 --- /dev/null +++ b/cosmogramme/sql/patch/patch_429.php @@ -0,0 +1,2 @@ +<?php +(new Class_Migration_DigitalResource_Numilog)->run(); \ No newline at end of file diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index 565faaa66a1dbeae7dff39eb2b0a9247068e4b51..3a55802806bc63f821e57b944fea140ec0d15d15 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -202,11 +202,6 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'OAI_REPOSITORY' => Class_AdminVar_Meta::newOnOff($this->_('Activation de l\'import de dépôts OAI')), 'OPDS' => Class_AdminVar_Meta::newOnOff($this->_('Activation de l\'import de catalogues OPDS'))->enable(), 'SITO_IN_ALBUMS' => Class_AdminVar_Meta::newOnOff($this->_('Gérer la sitothèque dans la bibliothèque numérique, nécessite l\'activation de la bibliothèque numérique')), - - 'NUMILOG_URL' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage <a href="http://forge.afi-sa.fr/projects/opac3/wiki/Ressources_externes_enrichissements#Numilog">Numilog</a>'))->bePrivate(), - 'NUMILOG_OAI_URL' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage <a href="http://forge.afi-sa.fr/projects/opac3/wiki/Ressources_externes_enrichissements#Numilog">Numilog</a>'))->bePrivate(), - 'NUMILOG_OAI_IDBIB' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage <a href="http://forge.afi-sa.fr/projects/opac3/wiki/Ressources_externes_enrichissements#Numilog">Numilog</a>'))->bePrivate(), - 'CYBERLIBRIS_URL' => Class_AdminVar_Meta::newDefault($this->_('Adresse du serveur OAI Cyberlibris'))->bePrivate(), 'CYBERLIBRIS_ID' => Class_AdminVar_Meta::newDefault($this->_('Identifiant SSO Cyberlibris'))->bePrivate(), @@ -834,14 +829,6 @@ Pour vous désabonner de la lettre d\'information, merci de cliquer sur le lien } - /** - * @return bool - */ - public function isNumilogEnabled() { - return ('' != Class_AdminVar::get('NUMILOG_URL') ); - } - - /** * @return bool */ diff --git a/library/Class/Album.php b/library/Class/Album.php index a80d18ae9e853febe3be9ec82eeb5377595699b9..1eafb948f05ffec41121e7d92e145f3b53871a32 100644 --- a/library/Class/Album.php +++ b/library/Class/Album.php @@ -508,11 +508,6 @@ class Class_Album extends Storm_Model_Abstract { } - public function beNumilog() { - return $this->setTypeDocId(Class_TypeDoc::NUMILOG); - } - - public function beCyberlibris() { return $this->setTypeDocId(Class_TypeDoc::CYBERLIBRIS); } @@ -534,7 +529,7 @@ class Class_Album extends Storm_Model_Abstract { public function isNumilog() { - return $this->getTypeDocId() == Class_TypeDoc::NUMILOG; + return $this->getTypeDocId() == Numilog_Config::getInstance()->getDoctypeId(); } diff --git a/library/Class/Album/Renderer.php b/library/Class/Album/Renderer.php index 88bab6625e8ca90630b8a01a37ac5e027c7a4164..0fd78491ccf1ce7b3b7b90548a6a93223f3cdd74 100644 --- a/library/Class/Album/Renderer.php +++ b/library/Class/Album/Renderer.php @@ -33,7 +33,6 @@ class Class_Album_Renderer { return $html; $mapping = ['tagBooklet' => function($album) { return $album->isLivreNumerique(); }, - 'tagLivreNumerique' => function($album) { return $album->isNumilog(); }, 'tagCyberlibrisBook' => function($album) { return $album->isCyberlibris(); }, 'tagSlideshow' => function($album) { return $album->isDiaporama() && $album->hasOnlyImages(); }, 'album_OsmPlayer' => function($album) { return $album->isDiaporama(); }, diff --git a/library/Class/Batch.php b/library/Class/Batch.php index 7c4aa6b984df3dfd1f771e5e7c04e1dec38f0fc7..85002a63b41fed7faf92e72b8b378a9e105eb91f 100644 --- a/library/Class/Batch.php +++ b/library/Class/Batch.php @@ -53,7 +53,6 @@ class Class_BatchLoader extends Storm_Model_Loader { $core = [Class_Batch_Vodeclic::TYPE => new Class_Batch_Vodeclic(), Class_Batch_ArteVOD::TYPE => new Class_Batch_ArteVOD(), Class_Batch_NumeriquePremium::TYPE => new Class_Batch_NumeriquePremium(), - Class_Batch_Numilog::TYPE => new Class_Batch_Numilog(), Class_Batch_Cyberlibris::TYPE => new Class_Batch_Cyberlibris(), Class_Batch_Orphea::TYPE => new Class_Batch_Orphea(), Class_Batch_Jamendo::TYPE => new Class_Batch_Jamendo(), diff --git a/library/Class/DigitalResource.php b/library/Class/DigitalResource.php index 6832c9e2fc51e7ae0faf056f8677ccf613b221a1..dcb4f20f823f6fe7d861501fa0d1190c2abd187d 100644 --- a/library/Class/DigitalResource.php +++ b/library/Class/DigitalResource.php @@ -378,17 +378,22 @@ class Class_DigitalResource extends Class_Entity { } - public function isAdminVarOn($plugin, $name) { + public function isAdminVarOn(string $plugin, string $name) { return Class_AdminVar::isModuleEnabled($this->withNamespace($plugin, $name)); } - public function getAdminVar($plugin, $name) { + public function getAdminVar(string $plugin, string $name) { return Class_AdminVar::getValueOrDefault($this->withNamespace($plugin, $name)); } - public function getAdminVarInstance($plugin, $name) { + public function getAdminVarValue(string $plugin, string $name) { + return Class_AdminVar::get($this->withNamespace($plugin, $name)); + } + + + public function getAdminVarInstance(string $plugin, string $name) { return Class_AdminVar::find($this->withNamespace($plugin, $name)); } diff --git a/library/Class/DigitalResource/Config.php b/library/Class/DigitalResource/Config.php index 400946039522a5e2d34251c8b8aa4fae933bc3fa..0588e7e3a037f87124f60fb79d897cc958c1c738 100644 --- a/library/Class/DigitalResource/Config.php +++ b/library/Class/DigitalResource/Config.php @@ -21,19 +21,23 @@ class Class_DigitalResource_Config extends Class_Entity { + + use Trait_Translator, Trait_PermissionTargetable, Trait_TimeSource; + + const DIGITAL_RESOURCE = 'DigitalResource', HARVEST = 'HARVEST', SSO = 'SSO'; + protected $_name, $_digital_resource, $_admin_var_cache = [], + $_admin_var_values_cache = [], $_harvest_start_date; - use Trait_Translator, Trait_PermissionTargetable, Trait_TimeSource; - public static function getNameFor($class_name) { return (new Class_DigitalResource_Name())->getName($class_name); @@ -182,6 +186,13 @@ class Class_DigitalResource_Config extends Class_Entity { } + public function getAdminVarValue(string $id) { + return $this->_admin_var_values_cache[$id] = + ($this->_admin_var_values_cache[$id] + ?? $this->getDigitalResource()->getAdminVarValue($id)); + } + + public function getAdminVarsInstances() { Class_AdminVar::init(); $vars = []; @@ -384,11 +395,11 @@ class Class_DigitalResource_Config extends Class_Entity { public function getTypeDocImage($view) { return $view->tagImg($view->url(['module' => 'opac', - 'controller' => 'digital-resource', - 'action' => 'typedoc-icon', - 'id' => $this->getName()]), - ['class' => 'error', - 'alt' => $this->_('Aucune image')]); + 'controller' => 'digital-resource', + 'action' => 'typedoc-icon', + 'id' => $this->getName()]), + ['class' => 'error', + 'alt' => $this->_('Aucune image')]); } @@ -418,7 +429,7 @@ class Class_DigitalResource_Config extends Class_Entity { $group->save(); if (!$permission = $this->getPermission()) - return $group; + return $group; $permission->permitTo($group, new Class_Entity()); @@ -458,7 +469,7 @@ class Class_DigitalResource_Config extends Class_Entity { public function newOAIClient() { $parser_class = $this->withNameSpace('Service_Parser'); - return (new Class_WebService_OAI()) + return (new Class_WebService_OAI) ->setParser(new $parser_class) ->setOAIHandler($this->getAdminVar('Harvest_Url')) ->setNumericResourceClass($this->withNameSpace('Service_Album')); diff --git a/library/Class/Migration/DigitalResource/Numilog.php b/library/Class/Migration/DigitalResource/Numilog.php new file mode 100644 index 0000000000000000000000000000000000000000..3c35198cb43d45232e34f1c484809329b633cc05 --- /dev/null +++ b/library/Class/Migration/DigitalResource/Numilog.php @@ -0,0 +1,59 @@ +<?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 Class_Migration_DigitalResource_Numilog extends Class_Migration_DigitalResource_Abstract { + + + protected function _getOldDocTypeId() : string { + return '106'; + } + + + protected function _getOldSsoAction() : string { + return 'numilog'; + } + + + protected function _getOldRightToken() : int { + return 3; + } + + + protected function _getAdminVarMapping() : array { + return ['NUMILOG_OAI_IDBIB' => 'Numilog_KEY']; + } + + + protected function _getConfig() : Class_DigitalResource_Config { + return Numilog_Config::getInstance(); + } + + + protected function _getOldMenuName() : string { + return 'NUMILOG'; + } + + + protected function _getOldBatchName() : string { + return 'MOISSONNAGE_NUMILOG'; + } +} \ No newline at end of file diff --git a/library/Class/Systeme/ModulesMenu.php b/library/Class/Systeme/ModulesMenu.php index 5657a87786a985661a9d1386e4ecab58fa6d4a79..695cccd63ebb0dfd9b9aa9698f2780e04251e91e 100644 --- a/library/Class/Systeme/ModulesMenu.php +++ b/library/Class/Systeme/ModulesMenu.php @@ -66,7 +66,6 @@ class Class_Systeme_ModulesMenu extends Class_Systeme_ModulesAbstract { 'ABON_ACTIVITIES' => Class_Systeme_ModulesMenu_AbonneActivities::class, 'FORM_CONTACT' => Class_Systeme_ModulesMenu_FormulaireContact::class, 'VODECLIC' => Class_Systeme_ModulesMenu_Vodeclic::class, - 'NUMILOG' => Class_Systeme_ModulesMenu_Numilog::class, 'ARTEVOD' => Class_Systeme_ModulesMenu_ArteVOD::class, 'MYCOW' => Class_Systeme_ModulesMenu_MyCow::class, 'PLANETNEMO' => Class_Systeme_ModulesMenu_PlanetNemo::class, diff --git a/library/Class/TypeDoc.php b/library/Class/TypeDoc.php index 29329722718b2b6ba8f1c488dab6cd63611d2e42..1f1508157bfaf8dc88fe45a7d0d550caab6e7dbe 100644 --- a/library/Class/TypeDoc.php +++ b/library/Class/TypeDoc.php @@ -335,7 +335,6 @@ class Class_TypeDoc extends Storm_Model_Abstract { OAI = 103, ARTEVOD = 104, VODECLIC = 105, - NUMILOG = 106, AUDIO_RECORD = 109, NUMERIQUEPREMIUM = 110, CYBERLIBRIS = 111, @@ -371,7 +370,6 @@ class Class_TypeDoc extends Storm_Model_Abstract { self::OAI => 'OAI', self::ARTEVOD => 'Arte VOD', self::VODECLIC => 'Formation Vodeclic', - self::NUMILOG => 'Livres numériques', self::AUDIO_RECORD => 'Enregistrement audio', self::NUMERIQUEPREMIUM => 'Numérique Premium', self::CYBERLIBRIS => 'Cyberlibris', @@ -524,7 +522,7 @@ class Class_TypeDoc extends Storm_Model_Abstract { public function isLegacyDigitalResource() { - return in_array($this->getId(), [static::ARTEVOD, static::VODECLIC, static::NUMILOG, + return in_array($this->getId(), [static::ARTEVOD, static::VODECLIC, static::NUMERIQUEPREMIUM, static::CYBERLIBRIS, static::DILICOM, static::ORPHEA, static::JAMENDO, static::SOUNDCLOUD, static::CITEDELAMUSIQUE]); diff --git a/library/Class/UserGroup.php b/library/Class/UserGroup.php index 62747bd255560e7d28158e4e29f6af5417b56dd4..7159a671b462903cf56160249b06247f8688d896 100644 --- a/library/Class/UserGroup.php +++ b/library/Class/UserGroup.php @@ -213,7 +213,6 @@ class Class_UserGroup extends Storm_Model_Abstract { const RIGHT_SUIVRE_ACTIVITY = 0; const RIGHT_DIRIGER_ACTIVITY = 1; const RIGHT_ACCES_ARTEVOD = 2; - const RIGHT_ACCES_NUMILOG = 3; const RIGHT_ACCES_VODECLIC = 5; const RIGHT_ACCES_NUMERIQUEPREMIUM = 20; const RIGHT_ACCES_CYBERLIBRIS = 22; @@ -277,7 +276,6 @@ class Class_UserGroup extends Storm_Model_Abstract { static::RIGHT_GERER_LETTRESINFO => $t->_('Lettres d\'informations : gérer les lettres d\'informations'), static::RIGHT_EDITER_BIB => $t->_('Bibliothèques : Modifier les fiches bibliothèques et les lieux'), static::RIGHT_ACCES_ARTEVOD => $t->_('Bibliothèque numérique: accéder à ARTE VOD'), - static::RIGHT_ACCES_NUMILOG => $t->_('Bibliothèque numérique: accéder à Numilog'), static::RIGHT_ACCES_CYBERLIBRIS => $t->_('Bibliothèque numérique: accéder à Cyberlibris'), static::RIGHT_ACCES_VODECLIC => $t->_('Bibliothèque numérique: accéder à Vodéclic'), static::RIGHT_ACCES_NUMERIQUEPREMIUM => $t->_('Bibliothèque numérique: accéder à Numérique Premium'), @@ -316,7 +314,6 @@ class Class_UserGroup extends Storm_Model_Abstract { $mapping = ['Activity' => [static::RIGHT_SUIVRE_ACTIVITY, static::RIGHT_DIRIGER_ACTIVITY], 'ArteVod' => [static::RIGHT_ACCES_ARTEVOD], - 'Numilog' => [static::RIGHT_ACCES_NUMILOG], 'Vodeclic' => [static::RIGHT_ACCES_VODECLIC], 'NumeriquePremium' => [static::RIGHT_ACCES_NUMERIQUEPREMIUM], 'MyCow' => [static::RIGHT_ACCES_MYCOW], diff --git a/library/Class/Users.php b/library/Class/Users.php index f916cefb7abce135a8bf2395c7f4f76d9db4df8c..4e576d855440857273f526f25cbb4d603c58a5f7 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -992,11 +992,6 @@ class Class_Users extends Storm_Model_Abstract { } - public function hasRightAccesNumilog() { - return $this->hasRightToAccess(Class_UserGroup::RIGHT_ACCES_NUMILOG); - } - - public function hasRightAccesVodeclic() { return $this->hasRightToAccess(Class_UserGroup::RIGHT_ACCES_VODECLIC); } diff --git a/library/Class/WebService/BibNumerique/Numilog.php b/library/Class/WebService/BibNumerique/Numilog.php deleted file mode 100644 index a5ca1d15baa0d40742680132e5d9d504c80c6268..0000000000000000000000000000000000000000 --- a/library/Class/WebService/BibNumerique/Numilog.php +++ /dev/null @@ -1,107 +0,0 @@ -<?php -/** - * 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 - * 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_WebService_BibNumerique_Numilog extends Class_WebService_BibNumerique_Abstract { - const SESSION_NAMESPACE = 'NUMILOG'; - - protected static $_harvested_ids_cache; - protected $_albums; - - const BASE_URL = 'http://oai.numilog.com/oai.ashx'; - const RESSOURCES = 'ressources'; - const AUTHORS = 'authors'; - const ACTORS = 'actors'; - - const CATEGORY_LABEL = 'Numilog'; - - /** - * @param $ressources array - * @return array of harvested ids - */ - protected function _importRessources($ressources) { - - $harvestedIds = []; - $this->_albums = []; - foreach ($ressources as $ressource) { - if ($ressource->isDeleted()) { - continue; - } - $harvestedIds[] = $ressource->getId(); - if ($ressource->isAlreadyHarvested()) - continue; - if ($album = $ressource->import()) - $this->_albums[] = $album; - } - - return $harvestedIds; - } - - - protected function _deleteNonHarvested() { - if (0 < count($this->getHarvestedIds())) - Class_Album::getLoader() - ->deleteBy(['where' => 'url_origine="'.self::BASE_URL.'" and id_origine not in (\'' . implode("', '", $this->getHarvestedIds()) . '\')']); - } - - - public function loadPage($page_number = 1) { - $reader = $this->getRessourcesNumeriquesReader()->parse(); - if (1 == $page_number) - $this->getLogger()->info($reader->getTotalCount() .' ressources dans la base'); - return $reader; - } - - - public function open_authenticated_url($url) { - $ticket = md5(Zend_Session::getId()); - $queries = []; - $queries['ticket'] = $ticket; - $http_client = self::getHttpClient(); - - return $http_client->open_url('http://'.$url.'?'.http_build_query($queries)); - } - - - public function getRessourcesNumeriquesReader() { - return new Class_WebService_BibNumerique_Numilog_LivresNumeriquesReader(); - } - - - public function getBaseUrl() { - return self::BASE_URL; - } - - - public function getAlbums() { - return $this->_albums; - } - - - public function isEnabled() { - return Class_AdminVar::isNumilogEnabled(); - } - - - public function getName() { - return 'Numilog'; - } -} -?> \ No newline at end of file diff --git a/library/Class/WebService/BibNumerique/Numilog/LivresNumeriquesReader.php b/library/Class/WebService/BibNumerique/Numilog/LivresNumeriquesReader.php deleted file mode 100644 index c625288b5453a42a990866738d6daaf9e993991d..0000000000000000000000000000000000000000 --- a/library/Class/WebService/BibNumerique/Numilog/LivresNumeriquesReader.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php -/** - * 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 - * 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_WebService_BibNumerique_Numilog_LivresNumeriquesReader extends Class_WebService_OAI { - protected $_xml_parser; - protected $_total_count; - protected $_page_number; - protected $_page_size; - protected $_resumptionToken; - protected $_ressourcesNumeriques; - protected $livres; - - - public function parse() { - $this->_total_count = $this->_page_number = 0; - $this->_page_size = 1; - - $this->livres = $this - ->setOAIHandler(Class_AdminVar::get('NUMILOG_OAI_URL')) - ->setNumericResourceClass('Class_WebService_BibNumerique_Numilog_LivreNumerique') - ->getRecordsFromSetNumericResources('bib:'.Class_AdminVar::get('NUMILOG_OAI_IDBIB')); - - while ($this->hasNextRecords()) - $this->livres = array_merge($this->livres, $this->getNextNumericResources()); - - $this->_total_count = sizeof($this->livres); - $this->_page_number=1; - $this->_page_size=$this->_total_count; - return $this; - } - - - public function getTotalCount() { - return $this->_total_count; - } - - - public function getPageNumber() { - return $this->_page_number; - } - - - public function getPageCount() { - return ceil($this->_total_count / $this->_page_size); - } - - - public function getRessourcesNumeriques() { - return $this->livres; - } -} diff --git a/library/Class/WebService/OAI.php b/library/Class/WebService/OAI.php index 352e00ce3a2ff467c0192ef7c94289419b513be8..8349eeb288e2ecdd3907ec7ee1abd89a84c93787 100644 --- a/library/Class/WebService/OAI.php +++ b/library/Class/WebService/OAI.php @@ -46,7 +46,7 @@ class Class_WebService_OAI extends Class_WebService_Abstract { protected - $_numeric_resource_class = 'Class_WebService_BibNumerique_Numilog_LivreNumerique', + $_numeric_resource_class = Class_WebService_BibNumerique_RessourceNumerique::class, $_listRecordsResumptionToken, $_oai_handler, $_metadata_prefix = 'oai_dc', @@ -147,6 +147,12 @@ class Class_WebService_OAI extends Class_WebService_Abstract { } + public function setDefaultSet(string $set) : self { + $this->_default_set = $set; + return $this; + } + + public function setNumericResourceClass($classname) { $this->_numeric_resource_class = $classname; return $this; diff --git a/library/Class/WebService/OAI/DublinCoreParser/ForRessourceNumerique.php b/library/Class/WebService/OAI/DublinCoreParser/ForRessourceNumerique.php index e3d564287b2f12109c569f8b61db323b269c4dfd..c8751f77017730da52ade0737cb9e4121bbe3fd0 100644 --- a/library/Class/WebService/OAI/DublinCoreParser/ForRessourceNumerique.php +++ b/library/Class/WebService/OAI/DublinCoreParser/ForRessourceNumerique.php @@ -79,14 +79,15 @@ class Class_WebService_OAI_DublinCoreParser_ForRessourceNumerique ? $this->_record['description'][0] : ''; - $resource = $this->getRessourceNumerique() - ->setOaiId($this->_record['id_oai']) - ->setTitle($this->_record['titre']) - ->setEditeur($first_editor) - ->setYear(substr($this->_record['date'], 0, 4)) - ->setDescription($first_description) - ->setRights($this->_record['rights']) - ->setDeleted(isset($this->_record['deleted']) ? $this->_record['deleted']: false ); + $resource = $this + ->getRessourceNumerique() + ->setOaiId($this->_record['id_oai']) + ->setTitle($this->_record['titre']) + ->setEditeur($first_editor) + ->setYear(substr($this->_record['date'], 0, 4)) + ->setDescription($first_description) + ->setRights($this->_record['rights']) + ->setDeleted(isset($this->_record['deleted']) ? $this->_record['deleted']: false ); foreach($this->_record['auteur'] as $author) $resource->addAuthor($author); diff --git a/library/ZendAfi/Acl/AdminControllerGroup.php b/library/ZendAfi/Acl/AdminControllerGroup.php index 6e1e338bdb431d7d0ff7f857ea87063c078d61a3..4dd2d77d440737fad51874f3a33781630dc52cee 100644 --- a/library/ZendAfi/Acl/AdminControllerGroup.php +++ b/library/ZendAfi/Acl/AdminControllerGroup.php @@ -100,7 +100,6 @@ class ZendAfi_Acl_AdminControllerGroup { 'harvest/vodeclic-browse' => Class_AdminVar::isVodeclicEnabled(), 'harvest/orphea-browse' => Class_AdminVar::isOrpheaEnabled(), 'harvest/numerique-premium-browse' => Class_AdminVar::isNumeriquePremiumEnabled(), - 'harvest/numilog-browse' => Class_AdminVar::isNumilogEnabled(), 'harvest/jamendo-browse' => Class_AdminVar::isJamendoEnabled(), 'harvest/soundcloud' => Class_AdminVar::isSoundCloudEnabled(), 'sito/create' => Class_AdminVar::isSitoInAlbums(), diff --git a/library/Class/WebService/BibNumerique/Numilog/LivreNumerique.php b/library/digital_resources/Numilog/Batch.php similarity index 55% rename from library/Class/WebService/BibNumerique/Numilog/LivreNumerique.php rename to library/digital_resources/Numilog/Batch.php index 5fcb36acb5f5f5632f061325d42a7a758a80067a..602b4383e060b0bd8bd575f479f195ce6a88e80e 100644 --- a/library/Class/WebService/BibNumerique/Numilog/LivreNumerique.php +++ b/library/digital_resources/Numilog/Batch.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * 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 @@ -19,27 +19,5 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class Class_WebService_BibNumerique_Numilog_LivreNumerique extends Class_WebService_BibNumerique_RessourceNumerique { - protected $_record; - protected $_titre; - - public function getBaseUrl(){ - return Class_WebService_BibNumerique_Numilog::BASE_URL; - } - - - public function fillAlbum($album) { - $album->beNumilog(); - - $this->addPoster('http://couverture.numilog.com/' . $this->_id.'_GRANDE.jpg'); - return $album; - } - - - public function getRessourceCategorieLibelle() { - return Class_WebService_BibNumerique_Numilog::CATEGORY_LABEL; - } -} - -?> \ No newline at end of file +class Numilog_Batch extends Class_DigitalResource_Batch {} diff --git a/library/Class/NumilogLink.php b/library/digital_resources/Numilog/CasLink.php similarity index 53% rename from library/Class/NumilogLink.php rename to library/digital_resources/Numilog/CasLink.php index 4eb44792a094ffc512057aae00da3e32f73ba53a..c3bc16eacb692ac2104d8d3e64fd37c99f09f942 100644 --- a/library/Class/NumilogLink.php +++ b/library/digital_resources/Numilog/CasLink.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * 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 @@ -19,53 +19,37 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class Class_NumilogLink { - use Trait_TimeSource; - protected $_user; +class Numilog_CasLink { - public static function forUser($user) { - return new self($user); - } + protected $_user; - public function __construct($user) { + public function __construct(Class_Users $user) { $this->_user = $user; } - public static function staticLink() { - return 'opac/modules/numilog'; - } - - - public function getBaseUrl() { - return Class_AdminVar::get('NUMILOG_URL'); - } - - - public function getTicket() { - return (new Class_CasTicket())->getTicketForUser($this->_user); - } - - - public function urlExternal($url_external) { - return $this->_injectTicketInto($url_external); + public function getSsoUrl(string $url = '') : string { + return $this->_injectTicketInto($url ? $url : $this->_getBaseUrl()); } - public function url() { - return $this->_injectTicketInto($this->getBaseUrl()); + protected function _getBaseUrl() : string { + return Numilog_Config::getInstance()->getAdminVar('SSO_URL') + . Numilog_Config::getInstance()->getAdminVar('KEY'); } - protected function _injectTicketInto($url) { - if (!$this->_user) - return $url; - + protected function _injectTicketInto(string $url) : string { return $url . (false !== strpos($url, '?') ? '&' : '?') - . 'ticket=' . $this->getTicket() + . 'ticket=' . $this->_getTicket() ; } + + + protected function _getTicket() : string { + return (new Class_CasTicket)->getTicketForUser($this->_user); + } } diff --git a/library/digital_resources/Numilog/Config.php b/library/digital_resources/Numilog/Config.php new file mode 100644 index 0000000000000000000000000000000000000000..fd1e23470696d630be14b2c97f44f1c53ff44cbe --- /dev/null +++ b/library/digital_resources/Numilog/Config.php @@ -0,0 +1,93 @@ +<?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 Numilog_Config extends Class_DigitalResource_Config { + + protected function _getConfig() { + return ['Introduction' => $this->_('Numilog'), + 'HelpLink' => 'https://forge.afi-sa.fr/projects/opac3/wiki/Ressources_externes_enrichissements#Numilog', + 'Url' => 'https://www.numilog.fr/', + 'Icon' => 'https://www.numilog.com/App_Themes/Numilog2017/Images/Entetes/LogoNumilog3.png', + + 'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à la ressource Numilog'), + 'NotAllowedMessage' => $this->_('Votre compte n\'est pas autorisé à accéder à cette ressource.'), + + 'SsoAction' => true, + + 'MenuLabel' => $this->_('Lien vers Numilog'), + 'ModuleMenu' => $this->withNameSpace('ModuleMenu'), + + 'Service' => $this->withNameSpace('Service'), + 'Batch' => $this->withNameSpace('Batch'), + + 'DocTypeLabel' => $this->_('Livres numériques'), + + 'AdminVars' => + ['SSO_URL' => + Class_AdminVar_Meta::newDefault($this->_('URL SSO de la plateforme Numilog'), + ['value' => 'https://www.biblioaccess.com/'])->bePrivate(), + 'HARVEST_URL' => + Class_AdminVar_Meta::newDefault($this->_('URL OAI du catalogue de la plateforme Numilog'), + ['value' => 'http://oai.numilog.com/oai.ashx'])->bePrivate(), + 'KEY' => + Class_AdminVar_Meta::newDefault($this->_('Identifiant Numilog'), + ['value' => ''])->bePrivate(), + 'THUMBNAIL_URL' => + Class_AdminVar_Meta::newDefault($this->_('URL de récupération des vignettes'), + ['value' => 'https://couverture.numilog.com/%s_GRANDE.jpg'])->bePrivate()] + ]; + } + + + public function isEnabled() { + return trim($this->getAdminVarValue('KEY')) + && trim($this->getAdminVarValue('SSO_URL')) + && trim($this->getAdminVarValue('HARVEST_URL')) + && trim($this->getAdminVarValue('THUMBNAIL_URL')); + } + + + public function getSsoUrl(Class_Users $user) : string { + return (new Numilog_CasLink($user))->getSsoUrl(); + } + + + public function getAlbumSsoUrl(Class_Users $user, Class_Album $album) : string { + return ($url = trim($album->getExternalUri())) + ? (new Numilog_CasLink($user))->getSsoUrl($url) + : ''; + } + + + public function getHarvestUrl(int $page = 1) : string { + return 1 === $page + ? $this->newOAIClient()->getRecordsUrl() + : ''; + } + + + public function newOAIClient() { + return parent::newOAIClient() + ->setOAIHandler($this->getAdminVar('HARVEST_URL')) + ->setDefaultSet('bib:' . $this->getAdminVar('KEY')); + } +} diff --git a/library/digital_resources/Numilog/ModuleMenu.php b/library/digital_resources/Numilog/ModuleMenu.php new file mode 100644 index 0000000000000000000000000000000000000000..ae5c1a77e8db05c0c6e9147465d83105573c5ad2 --- /dev/null +++ b/library/digital_resources/Numilog/ModuleMenu.php @@ -0,0 +1,23 @@ +<?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 Numilog_ModuleMenu extends Class_DigitalResource_ModuleMenu {} diff --git a/library/Class/Batch/Numilog.php b/library/digital_resources/Numilog/Service.php similarity index 75% rename from library/Class/Batch/Numilog.php rename to library/digital_resources/Numilog/Service.php index 232529d1be2d4ee6e4bc601e7f4e88bc75f74ed9..d2696073a9981491997bc8c6eda29aeebb354ab9 100644 --- a/library/Class/Batch/Numilog.php +++ b/library/digital_resources/Numilog/Service.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * 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 @@ -20,11 +20,4 @@ */ -class Class_Batch_Numilog extends Class_Batch_RessourceNumerique{ - const TYPE = 'MOISSONNAGE_NUMILOG'; - - protected function _getService() { - return new Class_WebService_BibNumerique_Numilog(); - } -} -?> \ No newline at end of file +class Numilog_Service extends Class_DigitalResource_ServiceOAI {} diff --git a/library/Class/Systeme/ModulesMenu/Numilog.php b/library/digital_resources/Numilog/Service/Album.php similarity index 52% rename from library/Class/Systeme/ModulesMenu/Numilog.php rename to library/digital_resources/Numilog/Service/Album.php index 3c7bb8abcb03cc62099580b4295f6ec8de1b35c0..6aa56eca152b3edebd5f119590eb7c23f0032ec4 100644 --- a/library/Class/Systeme/ModulesMenu/Numilog.php +++ b/library/digital_resources/Numilog/Service/Album.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * 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 @@ -19,29 +19,25 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class Class_Systeme_ModulesMenu_Numilog extends Class_Systeme_ModulesMenu_SSOAbstract { - protected - $_group = Class_Systeme_ModulesMenu::GROUP_MENU_ABONNES, - $_type_module = 'NUMILOG', - $_url = ['controller' => 'modules', - 'action' => 'numilog']; +class Numilog_Service_Album extends Class_WebService_BibNumerique_RessourceNumerique { - public function __construct() { - parent::__construct(); - $this->_libelle = $this->_('Lien vers Numilog'); + public function getBaseUrl() : string { + return Numilog_Config::getInstance()->getAdminVar('HARVEST_URL'); } - public function urlForUser($user) { - if ($user && $user->hasRightAccesNumilog()) - return Class_NumilogLink::forUser($user)->url(); - return ''; + public function fillAlbum(Class_Album $album) : self { + $album->setTypeDocId(Numilog_Config::getInstance()->getDocType()); + + return $this + ->addPoster(sprintf(Numilog_Config::getInstance()->getAdminVar('THUMBNAIL_URL'), + $this->_id)); } - public function isVisibleForProfil($profil) { - return Class_AdminVar::isNumilogEnabled(); + public function getRessourceCategorieLibelle() : string { + return Numilog_Config::getInstance()->getName(); } -} \ No newline at end of file +} diff --git a/library/digital_resources/Numilog/Service/Parser.php b/library/digital_resources/Numilog/Service/Parser.php new file mode 100644 index 0000000000000000000000000000000000000000..1264e0a088da06e1ce05bcc1f21caf96d652b377 --- /dev/null +++ b/library/digital_resources/Numilog/Service/Parser.php @@ -0,0 +1,23 @@ +<?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 Numilog_Service_Parser extends Class_WebService_OAI_DublinCoreParser_ForRessourceNumerique {} diff --git a/library/digital_resources/Numilog/View/Helper/Album.php b/library/digital_resources/Numilog/View/Helper/Album.php new file mode 100644 index 0000000000000000000000000000000000000000..c28c1167342af299f0f25f6054d2f2b10e71d26d --- /dev/null +++ b/library/digital_resources/Numilog/View/Helper/Album.php @@ -0,0 +1,23 @@ +<?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 Numilog_View_Helper_Album extends Class_DigitalResource_AlbumViewHelper {} diff --git a/library/digital_resources/Numilog/controllers/IndexController.php b/library/digital_resources/Numilog/controllers/IndexController.php new file mode 100644 index 0000000000000000000000000000000000000000..a80220000bd38f4b4ba5ef0b9e76205006e032e6 --- /dev/null +++ b/library/digital_resources/Numilog/controllers/IndexController.php @@ -0,0 +1,23 @@ +<?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 Numilog_Plugin_IndexController extends Class_DigitalResource_Controller {} diff --git a/library/digital_resources/Numilog/images/icon.png b/library/digital_resources/Numilog/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..6e1818f2a1b0e37477c6a24e0b733087138e8ea3 Binary files /dev/null and b/library/digital_resources/Numilog/images/icon.png differ diff --git a/library/digital_resources/Numilog/tests/NumilogTest.php b/library/digital_resources/Numilog/tests/NumilogTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9bb4bca03908cdb15fa0b9c7af114294435fdc0e --- /dev/null +++ b/library/digital_resources/Numilog/tests/NumilogTest.php @@ -0,0 +1,570 @@ +<?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 + */ + + +abstract class NumilogActivatedTestCase extends AbstractControllerTestCase { + + + protected + $_storm_default_to_volatile = true, + $_user; + + + public function setUp() { + parent::setUp(); + + Class_AdminVar::set('Numilog_KEY', '44'); + Class_AdminVar::set('Numilog_HARVEST_URL', + Class_AdminVar::getValueOrDefault('Numilog_HARVEST_URL')); + Class_AdminVar::set('Numilog_SSO_URL', + Class_AdminVar::getValueOrDefault('Numilog_SSO_URL')); + Class_AdminVar::set('Numilog_THUMBNAIL_URL', + Class_AdminVar::getValueOrDefault('Numilog_THUMBNAIL_URL')); + + $group = + $this->fixture(Class_UserGroup::class, + ['id' => 1, + 'libelle' => 'Digital resources']); + + $this->_user = + $this->fixture(Class_Users::class, + ['id' => 1, + 'login' => 'Tom', + 'password' => 'pwd']) + ->setUserGroups([$group]); + + $this->fixture(Class_Permission::class, + ['id' => 1, + 'code' => 'Numilog']) + ->permitTo($group, new Class_Entity); + } +} + + + + +class NumilogSsoTest extends NumilogActivatedTestCase { + + public function setUp() { + parent::setUp(); + ZendAfi_Auth::getInstance()->logUser($this->_user); + $this->dispatch('/opac/modules/' + . Class_DigitalResource::getInstance()->getSsoActionForPlugin('Numilog')); + } + + + /** @test */ + public function shouldRedirectToResource() { + $this->assertXPathContentContains('//script', + 'document.location.href="https://www.biblioaccess.com/44?ticket='); + } +} + + + + +class NumilogDashboardUnactivatedTest extends Admin_AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + $this->dispatch('/Numilog_Plugin'); + } + + + /** @test */ + public function shouldDisplayDeactivated() { + $this->assertXPathContentContains('//button', 'Désactivé'); + } + + + /** @test */ + public function ssoUrlShoudlBeDisplay() { + $this->assertXPathContentContains('//table', 'Numilog_SSO_URL'); + } +} + + + + +class NumilogDashboardActivatedTest extends NumilogActivatedTestCase { + + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + $album = $this + ->fixture(Class_Album::class, + ['id' => 20, + 'titre' => '10 moutons', + 'type_doc_id' => 'Numilog' + ]) + ->addPosterURI('https://couverture.numilog.com/9782715254244_GRANDE.jpg'); + + ZendAfi_Auth::getInstance() + ->logUser($this->fixture(Class_Users::class, + ['id' => 2, + 'login' => 'admin', + 'password' => 'admin', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN])); + + $this->dispatch('/Numilog_Plugin'); + } + + + /** @test */ + public function shouldDisplayActivated() { + $this->assertXPathContentContains('//button', 'Activé'); + } + + + /** @test */ + public function urlSsoTitleBeDisplay() { + $this->assertXPathContentContains('//h4', + 'URL SSO générée par /modules/' + . (Class_DigitalResource::getInstance() + ->getSsoActionForPlugin('Numilog')) + . ' pour l\'utilisateur "Numilog_test_user"'); + } + + + /** @test */ + public function oneAlbumShouldBePresent() { + $this->assertXPathContentContains('//h4', 'Nombre d\'albums présents dans Bokeh : 1'); + } + + + /** @test */ + public function sourceImageShouldBeCouvertureNumilog() { + $this->assertXPathContentContains('//pre', + 'Image source : https://couverture.numilog.com/9782715254244_GRANDE.jpg'); + } + + + /** @test */ + public function vignetteShouldBePresent() { + $this->assertXPath("//img[contains(@src,'/userfiles/album/20/thumb_20_e73a29d2e0b39d22ded8dcaabf2b0fb6.jpeg')]"); + } + + + /** @test */ + public function doctypeImageUrlShouldBePresent() { + $this->assertXPath('//h4/img[contains(@src, "/digital-resource/typedoc-icon/id/Numilog")]'); + } + + + /** @test */ + public function adminVarNumilogThumbUrlBeCreated() { + $this->assertNotNull(Class_AdminVar::findFirstBy(['clef' => 'Numilog_THUMBNAIL_URL', + 'valeur' => 'https://couverture.numilog.com/%s_GRANDE.jpg'])); + } +} + + + + +class NumilogWithAbonTest extends NumilogActivatedTestCase { + protected $_link; + + public function setUp() { + parent::setUp(); + + Class_AdminVar::set('Numilog_SSO_URL', 'https://urlnumilog/action/'); + + $jerry = + $this->fixture(Class_Users::class, + ['id' => 4, + 'idabon' => 34, + 'login' => 34, + 'password' => 'secret', + 'prenom' => 'Jerry', + 'nom' => 'Khan', + 'mail' => 'feu@essence.fr', + 'date_fin' => '2023-09-02']) + ->setUserGroups([Class_UserGroup::find(1)]); + + ZendAfi_Auth::getInstance()->logUser($jerry); + + $mon_livre_en_epub = + $this->fixture(Class_Album::class, + ['id' => 123, + 'titre' => 'Les fourmies']) + ->setExternalUri('https://url-given-bynumilog?withparam=2'); + } + + + protected function _ticketForSession() { + return 'ST-' . md5( Zend_Session::getId() . '4'); + } + + + /** @test */ + public function ssoUrlForJerryShouldReturnUrlWithKeyAndTicket() { + $this->assertEquals('https://urlnumilog/action/44?ticket=' . $this->_ticketForSession(), + Numilog_Config::getInstance()->urlFor(Class_Users::find(4))); + } + + + /** @test */ + public function ssoUrlForJerryWithUrlGivenByNumilogShouldReturnGivenUrlWithTicket() { + $this->assertEquals('https://url-given-bynumilog?withparam=2&ticket=' . $this->_ticketForSession(), + Numilog_Config::getInstance()->urlFor(Class_Users::find(4), + ['album_id' => 123], + 'http://url-given-bynumilog?withparam=2')); + } +} + + + + +class NumilogHavestingTest extends NumilogActivatedTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/batch'); + } + + + /** @test */ + public function numilogBatchShouldBePresent() { + $this->assertXPathContentContains('//td', + 'Moissonner catalogue Numilog'); + } +} + + + + +abstract class AbstractNumilogCatalogueTest extends NumilogActivatedTestCase { + + protected $_first_album, + $_second_album, + $_third_album; + + + public function setUp() { + parent::setUp(); + + $this->fixture(Class_CosmoVar::class, + ['id' => 'types_docs', + 'liste' => '']); + + $catalogue_end_xml = file_get_contents(realpath(dirname(__FILE__)). '/numilog_end.xml'); + + $http_client = $this + ->mock() + + ->whenCalled('open_url') + ->with('http://oai.numilog.com/oai.ashx?verb=ListRecords&metadataPrefix=oai_dc&set=bib%3A44') + ->answers($this->_getXml()) + + ->whenCalled('open_url') + ->with('http://oai.numilog.com/oai.ashx?verb=ListRecords&resumptionToken=769701498%21500%21oai_dc%21bib%3A44%21') + ->answers($catalogue_end_xml) + + ->beStrict(); + + Class_WebService_Abstract::setHttpClient($http_client); + + $codif_type_doc = + $this->fixture(Class_CodifTypeDoc::class, + ['id' => 'Numilog', + 'famille_id' => Class_CodifTypeDoc::INCONNU, + 'bibliotheques' => '1;8', + 'annexes' => '10;12', + 'sections' => '18;19']); + + $this->fixture(Class_TypeDoc::class, + ['id' => 'Numilog', + 'codif_type_doc' => $codif_type_doc, + 'label'=> 'Livres numériques']); + + $this->fixture(Class_CodifMatiere::class, + ['id' => '132', + 'libelle'=>'Management', + 'code_alpha' => 'MANAGEMENT']); + + $this->fixture(Class_CodifMatiere::class, + ['id' => '133', + 'libelle'=> 'Métiers et Formations', + 'code_alpha' => 'METIERS ET FORMATIONS']); + + $this->fixture(Class_CodifMatiere::class, + ['id' => '134', + 'libelle'=>'Psychologie', + 'code_alpha' => 'PSYCHOLOGIE']); + + $this->onLoaderOfModel(Class_Album::class) + ->whenCalled('deleteBy') + ->answers(true); + + Numilog_Config::getInstance() + ->getBatchInstance() + ->run(); + + $this->_first_album = Class_Album::find(1); + $this->_second_album = Class_Album::find(2); + $this->_third_album = Class_Album::find(3); + } + + + public function tearDown() { + Class_WebService_Abstract::setHttpClient(null); + parent::tearDown(); + } + + + protected function _getXml() { + return file_get_contents(realpath(dirname(__FILE__)) . '/numilog_catalogue.xml'); + } +} + + + + +class NumilogCatalogueTest extends AbstractNumilogCatalogueTest { + + + /** @test */ + public function secondNumilogLivresTitreShouldBeChroniquesDeNewYork() { + $this->assertEquals("Chroniques de New York", $this->_second_album->getTitre()); + } + + + /** @test */ + public function numberfLivresShouldBe75OnFirstPage() { + $this->assertEquals(74, count(Class_Album::findAllBy(['type_doc_id' => 'Numilog']))); + } + + + /** @test */ + public function firstAlbumIdOrigineShouldBe9782246804383() { + $this->assertEquals('9782246804383', $this->_first_album->getIdOrigine()); + } + + +/** @test */ + public function firstAlbumUrlOrigineShouldBeOaiNumilogDotCom() { + $this->assertEquals('http://oai.numilog.com/oai.ashx', + $this->_first_album->getUrlOrigine()); + } + + + /** @test */ + public function firstAlbumExternalURIShouldBeSet() { + $this->assertEquals('http://www.numilog.com/bibliotheque/BM-Enghien-les-Bains/fiche_livre.asp?idprod=330541',$this->_first_album->getExternalUri()); + } + + + /** @test */ + public function firstAlbumDescriptionShouldBeSet() { + + $this->assertEquals("<p align='justify'>Une île privée des Seychelles. Tatiana, « bécasse sentimentale », rencontre Philip, un garçon bien de sa personne ; ils sont beaux, elle est riche, ils s'aiment et décident de se marier. Leur histoire a tout du conte de fées, oui... mais celui-ci est écrit par Saphia Azzeddine, experte en démolitions.<br/>Des plages de sable fin aux coulisses du mariage, de Los Angeles à Paris, et de la meilleure copine à la femme de ménage, chaque personnage prend la parole, comme un chœur de pleureuses, et décrit ce couple en chemin vers l'autel. Sur la scène mondaine, les acteurs de cet univers d'ultra-riches et d'égoïstes liftés s'affrontent et s'esquivent dans une satire sociale aussi drôle que cruelle.</p>",$this->_first_album->getDescription()); + } + + + /** @test */ + public function thirdAlbumDescriptionShouldBeSet() { + $this->assertContains("<h4>Stressé, harcelé, \"burnouté\" ?",$this->_third_album->getDescription()); + + } + + + /** @test */ + public function thirdAlbumShouldBeValid() { + $this->assertTrue($this->_third_album->isValid(),implode(',',$this->_third_album->getErrors())); + + } + + + /** @test */ + public function thirdAlbumShouldHaveMatierePsychologie() { + $this->assertEquals('134;133;132',$this->_third_album->getMatiere()); + } + + + /** @test */ + public function thirdAlbumShouldBeSaved() { + $this->assertNotNull(Class_Album::findFirstBy(['titre' => 'Stress et burnout au travail'])); + } + + + /** @test */ + public function firstAlbumIdLangueShouldBeFre() { + $this->assertEquals('fre',$this->_first_album->getIdLangue()); + } + + + /** @test */ + public function firstAlbumAnneeShouldBe2013 (){ + $this->assertEquals('2013',$this->_first_album->getAnnee()); + } + + + /** @test */ + public function firstAlbumAuteurShouldBeAzzedine (){ + $this->assertContains('Saphia Azzeddine', $this->_first_album->getAuthorsNames()); + } + + + /** @test */ + public function firstAlbumAuteurShouldBeEditeur (){ + $this->assertEquals(['Grasset'], $this->_first_album->getEditors()); + } + + + /** @test */ + public function firstAlbumTypeDocShouldBeLivresNumeriques() { + $this->assertEquals('Livres numériques', + $this->_first_album->getTypeDoc()->getLabel()); + } + + + /** @test */ + public function firstAlbumCategorieShouldBeNumilog() { + $this->assertEquals('Numilog', + $this->_first_album->getCategorie()->getLibelle()); + } + + + /** @test */ + public function lastAlbumShouldBeGuideDeLaMaisonEconome() { + $this->assertEquals(['Eyrolles'], + Class_Album::findFirstBy(['titre' => 'Guide de la maison économe']) + ->getEditors()); + } + + + /** @test */ + public function posterShouldBeURIJacketURL(){ + $this->assertEquals('https://couverture.numilog.com/9782246804383_GRANDE.jpg', + $this->_first_album->getPoster()); + } + + + + /** @test */ + public function bibliothequeShouldBeImportedInFirstAlbum() { + $this->assertEquals('1;8', + $this->_first_album->getBibliotheques()); + } + + + /** @test */ + public function annexesShouldBeImportedInSecondAlbum() { + $this->assertEquals('10;12', + $this->_second_album->getAnnexes()); + } + + + /** @test */ + public function sectionsShouldBeImportedInThirdAlbum() { + $this->assertEquals('18;19', + $this->_third_album->getSections()); + } +} + + + + +class NumilogDeletedTest extends AbstractNumilogCatalogueTest { + + + protected function _getXml() { + return file_get_contents(realpath(dirname(__FILE__)). '/numilog_with_deleted.xml'); + } + + + /** @test */ + public function firstAlbumIdOrigineShouldBeDeleted() { + $this->assertNotEquals('9782246804383', $this->_first_album->getIdOrigine()); + } + + + /** @test */ + public function numberfBookImportedShouldBe4() { + $this->assertEquals(4, count(Class_Album::findAll())); + } +} + + + + +class NumilogAlbumDeletingTest extends ModelTestCase { + + public function setUp() { + parent::setUp(); + + $this->fixture(Class_Album::class, + ['id' => 12066, + 'notice_id' => 3255060, + 'type_doc_id' => 'Numilog', + 'titre' => 'Le chemin de l\'esperance']); + + $this->fixture(Class_Notice::class, + ['id' => 3255060, + 'id_notice' => 3255060, + 'alpha_titre' => 'CHEMIN DE L ESPERANCE']); + + + Class_Album::find(12066)->delete(); + } + + + /** @test */ + public function albumChemindeLesperanceShouldBedeleted() { + $this->assertNull(Class_Album::find(12066)); + } + + + /** @test */ + public function deletingAlbumChemindeLesperanceShouldDeleteItsRecord() { + $this->assertNull(Class_Notice::find(3255060)); + } +} + + + + +class NumilogModulesControllerTest extends NumilogActivatedTestCase { + + + /** @test */ + public function shouldRedirectToAuthLogin() { + ZendAfi_Auth::getInstance()->clearIdentity(); + $this->dispatch('/opac/modules/numilog'); + $this->assertRedirectContains('/auth/login?redirect='); + } + + + /** @test */ + public function shouldRedirectToNumilog() { + ZendAfi_Auth::getInstance()->logUser($this->_user); + $this->dispatch('/opac/modules/numilog'); + $this->assertXpathContentContains('//script', + 'document.location.href="https://www.biblioaccess.com/44?ticket=ST-', + $this->_response->getBody()); + } +} \ No newline at end of file diff --git a/tests/fixtures/numilog_catalogue.xml b/library/digital_resources/Numilog/tests/numilog_catalogue.xml similarity index 100% rename from tests/fixtures/numilog_catalogue.xml rename to library/digital_resources/Numilog/tests/numilog_catalogue.xml diff --git a/tests/fixtures/numilog_end.xml b/library/digital_resources/Numilog/tests/numilog_end.xml similarity index 100% rename from tests/fixtures/numilog_end.xml rename to library/digital_resources/Numilog/tests/numilog_end.xml diff --git a/tests/fixtures/numilog_with_deleted.xml b/library/digital_resources/Numilog/tests/numilog_with_deleted.xml similarity index 100% rename from tests/fixtures/numilog_with_deleted.xml rename to library/digital_resources/Numilog/tests/numilog_with_deleted.xml diff --git a/library/requires.php b/library/requires.php index 4761f3aff65ad035cc52c67e699faeb99554642e..9018425bfc70d85bf88109e5ed4e14dd85db83c2 100644 --- a/library/requires.php +++ b/library/requires.php @@ -124,7 +124,6 @@ require_once(ROOT_PATH.'library/ZendAfi/View/Helper/FonctionsAdmin.php'); require_once(ROOT_PATH.'library/Class/Systeme/ModulesMenu.php'); require_once(ROOT_PATH.'library/Class/Systeme/ModulesMenu/Sitotheque.php'); require_once(ROOT_PATH.'library/Class/Systeme/ModulesMenu/Rss.php'); -require_once(ROOT_PATH.'library/Class/Systeme/ModulesMenu/Numilog.php'); require_once(ROOT_PATH.'library/Class/Systeme/ModulesMenu/News.php'); require_once(ROOT_PATH.'library/Class/Systeme/ModulesMenu/LastNews.php'); require_once(ROOT_PATH.'library/Class/Systeme/ModulesMenu/Catalogue.php'); diff --git a/public/admin/skins/bokeh72/config.json b/public/admin/skins/bokeh72/config.json index ae5627df50a2e180fe39ab24d4c0983d175adac4..349f76a2b77a3187a0f926341979833d4b6a9553 100644 --- a/public/admin/skins/bokeh72/config.json +++ b/public/admin/skins/bokeh72/config.json @@ -18,7 +18,6 @@ "vodeclic": "../../images/picto/vodeclic_16.png", "orphea": "../../images/picto/orphea_16.png", "numeriquepremium": "../../images/picto/numeriquepremium_16.png", - "numilog": "../../images/picto/oai_16.png", "toutapprendre": "../../images/picto/oai_16.png", "oai": "../../images/picto/oai_16.png", "jamendo": "../../images/picto/jamendo_16.png", diff --git a/public/admin/skins/bokeh74/config.json b/public/admin/skins/bokeh74/config.json index 10611bb2cf1760695764b058f3eab90feb105a9f..ee6f97b904227cd4c9f28d2be16a215555e2cc13 100644 --- a/public/admin/skins/bokeh74/config.json +++ b/public/admin/skins/bokeh74/config.json @@ -53,7 +53,6 @@ "vodeclic": "../../images/picto/vodeclic_16.png", "orphea": "../../images/picto/orphea_16.png", "numeriquepremium": "../../images/picto/numeriquepremium_16.png", - "numilog": "../../images/picto/oai_16.png", "toutapprendre": "../../images/picto/oai_16.png", "jamendo": "../../images/picto/jamendo_16.png", "assimil": "../../images/picto/assimil_24.png", diff --git a/public/admin/skins/bokeh74/global.css b/public/admin/skins/bokeh74/global.css index a520f2d67f95ea9e2309cb1dd194496c7755480e..6d86f01605e1d39a69e186961c7a836a9fd93c19 100755 --- a/public/admin/skins/bokeh74/global.css +++ b/public/admin/skins/bokeh74/global.css @@ -49,6 +49,7 @@ body { } .redmine_status.redmine_green, +body .digital_connectors_status.enabled:disabled, body .digital_connectors_status.enabled, body .digital_connectors_status.enabled:focus, body .digital_connectors_status.enabled:hover { diff --git a/public/admin/skins/noel/config.json b/public/admin/skins/noel/config.json index 7c29e99825b9d5f3c67e98709e2deacaf1892c74..3a16a417c823c6d9e25c0fdae7655e8bd2f4e8cb 100644 --- a/public/admin/skins/noel/config.json +++ b/public/admin/skins/noel/config.json @@ -53,7 +53,6 @@ "vodeclic": "../../images/picto/vodeclic_16.png", "orphea": "../../images/picto/orphea_16.png", "numeriquepremium": "../../images/picto/numeriquepremium_16.png", - "numilog": "../../images/picto/oai_16.png", "toutapprendre": "../../images/picto/oai_16.png", "jamendo": "../../images/picto/jamendo_16.png", "assimil": "../../images/picto/assimil_24.png", diff --git a/public/admin/skins/retro/config.json b/public/admin/skins/retro/config.json index 6829adb6e2d75572770e4b7f9fdf0d0b2a07ebc4..5f5119d074a6ec65d7b82cb9b6cad00acf688245 100644 --- a/public/admin/skins/retro/config.json +++ b/public/admin/skins/retro/config.json @@ -53,7 +53,6 @@ "vodeclic": "../../images/picto/vodeclic_16.png", "orphea": "../../images/picto/orphea_16.png", "numeriquepremium": "../../images/picto/numeriquepremium_16.png", - "numilog": "../../images/picto/oai_16.png", "toutapprendre": "../../images/picto/oai_16.png", "jamendo": "../../images/picto/jamendo_16.png", "assimil": "../../images/picto/assimil_24.png", diff --git a/public/opac/js/digital_connectors.js b/public/opac/js/digital_connectors.js index cbebfd1c310221bce416139ba0c81f351375066c..329f80f2f0124055789b5a6cacaff2b099121fb6 100644 --- a/public/opac/js/digital_connectors.js +++ b/public/opac/js/digital_connectors.js @@ -123,17 +123,6 @@ "name" : "", "url" : "http://www.numeriquepremium.com/contact"} }, - "NUMILOG": { - "label" : "Numilog", - "enabled": "isNumilogEnabled", - "url" : "http://www.numilog.fr", - "image_url" : "https://bokeh-library-portal.org/userfiles/media/ressources_numeriques/numilog.png", - "desc": "Numilog est un distributeur et diffuseur français de livres numériques.", - "features": ["HARVEST", "SSO"], - "sales_contact": {"mail" : "contact@numilog.com", - "name" : "", - "url" : ""} - }, "PLANETNEMO": { "label" : "PlanetNemo", "enabled": "isPlanetNemoEnabled", diff --git a/tests/application/modules/admin/controllers/BatchControllerTest.php b/tests/application/modules/admin/controllers/BatchControllerTest.php index 6441753b4cb5d9e498045e9ff132600c9fab9fe1..eb694a67b2d9a3b8988a9eb50446a9dc54ebc8c2 100644 --- a/tests/application/modules/admin/controllers/BatchControllerTest.php +++ b/tests/application/modules/admin/controllers/BatchControllerTest.php @@ -39,7 +39,6 @@ abstract class BatchControllerTestCase extends AbstractControllerTestCase { RessourcesNumeriquesFixtures::activateVodeclic(); RessourcesNumeriquesFixtures::activateArteVod(); RessourcesNumeriquesFixtures::activateCyberlibris(); - RessourcesNumeriquesFixtures::deactivateNumilog(); $this->_batch_import = $this->fixture('Class_Batch', ['id' => 3, diff --git a/tests/application/modules/admin/controllers/UserGroupControllerTest.php b/tests/application/modules/admin/controllers/UserGroupControllerTest.php index dc24de89ea0623d1558cda0e1a28fb6176cca54b..670127859e0f00e9658d9e1ca6aa224df9c10397 100644 --- a/tests/application/modules/admin/controllers/UserGroupControllerTest.php +++ b/tests/application/modules/admin/controllers/UserGroupControllerTest.php @@ -1148,7 +1148,6 @@ class Admin_UserGroupControllerRessourcesNumeriquesTest extends Admin_UserGroupC public function datas() { return [['ArteVod', 'ARTE'], ['Vodeclic', 'Vodéclic'], - ['Numilog', 'Numilog'], ['Musicme', 'musicMe'], ['NumeriquePremium', 'Numérique Premium']]; } diff --git a/tests/application/modules/opac/controllers/AuthControllerTest.php b/tests/application/modules/opac/controllers/AuthControllerTest.php index 7b182720b28c4474c0e9152a7df6c3359353a322..4e13bcdef719106d610ebff58a06fe0f390b20bf 100644 --- a/tests/application/modules/opac/controllers/AuthControllerTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerTest.php @@ -1309,18 +1309,38 @@ class AuthControllerPostSuccessfulFromMusicmeCASClientTest extends AuthControlle class AuthControllerFromCASClientUserConnectedTest extends AuthControllerNobodyLoggedTestCase { public function setUp() { parent::setUp(); - ZendAfi_Auth::getInstance()->logUser(Class_Users::newInstanceWithId('22',['login'=> 'john'])); + + $group = + $this->fixture(Class_UserGroup::class, + ['id' => 1, + 'libelle' => 'Digital resources']); + + $this->fixture(Class_Permission::class, + ['id' => 1, + 'code' => 'Numilog']) + ->permitTo($group, new Class_Entity); + + $user = $this->fixture(Class_Users::class, + ['id' => 22, + 'login' => 'john', + 'password' => 'secret']) + ->setUserGroups([$group]); + + ZendAfi_Auth::getInstance() + ->logUser($user); + $this->dispatch('/auth/login?service=http://numilog.com/actionredirected'); } /** @test */ - public function responseShouldRedirectToCasClientServiceWithTicket() { + public function shouldRedirectToCasClientServiceWithTicket() { $this->assertRedirectTo('http://numilog.com/actionredirected?ticket=ST-'.md5(Zend_Session::getId().'22')); } + /** @test */ - public function userJohnShouldBeLogged() { + public function userJohnShouldRemainLogged() { $this->assertEquals('john', Class_Users::getIdentity()->getLogin()); } } @@ -1328,6 +1348,35 @@ class AuthControllerFromCASClientUserConnectedTest extends AuthControllerNobodyL +class AuthControllerFromCASClientUserWithoutRightsConnectedTest extends AuthControllerNobodyLoggedTestCase { + public function setUp() { + parent::setUp(); + + $user = $this->fixture(Class_Users::class, + ['id' => 22, + 'login' => 'john', + 'password' => 'secret']); + + ZendAfi_Auth::getInstance() + ->logUser($user); + + $this->dispatch('/auth/login?service=http://numilog.com/actionredirected'); + } + + + /** @test */ + public function shouldRedirectToOpac() { + $this->assertRedirectTo('/opac'); + } + + + /** @test */ + public function userJohnShouldRemainLogged() { + $this->assertEquals('john', Class_Users::getIdentity()->getLogin()); + } +} + + class AuthControllerPostSimpleFailureTest extends AuthControllerPostSimpleTestCase { diff --git a/tests/application/modules/opac/controllers/ModulesControllerTest.php b/tests/application/modules/opac/controllers/ModulesControllerTest.php index 9aab6a9cf0635c9ed19a89aff4e9c66bf9cac33a..0fb9dd796e5def03cc49b2f068bdf408ad857ac6 100644 --- a/tests/application/modules/opac/controllers/ModulesControllerTest.php +++ b/tests/application/modules/opac/controllers/ModulesControllerTest.php @@ -157,38 +157,6 @@ class ModulesControllerArteVodTest extends AbstractControllerTestCase { -class ModulesControllerNumilogTest extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - - public function setUp() { - parent::setUp(); - Class_AdminVar::newInstanceWithId('NUMILOG_URL',['valeur' => 'http://numilogurl/action']); - } - - - /** @test */ - public function responseShouldContainsRedirectToLogin() { - ZendAfi_Auth::getInstance()->clearIdentity(); - $this->dispatch('/opac/modules/numilog'); - $this->assertXpath('//script[contains(text(), "location.href=")][contains(text(), "auth/login?redirect=http")]'); - } - - - /** @test */ - public function shouldRedirectToNumilog() { - $group = $this->fixture('Class_UserGroup', ['id' => 1]) - ->addRight(Class_UserGroup::RIGHT_ACCES_NUMILOG); - - Class_Users::getIdentity()->setUserGroups([$group]); - - $this->dispatch('/opac/modules/numilog'); - $this->assertXpathContentContains('//script', 'document.location.href="http://numilogurl/action?ticket=ST-'); - } -} - - - - class ModulesControllerNumeriquepremiumTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php index 9e5afd942ae43333975e5efeb1659a0c0a7538b5..f42b272bf94b55654543ac04b465eb87d5ed2cfd 100644 --- a/tests/db/UpgradeDBTest.php +++ b/tests/db/UpgradeDBTest.php @@ -4392,3 +4392,13 @@ class UpgradeDB_428_Test extends UpgradeDBTestCase { $row['valeur'] ?? ''); } } + + + + +class UpgradeDB_429_Test extends UpgradeDBTestCase { + public function prepare() {} + + /** @test */ + public function placeholderForNumilogMigrationPatch() {} +} diff --git a/tests/fixtures/RessourcesNumeriquesFixtures.php b/tests/fixtures/RessourcesNumeriquesFixtures.php index 0118d120931cfff12ec6eac8e0feac00ff03562b..366cb1c11f6becf4a8a9b3e0d6505265d2ca6039 100644 --- a/tests/fixtures/RessourcesNumeriquesFixtures.php +++ b/tests/fixtures/RessourcesNumeriquesFixtures.php @@ -23,7 +23,6 @@ class RessourcesNumeriquesFixtures { public static function deactivate() { self::deactivateVodeclic(); self::deactivateArteVod(); - self::deactivateNumilog(); self::deactivateCyberlibris(); self::deactivateNumeriquePremium(); self::deactivateTypo3(); @@ -41,7 +40,6 @@ class RessourcesNumeriquesFixtures { public static function activate() { self::activateVodeclic(); self::activateArteVod(); - self::activateNumilog(); self::activateCyberlibris(); self::activateNumeriquePremium(); self::activateTypo3(); @@ -114,11 +112,6 @@ class RessourcesNumeriquesFixtures { } - public static function activateNumilog() { - Class_AdminVar::newInstanceWithId('NUMILOG_URL',['valeur' => 'http://numilogurl/action']); - } - - public static function activateMusicme() { Class_AdminVar::newInstanceWithId('Musicme_URL',['valeur' => 'http://musicmeurl/']); Class_AdminVar::newInstanceWithId('Musicme_BIB_ID',['valeur' => '888']); @@ -131,11 +124,6 @@ class RessourcesNumeriquesFixtures { } - public static function deactivateNumilog() { - Class_AdminVar::newInstanceWithId('NUMILOG_URL',['valeur' => '']); - } - - public static function deactivateNumeriquePremium() { Class_AdminVar::newInstanceWithId('NUMERIQUE_PREMIUM_URL', ['valeur' => '']); } diff --git a/tests/library/Class/AlbumTest.php b/tests/library/Class/AlbumTest.php index 0da7d6fdaf78d1e78acf5b9c74dcc2500f24b1c2..339ddb100b5ec995b664385de7e842bc69faed0f 100644 --- a/tests/library/Class/AlbumTest.php +++ b/tests/library/Class/AlbumTest.php @@ -697,41 +697,6 @@ class AlbumHarlockSortingResourcesTest extends AlbumHarlockTestCase { -class AlbumDeletingTestCase extends ModelTestCase { - protected $_storm_default_to_volatile = true; - - public function setUp() { - parent::setUp(); - - $this->fixture('Class_Album', - ['id' => 12066, - 'notice_id' => 3255060, - 'type_doc_id' => Class_TypeDoc::NUMILOG, - 'titre' => 'Le chemin de l\'esperance']); - - $this->fixture('Class_Notice', - ['id' => 3255060, - 'id_notice' => 3255060, - 'alpha_titre' => 'CHEMIN DE L ESPERANCE']); - - - Class_Album::find(12066)->delete(); - } - - - /** @test */ - public function albumChemindeLesperanceShouldBedeleted() { - $this->assertNull(Class_Album::find(12066)); - } - - - /** @test */ - public function deletingAlbumChemindeLesperanceShouldDeleteItsRecord() { - $this->assertNull(Class_Notice::find(3255060)); - } -} - - /** * @see http://forge.afi-sa.fr/issues/61917#note-22 */ diff --git a/tests/library/Class/Migration/DigitalResource/NumilogTest.php b/tests/library/Class/Migration/DigitalResource/NumilogTest.php new file mode 100644 index 0000000000000000000000000000000000000000..bcbae961d61b20ee5b33b4f222e3baa0fab8cb93 --- /dev/null +++ b/tests/library/Class/Migration/DigitalResource/NumilogTest.php @@ -0,0 +1,215 @@ +<?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_NumilogTest extends ModelTestCase { + + 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' => 'NUMILOG', + 'libelle' => 'Lien vers Numilog', + 'preferences' => [], + 'picto' => 'vide.gif'] ]]]]]; + + $cfg_menus_without_numilog = + ['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::class, + ['id' => 22, + 'parent_id' => null]) + ->setBrowser('opac') + ->setLibelle('Profil Adulte') + ->setSelTypeDoc('1;2;106') + ->setCfgMenus($cfg_menus); + + $this->fixture(Class_Catalogue::class, + ['id' => 22, + 'libelle' => 'should be updated', + 'type_doc' => '1;2;106']); + + $this->fixture(Class_Article::class, + ['id' => 22, + 'titre' => 'should be updated', + 'contenu' => '<a href="/modules/numilog">lien</a>', + 'description' => '<a href="/modules/numilog">lien</a>']); + + $profil_without_numilog = $this->fixture(Class_Profil::class, + ['id' => 23, + 'rewrite_url' => 'adulte']) + ->setBrowser('opac') + ->setLibelle('Profil Adulte') + ->setCfgMenus($cfg_menus_without_numilog); + + + Class_Profil::setCurrentProfil($profil_adulte); + + $this->fixture(Class_UserGroup::class, + ['id' => 2, + 'libelle' => 'team ONE', + 'rights_token' => pow(2, 3)]); + + Class_AdminVar::set('NUMILOG_URL', 'http://www.biblioaccess.com/804'); + Class_AdminVar::set('NUMILOG_OAI_IDBIB', '804'); + Class_AdminVar::set('NUMILOG_OAI_URL', 'http://oai.numilog.com/oai.ashx'); + + $this->fixture(Class_Batch::class, + ['id' => 1, + 'type' => 'MOISSONNAGE_NUMILOG', + 'last_run' => '2018-08-13 07:46:22', + 'pick_day' => '1;2;3;4;5;6;0']); + + $this->fixture(Class_Album::class, + ['id' => 456, + 'type_doc_id' => 106, + 'titre' => 'update Me']); + + $this->fixture(Class_Notice::class, + ['id' => 654, + 'type_doc' => 106]); + + (new Class_Migration_DigitalResource_Numilog) + ->setMemoryCleaner(function(){}) + ->run(); + } + + + public function tearDown() { + Class_DigitalResource::resetInstance(); + parent::tearDown(); + } + + + /** @test */ + public function updateDocTypeIdShouldBeNumilog() { + $this->assertEquals('Numilog', Class_Album::find(456)->getTypeDocId()); + } + + + /** @test */ + public function record654DocTypeShouldBeToutNumilog() { + $this->assertEquals('Numilog', Class_Notice::find(654)->getTypeDoc()); + } + + + /** @test */ + public function adminVarNumilogSsoUrlShoudBeCreated() { + $this->assertEquals('https://www.biblioaccess.com/', + Class_AdminVar::getValueOrDefault('Numilog_SSO_URL')); + } + + + /** @test */ + public function adminVarNumilogHarvestUrlShoudBeCreated() { + $this->assertEquals('http://oai.numilog.com/oai.ashx', Class_AdminVar::getValueOrDefault('Numilog_HARVEST_URL')); + } + + + /** @test */ + public function adminVarNumilogKeyShoudBeUpdated() { + $this->assertNotNull(Class_AdminVar::findFirstBy(['clef' => 'Numilog_KEY', + 'valeur' => '804'])); + } + + + /** @test */ + public function profilMenuWithNumilogShouldContainsNewNumilog() { + $this->assertEquals('Numilog', + Class_Profil::find(22)->getCfgMenusAsArray()['H']['menus'][0]['sous_menus'][1]['type_menu']); + } + + + /** @test */ + public function teamOneShouldHavePermissionOnNumilog() { + if (!$permissions = Class_UserGroup::find(2)->getPermissions()) + return $this->fail(); + $this->assertEquals('Numilog', array_shift($permissions)->getCode()); + } + + + /** @test */ + public function teamOneRightsShouldBeCleaned() { + $this->assertEquals(0, Class_UserGroup::find(2)->getRightsToken()); + } + + + /** @test */ + public function oldBatchMoissonageNumilogShouldNotExists() { + $this->assertNull(Class_Batch::findFirstBy(['type' => 'MOISSONNAGE_NUMILOG'])); + } + + + /** @test */ + public function batchNumilogShouldExists() { + $batch = Class_Batch::findFirstBy(['type' => 'Numilog_Batch']); + $this->assertNotNull($batch); + $this->assertEquals(1, $batch->getId()); + $this->assertEquals('2018-08-13 07:46:22', $batch->getLastRun()); + $this->assertEquals('1;2;3;4;5;6;0', $batch->getPickDay()); + } + + + /** @test */ + public function profileSelTypeDocShouldContainsNumilog() { + $this->assertEquals('1;2;Numilog', Class_Profil::find(22)->getSelTypeDoc()); + } + + + /** @test */ + public function domainTypeDocShouldContainsNumilog() { + $this->assertEquals('1;2;Numilog', Class_Catalogue::find(22)->getTypeDoc()); + } + + + /** @test */ + public function articleWithLinkShouldContainsNumilog() { + $this->assertContains('/modules/numilog', Class_Article::find(22)->getContenu()); + $this->assertContains('/modules/numilog', Class_Article::find(22)->getDescription()); + } +} diff --git a/tests/library/Class/MoteurRechercheTest.php b/tests/library/Class/MoteurRechercheTest.php index 56306b43292f1f67820143eb56cf8017cd506063..2e4e762aa3c51d28bd945c490c5f8c97f81d3657 100644 --- a/tests/library/Class/MoteurRechercheTest.php +++ b/tests/library/Class/MoteurRechercheTest.php @@ -342,13 +342,13 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { 'digital_lib' => '1'], 'nb_mots'=> 0, - 'req_liste' => $this->listSqlWith("(type_doc in ('100','101','102','103','104','105','106','109','110','111','112','113','115','116','117','119','Arkhenum','ArteCampus','Artips','Assimil','Bacon','Cvs','DiMusic','Kidilangues','LaSourisQuiRaconte','Lekiosk','LesYeuxDoc','MaPetiteMediatheque','Mobidys','Musicme','Omeka','Skilleos','StoryPlayR','ToutApprendre','Whisperies'))")], + 'req_liste' => $this->listSqlWith("(type_doc in ('100','101','102','103','104','105','109','110','111','112','113','115','116','117','119','Arkhenum','ArteCampus','Artips','Assimil','Bacon','Cvs','DiMusic','Kidilangues','LaSourisQuiRaconte','Lekiosk','LesYeuxDoc','MaPetiteMediatheque','Mobidys','Musicme','Numilog','Omeka','Skilleos','StoryPlayR','ToutApprendre','Whisperies'))")], [['expressionRecherche' => 'logo', 'digital_lib' => '1'], 'nb_mots'=> 1, - 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) and (type_doc in ('100','101','102','103','104','105','106','109','110','111','112','113','115','116','117','119','Arkhenum','ArteCampus','Artips','Assimil','Bacon','Cvs','DiMusic','Kidilangues','LaSourisQuiRaconte','Lekiosk','LesYeuxDoc','MaPetiteMediatheque','Mobidys','Musicme','Omeka','Skilleos','StoryPlayR','ToutApprendre','Whisperies'))", + 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) and (type_doc in ('100','101','102','103','104','105','109','110','111','112','113','115','116','117','119','Arkhenum','ArteCampus','Artips','Assimil','Bacon','Cvs','DiMusic','Kidilangues','LaSourisQuiRaconte','Lekiosk','LesYeuxDoc','MaPetiteMediatheque','Mobidys','Musicme','Numilog','Omeka','Skilleos','StoryPlayR','ToutApprendre','Whisperies'))", "(MATCH(titres) AGAINST(' LOGO') * 1.5) + (MATCH(auteurs) AGAINST(' LOGO')) desc")], [['expressionRecherche' => '', diff --git a/tests/library/Class/NumilogLinkTest.php b/tests/library/Class/NumilogLinkTest.php deleted file mode 100644 index d9f9a663b28772a0cf12f18dda37e69a2a3eea98..0000000000000000000000000000000000000000 --- a/tests/library/Class/NumilogLinkTest.php +++ /dev/null @@ -1,82 +0,0 @@ -<?php -/** - * 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 - * 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 NumilogLinkWithAbonTest extends ModelTestCase { - protected - $_storm_default_to_volatile = true, - $_link; - - public function setUp() { - parent::setUp(); - - Class_AdminVar::set('NUMILOG_URL', 'http://urlnumilog/action'); - - $this->_link = Class_NumilogLink::forUser(Class_Users::getLoader() - ->newInstanceWithId(4) - ->setIdabon(34) - ->setLogin(34) - ->setPrenom('Jerry') - ->setNom('Khan') - ->setMail('feu@essence.fr') - ->setDateFin('2023-09-02')); - } - - - protected function _ticketForSession() { - return 'ST-' . md5( Zend_Session::getId() . '4'); - } - - - /** @test */ - public function urlForJerryShouldBeNumilogSSO() { - $this->assertEquals('http://urlnumilog/action', - $this->_link->getBaseUrl()); - } - - - /** @test */ - public function numilogUrlWithoutParamShouldReturnUrlWithTicket() { - $this->assertEquals('http://urlnumilog/action?ticket=' . $this->_ticketForSession(), - $this->_link->url()); - } - - - /** @test */ - public function numilogUrlWithParamsShouldReturnUrlWithTicket() { - Class_AdminVar::set('NUMILOG_URL', 'http://urlnumilog/action?my_param=3'); - $this->assertEquals('http://urlnumilog/action?my_param=3&ticket=' . $this->_ticketForSession(), - $this->_link->url()); - } - - - /** @test */ - public function numilogUrlExternalWithParamShouldReturnUrlWithTicket() { - $this->assertEquals('http://url-given-bynumilog?withparam=2&ticket=' . $this->_ticketForSession(), - $this->_link->urlExternal('http://url-given-bynumilog?withparam=2')); - } - - - /** @test */ - public function numilogUrlExternalWithoutParamShouldReturnUrlWithTicket() { - $this->assertEquals('http://url-given-bynumilog/322292?ticket=' . $this->_ticketForSession(), - $this->_link->urlExternal('http://url-given-bynumilog/322292')); - } -} \ No newline at end of file diff --git a/tests/library/Class/Systeme/ModulesMenu/NumilogTest.php b/tests/library/Class/Systeme/ModulesMenu/NumilogTest.php deleted file mode 100644 index 99b397cb88f392770bdaf47d55683fa26b935363..0000000000000000000000000000000000000000 --- a/tests/library/Class/Systeme/ModulesMenu/NumilogTest.php +++ /dev/null @@ -1,55 +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_NumilogTest extends ModelTestCase { - public function setUp() { - parent::setUp(); - RessourcesNumeriquesFixtures::activate(); - $this->menu = new Class_Systeme_ModulesMenu_Numilog(); - $this->user = $this->fixture('Class_Users', [ - 'id'=> 34 , - 'password' => 'toto' , - 'login' => '34', - 'idabon' => 34, - 'date_debut' => '1999-02-10', - 'date_fin' => '2025-09-12', - 'user_groups' => [$this->fixture('Class_UserGroup', [ - 'id' => 20, - 'libelle' => 'Numilog' - ])->addRight(Class_UserGroup::RIGHT_ACCES_NUMILOG)] - ])->beAbonneSIGB(); - - ZendAfi_Auth::getInstance()->logUser($this->user); - } - - - /** @test */ - public function withUserLoggedShouldBeLink() { - $this->assertContains('numilog', $this->menu->getDynamiqueUrl()); - } - - - /** @test */ - public function withAbonnementInvalidShouldBeLink() { - $this->assertContains('numilog', $this->menu->getDynamiqueUrl()); - } -} diff --git a/tests/library/Class/WebService/NumilogTest.php b/tests/library/Class/WebService/NumilogTest.php index e3f1fb7963bda372402c68ad1f2baf941a472fac..17ddc44fa05160ccc218dac60609dfb90ee6fe19 100644 --- a/tests/library/Class/WebService/NumilogTest.php +++ b/tests/library/Class/WebService/NumilogTest.php @@ -18,244 +18,3 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -abstract class AbstractNumilogCatalogueTest extends ModelTestCase { - protected $_storm_default_to_volatile = true; - - public function setUp() { - parent::setUp(); - - $this->fixture('Class_CosmoVar', - ['id' => 'types_docs', - 'liste' => '']); - - Class_AdminVar::newInstanceWithId('NUMILOG_OAI_URL', ['valeur' => 'http://numilog-oai-url']); - Class_AdminVar::newInstanceWithId('NUMILOG_URL', ['valeur' => 'http://numilog-oai-url']); - Class_AdminVar::newInstanceWithId('NUMILOG_OAI_IDBIB', ['valeur' => '44']); - - $catalogue_end_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/numilog_end.xml'); - - $this->_http_client = $this->mock() - ->whenCalled('open_url') - ->with('http://numilog-oai-url?verb=ListRecords&metadataPrefix=oai_dc&set=bib%3A44') - ->answers($this->_getXml()) - ->whenCalled('open_url') - ->with('http://numilog-oai-url?verb=ListRecords&resumptionToken=769701498%21500%21oai_dc%21bib%3A44%21') - ->answers($catalogue_end_xml) - - ->beStrict(); - - $codif_type_doc = $this->fixture('Class_CodifTypeDoc', - ['id' => Class_TypeDoc::NUMILOG, - 'famille_id' => Class_CodifTypeDoc::INCONNU, - 'bibliotheques' => '1;8', - 'annexes' => '10;12', - 'sections' => '18;19']); - - $this->fixture('Class_TypeDoc', ['id' => Class_TypeDoc::NUMILOG, - 'codif_type_doc' => $codif_type_doc, - 'label'=> 'Livres Numériques']); - - $this->fixture('Class_CodifMatiere', ['id' => '132', - 'libelle'=>'Management', - 'code_alpha' => 'MANAGEMENT']); - $this->fixture('Class_CodifMatiere', ['id' => '133', - 'libelle'=> 'Métiers et Formations', - 'code_alpha' => 'METIERS ET FORMATIONS']); - $this->fixture('Class_CodifMatiere', ['id' => '134', - 'libelle'=>'Psychologie', - 'code_alpha' => 'PSYCHOLOGIE']); - - $this->onLoaderOfModel('Class_Album') - ->whenCalled('deleteBy') - ->answers(true); - - $this->_numilog = new Class_WebService_BibNumerique_Numilog(); - - Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock() - ->whenCalled('execTimedScript') - ->answers('')); - Class_WebService_BibNumerique_Numilog::setDefaultHttpClient($this->_http_client); - - $this->_numilog->harvest(''); - - $this->_first_livre_numerique = $this->_numilog->loadPage(1)->getRessourcesNumeriques()[0]; - $this->_first_album = $this->_numilog->getAlbums()[0]; - $this->_second_album = $this->_numilog->getAlbums()[1]; - $this->_third_album = $this->_numilog->getAlbums()[2]; - } - - protected function _getXml() { - return file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/numilog_catalogue.xml'); - } - - public function tearDown() { - Class_WebService_BibNumerique_RessourceNumerique::setCommand(null); - Class_WebService_BibNumerique_Numilog::setDefaultHttpClient(null); - parent::tearDown(); - } - -} - - -class NumilogCatalogueTest extends AbstractNumilogCatalogueTest { - /** - * @test - */ - public function secondNumilogLivresTitreShouldBeChroniquesDeNewYork() { - $this->assertEquals("Chroniques de New York", $this->_second_album->getTitre()); - } - - - /** @test */ - public function numberfLivresShouldBe75OnFirstPage() { - $this->assertEquals(74, count($this->_numilog->loadPage(1)->getRessourcesNumeriques())); - } - - - /** @test */ - public function firstAlbumIdOrigineShouldBe9782246804383() { - $this->assertEquals('9782246804383', $this->_first_album->getIdOrigine()); - } - - -/** @test */ - public function firstAlbumLinkShouldBeSet() { - $this->assertEquals('http://oai.numilog.com/oai.ashx',$this->_first_album->getUrlOrigine()); - } - - - /** @test */ - public function firstAlbumExternalURIShouldBeSet() { - $this->assertEquals('http://www.numilog.com/bibliotheque/BM-Enghien-les-Bains/fiche_livre.asp?idprod=330541',$this->_first_album->getExternalUri()); - } - - - /** @test */ - public function firstAlbumDescriptionShouldBeSet() { - - $this->assertEquals("<p align='justify'>Une île privée des Seychelles. Tatiana, « bécasse sentimentale », rencontre Philip, un garçon bien de sa personne ; ils sont beaux, elle est riche, ils s'aiment et décident de se marier. Leur histoire a tout du conte de fées, oui... mais celui-ci est écrit par Saphia Azzeddine, experte en démolitions.<br/>Des plages de sable fin aux coulisses du mariage, de Los Angeles à Paris, et de la meilleure copine à la femme de ménage, chaque personnage prend la parole, comme un chœur de pleureuses, et décrit ce couple en chemin vers l'autel. Sur la scène mondaine, les acteurs de cet univers d'ultra-riches et d'égoïstes liftés s'affrontent et s'esquivent dans une satire sociale aussi drôle que cruelle.</p>",$this->_first_album->getDescription()); - } - - - /** @test */ - public function thirdAlbumDescriptionShouldBeSet() { - $this->assertContains("<h4>Stressé, harcelé, \"burnouté\" ?",$this->_third_album->getDescription()); - - } - - - /** @test */ - public function thirdAlbumShouldBeValid() { - $this->assertTrue($this->_third_album->isValid(),implode(',',$this->_third_album->getErrors())); - - } - - - /** @test */ - public function thirdAlbumShouldHaveMatierePsychologie() { - $this->assertEquals('134;133;132',$this->_third_album->getMatiere()); - } - - - /** @test */ - public function thirdAlbumShouldBeSaved() { - $this->assertNotNull(Class_Album::findFirstBy(['titre' => 'Stress et burnout au travail'])); - } - - - /** @test */ - public function firstAlbumIdLangueShouldBeFre() { - $this->assertEquals('fre',$this->_first_album->getIdLangue()); - } - - - /** @test */ - public function firstAlbumAnneeShouldBe2013 (){ - $this->assertEquals('2013',$this->_first_album->getAnnee()); - } - - - /** @test */ - public function firstAlbumAuteurShouldBeAzzedine (){ - $this->assertContains('Saphia Azzeddine', $this->_first_album->getAuthorsNames()); - } - - - /** @test */ - public function firstAlbumAuteurShouldBeEditeur (){ - $this->assertEquals(['Grasset'], $this->_first_album->getEditors()); - } - - - /** @test */ - public function firstAlbumTypeDocShouldBeLivre() { - $this->assertEquals('Livres Numériques',$this->_first_album->getTypeDoc()->getLabel()); - } - - - /** @test */ - public function firstAlbumCategorieShouldBeLivreNumerique() { - $this->assertEquals('Numilog',$this->_first_album->getCategorie()->getLibelle()); - } - - /** @test */ - public function lastAlbumShouldBeGuideDeLaMaisonEconome() { - $this->assertEquals(['Eyrolles'], - Class_Album::findFirstBy(['titre' => 'Guide de la maison économe']) - ->getEditors()); - } - - - /** @test */ - public function posterShouldBeURIJacketURL(){ - $this->assertEquals('http://couverture.numilog.com/9782246804383_GRANDE.jpg', - $this->_first_album->getPoster()); - } - - - - /** @test */ - public function bibliothequeShouldBeImportedInFirstAlbum() { - $this->assertEquals('1;8',$this->_first_album->getBibliotheques()); - } - - - /** @test */ - public function annexesShouldBeImportedInSecondAlbum() { - $this->assertEquals('10;12',$this->_second_album->getAnnexes()); - } - - - /** @test */ - public function sectionsShouldBeImportedInThirdAlbum() { - $this->assertEquals('18;19',$this->_third_album->getSections()); - } -} - - -class NumilogDeletedTest extends AbstractNumilogCatalogueTest { - - protected function _getXml() { - return file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/numilog_with_deleted.xml'); - } - - - /** @test */ - public function firstAlbumIdOrigineShouldBeDeleted() { - $this->assertNotEquals('9782246804383', $this->_first_album->getIdOrigine()); - } - - /** @test */ - public function numberfBooksShouldBe7() { - $this->assertEquals(7, count($this->_numilog->loadPage(1)->getRessourcesNumeriques())); - } - - - /** @test */ - public function numberfBookImportedShouldBe4() { - $this->assertEquals(4, count(Class_Album::findAll())); - } - - -} \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Status/JsonTest.php b/tests/library/ZendAfi/View/Helper/Status/JsonTest.php index b2fab4e957ae7f7e861ae87f924ff378a8701004..0a6b05193bdeca6ae066ae8914b7de465faf8526 100644 --- a/tests/library/ZendAfi/View/Helper/Status/JsonTest.php +++ b/tests/library/ZendAfi/View/Helper/Status/JsonTest.php @@ -211,17 +211,6 @@ class ZendAfi_View_Helper_Status_JsonTest extends ZendAfi_View_Helper_Status_Tes } - /** @test */ - public function NumilogShouldEnabled() { - $this->assertContains(["code" => "NUMILOG", - "label" => "Numilog", - "enabled" => true, - "features" => ["HARVEST", "SSO"], - "album_count" => 0 - ], - $this->_report['digital_connectors']); - } - /** @test */ public function CyberlibrisShouldEnabled() { $this->assertContains(["code" => "CYBERLIBRIS",