diff --git a/VERSIONS_HOTLINE/140322 b/VERSIONS_HOTLINE/140322 new file mode 100644 index 0000000000000000000000000000000000000000..334efa0363437fc5ffac30c27b9b1fc68580cce0 --- /dev/null +++ b/VERSIONS_HOTLINE/140322 @@ -0,0 +1 @@ + - ticket #140322 : Réservations calendaire : Correction de la prise en charge du paramétrage de plusieurs codes de types de documents. \ No newline at end of file diff --git a/VERSIONS_HOTLINE/141990 b/VERSIONS_HOTLINE/141990 new file mode 100644 index 0000000000000000000000000000000000000000..d2082148003caebc74efa65c356107f51a596595 --- /dev/null +++ b/VERSIONS_HOTLINE/141990 @@ -0,0 +1 @@ + - ticket #141990 : DiMusic : Ajout du script scripts/dimusic_first_harvest.php permettant de lancer le premier moissonage de cette ressource. \ No newline at end of file diff --git a/VERSIONS_HOTLINE/142649 b/VERSIONS_HOTLINE/142649 new file mode 100644 index 0000000000000000000000000000000000000000..f41092da6b5882abb10b01b41e5ce60a7307dad3 --- /dev/null +++ b/VERSIONS_HOTLINE/142649 @@ -0,0 +1 @@ + - ticket #142649 : Magasin de thèmes : Correction du rendu de liste à interactions qui pouvait renvoyer une autre liste après la pagination. \ No newline at end of file diff --git a/VERSIONS_HOTLINE/143141 b/VERSIONS_HOTLINE/143141 new file mode 100644 index 0000000000000000000000000000000000000000..183de0d3e9fb4caa72d1e20296e73291522d0b95 --- /dev/null +++ b/VERSIONS_HOTLINE/143141 @@ -0,0 +1 @@ + - ticket #143141 : Admin : Album netoyer les PNB pour supprimer les facettes associés à des codifications supprimés \ No newline at end of file diff --git a/VERSIONS_HOTLINE/143478 b/VERSIONS_HOTLINE/143478 new file mode 100644 index 0000000000000000000000000000000000000000..6ee8626fee5b8aa9eed36b14e4ef52721b32a44b --- /dev/null +++ b/VERSIONS_HOTLINE/143478 @@ -0,0 +1 @@ + - ticket #143478 : Cosmogramme : correction de la phase de suppression des fichiers d'intégrations. Les fichiers les plus anciens sont maintenant supprimés. \ No newline at end of file diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index e532a1dc8de2e0316b57d3f584285bc2459043e2..63e0facddf78783d53c253aa1c0e625cb414721f 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -123,7 +123,7 @@ class RechercheController extends ZendAfi_Controller_Action { ->injectInto($criteres_recherche); $criteres_recherche = (new Class_CriteresRecherche_AxesParam)->fromParamArray($params) - ->injectInto($criteres_recherche); + ->injectInto($criteres_recherche); } if ($should_redirect) { @@ -880,9 +880,11 @@ class RechercheController extends ZendAfi_Controller_Action { if ($this->_request->isPost() && $form->isValid($this->_request->getPost())) { - return $this->_redirect($this->view->absoluteUrl(['action' => 'reservationajax', - 'render' => null, - 'code_annexe' => $this->_request->getPost('code_annexe')])); + return $this->_redirect($this->view->url(['module' => 'opac', + 'controller' => 'recherche', + 'action' => 'reservationajax', + 'render' => null, + 'code_annexe' => $this->_request->getPost('code_annexe')])); } $html = []; diff --git a/library/Class/Cosmogramme/Integration/PhaseFlushIntegrations.php b/library/Class/Cosmogramme/Integration/PhaseFlushIntegrations.php index 84ddc85ed4a4f374db239567a3e74c3a40ed6aa4..188710a21895c2710e94b274817f47424cb1623f 100644 --- a/library/Class/Cosmogramme/Integration/PhaseFlushIntegrations.php +++ b/library/Class/Cosmogramme/Integration/PhaseFlushIntegrations.php @@ -25,6 +25,9 @@ class Class_Cosmogramme_Integration_PhaseFlushIntegrations const MY_ID = 22; + protected $_count_archives=0, + $_count_deleted_files=0, + $_path; public function __construct($phase, $log, $chrono) { parent::__construct($phase, $log, $chrono); @@ -38,7 +41,7 @@ class Class_Cosmogramme_Integration_PhaseFlushIntegrations protected function _execute() { - if ( ! $path = Class_CosmoVar::getValueOf('integration_path')) + if ( ! $this->_path = Class_CosmoVar::getValueOf('integration_path')) return $this->_log->error($this->_('La configuration de CosmoVar integration_path est incorrecte. Aucun fichier d\'intégration ne sera supprimé.')); if ( ! $nb_max = Class_CosmoVar::getValueOf('integre_max_paniers')) @@ -52,27 +55,45 @@ class Class_Cosmogramme_Integration_PhaseFlushIntegrations $nb, $nb_max)); - $liste = Class_Cosmogramme_Integration::findAllBy(['traite not' => 'non', - 'destroy' => '0', - 'order' => 'id desc', - 'limit' => sprintf('%s, 10000', $nb_max)]); - Class_FileManager::beOpenBar(); - $count = 0; - foreach($liste as $integration) { - if ( ! $file = Class_FileManager::find($path . $integration->getFichier())) - continue; + $this->_count_archives = 0; + $this->_count_deleted_files = 0; - if ( false === (bool) Class_FileManager::delete($file)) - continue; + while($integrations = Class_Cosmogramme_Integration::findAllBy(['traite not' => 'non', + 'destroy' => '0', + 'order' => 'id desc', + 'limitPage' => [2, $nb_max]])) { + $this->_processPageIntegration($integrations); - $integration->setDestroy(1)->save(); - $count++; + $this->_cleanMemory(); } Class_FileManager::reset(); - $this->_log->success($this->_('%s fichiers d\'intégrations supprimés.', $count)); + $this->_log->success($this->_('%s intégrations ont été archivées. %s fichiers ont été supprimés.', + $this->_count_archives, + $this->_count_deleted_files)); + } + + + protected function _processPageIntegration($integrations){ + foreach($integrations as $integration) { + $integration + ->setDestroy(1) + ->save(); + + $this->_count_archives++; + + $integration_file_path = $this->_path . $integration->getFichier(); + if (!$file = Class_FileManager::find($integration_file_path)) + continue; + + if ( false === (bool) Class_FileManager::delete($file)) + continue; + + $this->_count_deleted_files++; + + } } } diff --git a/library/Class/DigitalResource.php b/library/Class/DigitalResource.php index c4e26c3c7096c6109bf2849867aff6c8f334cdda..6832c9e2fc51e7ae0faf056f8677ccf613b221a1 100644 --- a/library/Class/DigitalResource.php +++ b/library/Class/DigitalResource.php @@ -148,6 +148,24 @@ class Class_DigitalResource extends Class_Entity { } + public function getImporters() { + return $this->pluginsByName(function($config) + { + if($importer = $config->getImporter()) + return $this->build($importer, $config); + }); + } + + + public function getHarvesters() { + return $this->pluginsByName(function($config) + { + if($harvester = $config->getHarvester()) + return $this->build($harvester, $config); + }); + } + + public function hasRightAccessPlugin($plugin, $user) { if (!$this->isPluginDocType($plugin)) return false; diff --git a/library/Class/DigitalResource/Config.php b/library/Class/DigitalResource/Config.php index e2f92262271a4ea29ea46c83ecedaf173ce86126..400946039522a5e2d34251c8b8aa4fae933bc3fa 100644 --- a/library/Class/DigitalResource/Config.php +++ b/library/Class/DigitalResource/Config.php @@ -110,6 +110,32 @@ class Class_DigitalResource_Config extends Class_Entity { } + public function isFirstHarvestAware() { + return $this->getHarvester() + && $this->getImporter(); + } + + + public function isFirstHarvestDone() { + return $this->getHarvesterInstance()->isDone(); + } + + + public function isFirstImportDone() { + return $this->getImporterInstance()->isDone(); + } + + + public function isFirstHarvestRunning() { + return $this->getHarvesterInstance()->isRunning(); + } + + + public function isFirstImportRunning() { + return $this->getImporterInstance()->isRunning(); + } + + public function getDashboardUrl() { return Class_Url::absolute(['module' => $this->getModuleName()], null, @@ -118,7 +144,33 @@ class Class_DigitalResource_Config extends Class_Entity { public function getBatchInstance() { - return $this->getDigitalResource()->getBatches()[$this->getBatch()]; + return $this->_getObjectInstance($this->getDigitalResource()->getBatches(), + $this->getBatch()); + } + + + public function getImporterInstance() { + return $this->_getObjectInstance($this->getDigitalResource()->getImporters()); + } + + + public function getHarvesterInstance() { + return $this->_getObjectInstance($this->getDigitalResource()->getHarvesters()); + } + + + protected function _getObjectInstance($instances, $key = '') { + if ( ! $instances ) + return null; + + $key = + ( $key + ? $key + : $this->getName() ); + + return isset($instances[$key]) + ? $instances[$key] + : null; } diff --git a/library/Class/DigitalResource/Harvester/OAI.php b/library/Class/DigitalResource/Harvester/OAI.php new file mode 100644 index 0000000000000000000000000000000000000000..37022f93ad30e2adda53df1ba37a86da65654303 --- /dev/null +++ b/library/Class/DigitalResource/Harvester/OAI.php @@ -0,0 +1,103 @@ +<?php +/** + * Copyright (c) 2012-2021, 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_DigitalResource_Harvester_OAI extends Class_DigitalResource_OAI_AbstractInitJob { + + public function __construct() { + parent::__construct(); + $this->_job = $this->_('moissonnage de l\'OAI'); + } + + + protected function _clean() { + return $this + ->_cleanHarvestLogs() + ->_cleanXML(); + } + + + protected function _cleanHarvestLogs() { + $this->_log($this->_('Suppression des précédents journaux de moissonnage de %s.', + $this->_name)); + + Class_WebService_HarvestLog::deleteBy([ 'type_doc' => $this->_doc_type ]); + $this->_cleanMemory(); + + return $this; + } + + + protected function _cleanXML() { + $this->_log($this->_('Suppression des fichiers XML existants dans %s', $this->_oai_xml_directory_path)); + + Class_FileManager::deleteFiles($this->_oai_xml_directory_path); + + return $this; + } + + + protected function _work() { + $this->_log($this->_('Début du moissonnage.')); + $this->_oai_ws->setLogger($this->getLogger()); + + Class_FileManager::create($this->_oai_xml_directory_name, + Class_FileManager::find(USERFILES)); + + $page = 0; + while($this->_oai_ws->hasRecordsToHarvest()) + $this->_writeXML($page ++); + + Class_WebService_HarvestLog::newInstance(['end_date' => $this->getCurrentDate(), + 'type_doc' => $this->_doc_type]) + ->save(); + + $this->_log($this->_('%s fichiers sauvegardés.', ((int) $page ) -1)); + return $this; + } + + + protected function _writeXML($page) { + if ( ! $xml = $this->_getXML($page)) + return; + + $this->_oai_ws->parseResumptionToken($xml); + Class_FileManager::createFile($this->_oai_xml_directory_path . '/' . $page . '.xml', $xml); + } + + + protected function _getXML($page) { + return $page == 1 + ? $this->_oai_ws->getXML() + : $this->_oai_ws->getNextXML(); + } + + + public function isDone() { + return Class_WebService_HarvestLog::findFirstBy(['type_doc' => $this->_doc_type]); + } + + + public function isRunning() { + return ( ! $this->isDone()) + && Class_FileManager::hasFilesIn($this->_oai_xml_directory_path); + } +} diff --git a/library/Class/DigitalResource/Importer/OAI.php b/library/Class/DigitalResource/Importer/OAI.php new file mode 100644 index 0000000000000000000000000000000000000000..547fa1c1ccdf825404fa2bf32d70ccd5f487eaea --- /dev/null +++ b/library/Class/DigitalResource/Importer/OAI.php @@ -0,0 +1,121 @@ +<?php +/** + * Copyright (c) 2012-2021, 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_DigitalResource_Importer_OAI extends Class_DigitalResource_OAI_AbstractInitJob { + + public function __construct() { + parent::__construct(); + $this->_job = $this->_('import des albums'); + } + + + protected function _clean() { + if (Class_FileManager::files($this->_oai_xml_done_directory_path)) + return $this; + + $this->_log($this->_('%s : suppression des albums existants', + $this->_name)); + + $count_all_dimusic_albums = Class_Album::countBy(['type_doc_id' => $this->_doc_type]); + + $deleted_albums = 0; + + while ( $albums = Class_Album::findAllBy(['type_doc_id' => $this->_doc_type, + 'limit' => 100])) { + $deleted_albums += $this->_deleteAlbums($albums); + $this->_log(sprintf('%s/%s', + $deleted_albums, + $count_all_dimusic_albums)); + + $this->_cleanMemory(); + } + + return $this; + } + + + protected function _deleteAlbums($albums) { + $deleted_albums = 0; + foreach($albums as $album) { + $album->delete(); + $deleted_albums ++; + } + + return $deleted_albums; + } + + + protected function _work() { + $this->_log($this->_('%s : création des albums.', + $this->_name)); + + Class_FileManager::create(static::DONE_DIRECTORY, + Class_FileManager::find($this->_oai_xml_directory_path)); + + $files = Class_FileManager::files($this->_oai_xml_directory_path); + $total = count($files); + $count = 1; + + foreach ( $files as $xml_file ) { + $this->_log($this->_('Traitement du fichier : %s. %s/%s', + $xml_file->getPath(), + $count, + $total)); + $this->_workWithFile($xml_file); + $count ++; + } + + return $this; + } + + + protected function _workWithFile($xml_file) { + $xml = $xml_file->getContent(); + if ($this->_service->importFrom($xml)) + Class_FileManager::moveItemInto($xml_file, + $this->_oai_xml_done_directory_path + . '/' + . $xml_file->getName()); + + return $this; + } + + + public function isDone() { + return (0 < $this->_config->countAlbums()) + && $this->_config->getHarvesterInstance()->isDone(); + } + + + public function isRunning() { + return ( ! $this->isDone()) + && Class_FileManager::hasFilesIn($this->_oai_xml_directory_path); + } + + + public function getUserfilesFolderToDelete() { + return (Class_FileManager::find($this->_oai_xml_done_directory_path) + && $this->isDone()) + ? $this->_oai_xml_directory_path + : ''; + } +} diff --git a/library/Class/DigitalResource/OAI/AbstractInitJob.php b/library/Class/DigitalResource/OAI/AbstractInitJob.php new file mode 100644 index 0000000000000000000000000000000000000000..5b9df3508153f60de2dff02ab67db2eb53c00eac --- /dev/null +++ b/library/Class/DigitalResource/OAI/AbstractInitJob.php @@ -0,0 +1,109 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 Class_DigitalResource_OAI_AbstractInitJob { + use + Trait_TimeSource, + Trait_Translator, + Trait_MemoryCleaner, + Trait_Logger; + + const DONE_DIRECTORY = 'done'; + + + protected + $_job, + $_config, + $_service, + $_doc_type, + $_oai_xml_directory_name, + $_oai_xml_directory_path; + + + public function __construct() { + $this->_config = Class_DigitalResource_Config::getInstanceFor(static::class); + $this->_name = $this->_config->getName(); + $this->_doc_type = $this->_config->getDocType(); + $this->_service = $this->_config->getServiceInstance(); + $this->_oai_ws = $this->_config->newOAIClient(); + + $this->_oai_xml_directory_name = sprintf('%s_oai_xml_responses', + strtolower($this->_name)); + + $this->_oai_xml_directory_path = USERFILES . '/' . $this->_oai_xml_directory_name; + + $this->_oai_xml_done_directory_path = + $this->_oai_xml_directory_path + . '/' + . static::DONE_DIRECTORY; + + Class_FileManager::disableCache(); + Class_FileManager::beOpenBar(); + Class_FileManager_FileSystem::beUnlimited(); + } + + + protected function _log($message) { + return $this->getLogger()->log("\n" . $message); + } + + + public function run() { + if ( ! $this->_config->isEnabled() ) { + $this->_log($this->_('%s n\'est pas activé. Le script est arrété.', + $this->_name)); + return $this;; + } + + return $this + ->_intro() + ->_clean() + ->_work() + ->_stop(); + } + + protected function _intro() { + $this->_log($this->_('%s : Début premier %s à %s.', + $this->_name, + $this->_job, + $this->getCurrentDateTime())); + return $this; + } + + + protected function _stop() { + Class_FileManager::reset(); + $this->_oai_ws->reset(); + + $this->_log($this->_('%s : Fin du premier %s à %s.', + $this->_name, + $this->_job, + $this->getCurrentDateTime())); + return $this; + } + + + abstract protected function _clean(); + abstract protected function _work(); + abstract public function isDone(); + abstract public function isRunning(); +} \ No newline at end of file diff --git a/library/Class/FileManager.php b/library/Class/FileManager.php index b81ed12c86ea10f770538bbe66f65aac16a776c1..084c7b5643bd2b6cca2b3e68ca2a94d8c8ea29d6 100644 --- a/library/Class/FileManager.php +++ b/library/Class/FileManager.php @@ -67,6 +67,11 @@ class Class_FileManager extends Class_Entity { } + public static function disableCache() { + return static::getFileSystem()->disableCache(); + } + + public static function getDiskSpaceInfo() { return static::getFileSystem()->diskSpaceInfo(); } @@ -276,6 +281,17 @@ class Class_FileManager extends Class_Entity { } + public static function deleteFiles ($path) { + foreach (Class_FileManager::files($path) as $file) + Class_FileManager::delete($file); + } + + + public static function hasFilesIn($path) { + return 0 < static::getFileSystem()->countFilesIn($path); + } + + public static function search($term, $path) { if (!static::userHasRightOnPath($path)) return []; @@ -363,6 +379,11 @@ class Class_FileManager extends Class_Entity { public static function createImage($path, $content) { + return static::createFile($path, $content); + } + + + public static function createFile($path, $content) { return static::getFileSystem()->createImage($path, $content); } diff --git a/library/Class/FileManager/FileSystem.php b/library/Class/FileManager/FileSystem.php index d98f26518820aa6910ca3ccd0688ce5a1b12a2ee..ca500fc6280d89113a3fba181450c70d5e5cf866 100644 --- a/library/Class/FileManager/FileSystem.php +++ b/library/Class/FileManager/FileSystem.php @@ -26,7 +26,9 @@ class Class_FileManager_FileSystem { const LISTING_LIMIT = 200; - protected static $_limited = true; + protected static + $_limited = true, + $_cache_status = true; protected $_cached_paths = [], @@ -40,6 +42,7 @@ class Class_FileManager_FileSystem { public static function reset() { static::$_limited = true; + static::$_cache_status = true; } @@ -53,8 +56,13 @@ class Class_FileManager_FileSystem { } + public function countFilesIn($path) { + return count($this->_glob($path, false)); + } + + protected function _filterEntriesAt($path, $callback = null) { - $items = $this->_glob($path, true); + $items = $this->_glob($path, static::$_cache_status); if (static::$_limited && Class_FileManager_FileSystem::LISTING_LIMIT < count($items)) { $this->_oversized[] = $path; @@ -334,16 +342,17 @@ class Class_FileManager_FileSystem { protected function _glob($path, $cache = true) { $this->_cached_paths[] = $path; - $closure = function() use ($path) { - $paths = glob($path . '/{,.}[!.,!..]*', GLOB_BRACE); - $paths = array_filter($paths, - function($path) - { - return Class_FileManager::userHasRightOnPath($path); - }); - sort($paths, SORT_NATURAL); - return $paths; - }; + $closure = function() use ($path) + { + $paths = glob($path . '/{,.}[!.,!..]*', GLOB_BRACE); + $paths = (array_filter($paths, + function($path) + { + return Class_FileManager::userHasRightOnPath($path); + })); + sort($paths, SORT_NATURAL); + return $paths; + }; if($cache) return (new Storm_Cache()) @@ -398,4 +407,9 @@ class Class_FileManager_FileSystem { ob_end_clean(); return readfile($path); } + + + public function disableCache() { + static::$_cache_status = false; + } } \ No newline at end of file diff --git a/library/Class/Migration/AlbumClearCodif.php b/library/Class/Migration/AlbumClearCodif.php new file mode 100644 index 0000000000000000000000000000000000000000..fc39244914f8db2599b8fca6c6c0f7fb0e075141 --- /dev/null +++ b/library/Class/Migration/AlbumClearCodif.php @@ -0,0 +1,177 @@ +<?php +/** + * Copyright (c) 2012-2021, 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_AlbumClearCodif { + + protected + $_cat_id, + $_list_codif_status; + + public function __construct($cat_id) { + $this->_cat_id = $cat_id; + $this->_list_codif_status = new Storm_Collection(); + } + + + public function run() { + try { + if (!$this->_cat_id + || !$category = Class_AlbumCategorie::find($this->_cat_id)) + return; + + $albums = Class_Album::findAllBy(['cat_id' => $category->getSousCategoriesIds()]); + array_map(function ($album) { + $this->_withAlbumDo($album); + }, $albums); + + (new Storm_Cache())->clean(); + } catch (Exception $e) { + return; + } + } + + + protected function _withAlbumDo($album) { + $must_save = $this->_checkGenre($album); + $must_save |= $this->_checkSection($album); + $must_save |= $this->_checkAnnexe($album); + $must_save |= $this->_checkMatiere($album); + + if ($must_save) { + $album->save(); + $album->index(); + } + } + + + protected function _checkGenre($album) { + return $this->_checkCodif($album, 'genre', Class_CodifGenre::class); + } + + + protected function _checkSection($album) { + return $this->_checkCodif($album, 'sections', Class_CodifSection::class); + } + + + protected function _checkAnnexe($album) { + return $this->_checkCodif($album, 'annexes', Class_CodifAnnexe::class); + } + + + protected function _checkMatiere($album) { + return $this->_checkCodif($album, 'matiere', Class_CodifMatiere::class); + } + + + protected function _checkCodif($album, $attrib, $class_name) { + $is_updated = false; + $list_codif = []; + foreach (explode(';', $album->$attrib) as $codif_id) + $is_updated |= $this->_isUpdatedListCodif($class_name, $codif_id, $list_codif); + + if ($is_updated) + $album->$attrib = implode(';', $list_codif); + + return $is_updated; + } + + + protected function _isUpdatedListCodif($class_name, $codif_id, &$list_codif) { + $valid = $this->_existForClassName($class_name, $codif_id); + if ($valid) + $list_codif [] = $codif_id; + + return !$valid; + } + + + protected function _existForClassName($class_name, $codif_id) { + $codif_for_type = $this->_list_codif_status + ->detect(function ($codif_status) use ($class_name, $codif_id) { + return $class_name == $codif_status->getClassName() + && $codif_id == $codif_status->getCodifId(); + }); + + if (!$codif_for_type) + $codif_for_type = $this->_addNewCodif($class_name, $codif_id); + + return $codif_for_type->isExist(); + } + + + protected function _addNewCodif($type, $codif_id) { + $new_codif = (new CodifStatus($type, $codif_id))->init(); + if ($new_codif->isValid()) + $this->_list_codif_status->add($new_codif); + + return $new_codif; + } +} + + + + +class CodifStatus { + + protected + $_exist = false, + $_class_name, + $_codif_id; + + public function __construct($class_name, $codif_id) { + $this->_class_name = $class_name; + $this->_codif_id = $codif_id; + } + + + public function isValid() { + return $this->_class_name && $this->_codif_id; + } + + + public function init() { + if (!$this->isValid()) + return $this; + + $codif = $this->_class_name::find($this->_codif_id); + if ($codif) + $this->_exist = true; + + return $this; + } + + + public function getClassName() { + return $this->_class_name; + } + + + public function getCodifId() { + return $this->_codif_id; + } + + + public function isExist() { + return $this->_exist; + } +} diff --git a/library/Class/User/CardsOperationDecorator.php b/library/Class/User/CardsOperationDecorator.php index 60a697011122df0defdc48f7f244cffe06f16725..14237bcf77297027f63e53975b7f92a22e7bbe88 100644 --- a/library/Class/User/CardsOperationDecorator.php +++ b/library/Class/User/CardsOperationDecorator.php @@ -27,8 +27,8 @@ class Class_User_CardsOperationDecorator { public static function decorateAll($operations, $card) { return $operations->collect( - function($loan) use ($card) { - return new Class_User_CardsOperationDecorator($loan, $card); + function($operation) use ($card) { + return new Class_User_CardsOperationDecorator($operation, $card); }); } diff --git a/library/Class/WebService/BibNumerique/AbstractOAI.php b/library/Class/WebService/BibNumerique/AbstractOAI.php index 96723336ba7f8b9b858c3a40251b4de7c81bf74f..aa9c8c14bd9ea27c816cd9d40722f4a1d8d47e0e 100644 --- a/library/Class/WebService/BibNumerique/AbstractOAI.php +++ b/library/Class/WebService/BibNumerique/AbstractOAI.php @@ -38,6 +38,11 @@ abstract class Class_WebService_BibNumerique_AbstractOAI extends Class_WebServic } + public function importFrom($xml) { + return $this->_importRessources($this->getOaiWS()->parseXML($xml)); + } + + protected function _logRun() { Class_WebService_HarvestLog::newInstance(['end_date' => $this->getCurrentDate(), 'type_doc' => $this->getDocType()])->save(); @@ -97,7 +102,7 @@ abstract class Class_WebService_BibNumerique_AbstractOAI extends Class_WebServic protected function getOaiWS() { - return $this->_oaiws; + return $this->_oaiws->setLogger($this->getLogger()); } diff --git a/library/Class/WebService/BibNumerique/ArteVOD/Config.php b/library/Class/WebService/BibNumerique/ArteVOD/Config.php index 2cbbd9b390bc04fa195a8140f25b439249daf988..d3c359e42da839b3257120eb53a7c79586d3bf85 100644 --- a/library/Class/WebService/BibNumerique/ArteVOD/Config.php +++ b/library/Class/WebService/BibNumerique/ArteVOD/Config.php @@ -201,4 +201,9 @@ class Class_WebService_BibNumerique_ArteVOD_Config extends Class_Entity { public function renderTrySsoUrlOn($view, $params=[]) { return $view->url(array_merge($params, ['action' => 'artevod-try-sso'])); } + + + public function isFirstHarvestAware() { + return false; + } } diff --git a/library/Class/WebService/OAI.php b/library/Class/WebService/OAI.php index 400a0b61bf9dd847951bb7d6ee9179c224e79ae1..327b0b2ef9b13bbcacfcceab939d434a513fdaad 100644 --- a/library/Class/WebService/OAI.php +++ b/library/Class/WebService/OAI.php @@ -31,6 +31,9 @@ */ class Class_WebService_OAI extends Class_WebService_Abstract { + use Trait_Translator; + + const Verb = 'verb', MetadataPrefix = 'metadataPrefix', @@ -52,6 +55,14 @@ class Class_WebService_OAI extends Class_WebService_Abstract { $_logger; + /** @override Trait_SimpleWebClient::getWebClient() */ + public static function getWebClient() { + return isset(static::$_web_client) + ? static::$_web_client + : new Class_WebService_WaitingSimpleWebClient(); + } + + public static function baseURL() { return Class_Url::absolute(['module' => 'opac', 'controller' => 'oai', @@ -162,8 +173,19 @@ class Class_WebService_OAI extends Class_WebService_Abstract { public function oaiAsks($verb, $parameters) { $url = $this->_askUrlFor($verb, $parameters); + $this->_log($this->_('Url : %s', $url)); + $response = $this->getContent($url); - $this->_log($url, $response); + 200 < strlen($response) + ? ($this + ->_log($this->_('Réponse :')) + ->_log(substr($response, 0, 200)) + ->_log('[…]') + ->_log(substr($response, -200))) + : $response; + + if ( ! $response ) + $this->setListRecordsResumptionToken(null); return $response; } @@ -181,10 +203,12 @@ class Class_WebService_OAI extends Class_WebService_Abstract { } - protected function _log($url, $response) { + protected function _log($message) { if (!$this->_logger) - return; - $this->_logger->log($url, $response); + return $this; + + $this->_logger->log($message); + return $this; } @@ -243,11 +267,9 @@ class Class_WebService_OAI extends Class_WebService_Abstract { if (!$this->isFirstPage()) return $this->getNextNumericResources(); - $params = array_filter(array_merge([static::MetadataPrefix => $this->_metadata_prefix, - static::Set => $this->_default_set], - $params)); $this->_first_page = false; - $xml_data = $this->oaiAsks(static::ListRecords, $params); + + $xml_data = $this->getXML($params); return $this->parseListRecordsRessourcesNumeriqueXML($xml_data); } @@ -266,7 +288,8 @@ class Class_WebService_OAI extends Class_WebService_Abstract { public function getRecords($params = []) { - $params = array_merge([static::MetadataPrefix => $this->_metadata_prefix], $params); + $params = array_merge([static::MetadataPrefix => $this->_metadata_prefix], + $params); $xml_data = $this->oaiAsks(static::ListRecords, $params); return $this->parseListRecordsXML($xml_data); @@ -312,14 +335,39 @@ class Class_WebService_OAI extends Class_WebService_Abstract { protected function _withNextPageDo($method) { - if (!$this->hasNextRecords()) - return []; + return ($xml_data = $this->getNextXML()) + ? $this->$method($xml_data) + : []; + } + + + public function getXML($params = []) { + $params = array_filter(array_merge([static::MetadataPrefix => $this->_metadata_prefix, + static::Set => $this->_default_set], + $params)); + return $this->oaiAsks(static::ListRecords, $params); + } + + + public function getNextXML() { + return $this->hasNextRecords() + ? $this->getXML([static::MetadataPrefix => null, + static::Set => null, + static::ResumptionToken => + $this->getListRecordsResumptionToken()->getToken()]) + : ''; + } - $xml_data = $this - ->oaiAsks(static::ListRecords, - [static::ResumptionToken => $this->getListRecordsResumptionToken()->getToken()]); - return $this->$method($xml_data); + public function parseResumptionToken($xml) { + $this->parser->parse($xml); + + return ($token = $this->parser->getResumptionToken()) + ? ($this + ->setListRecordsResumptionToken($token) + ->beNextPage()) + : ($this + ->setListRecordsResumptionToken(null)); } @@ -364,6 +412,19 @@ class Class_WebService_OAI extends Class_WebService_Abstract { } + public function beNextPage() { + $this->_first_page = false; + return $this; + } + + + public function parseXML($xml) { + $this->parser->acceptVisitor($this); + $this->parser->parse($xml); + return $this->parser->getRecordsRessourceNumeriques(); + } + + public function reset() { return $this->setListRecordsResumptionToken(null) ->beFirstPage(); diff --git a/library/Class/WebService/SIGB/AbstractRESTService.php b/library/Class/WebService/SIGB/AbstractRESTService.php index 6c8b03fdb6f4100ded19771daadf4c3d84e30d4a..f2af41d2e3694be46f3ede5f05c0bfb2d1864d64 100644 --- a/library/Class/WebService/SIGB/AbstractRESTService.php +++ b/library/Class/WebService/SIGB/AbstractRESTService.php @@ -20,6 +20,9 @@ */ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebService_SIGB_AbstractService { + + protected static $_should_throw_error = false; + protected $_server_root; protected $_web_client; protected $_has_network_error = false; @@ -129,11 +132,21 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic */ protected function _withClientDo($options, $closure) { $url = $this->buildQueryURL($options); - try { + $web_client = $this->getWebClient(); + + $response_closure = function($closure, $url) + { $response = $closure($this->getWebClient(), $url); $this->log($this); $this->_has_network_error = false; return $response; + }; + + if (static::$_should_throw_error) + return $response_closure($closure, $url); + + try { + return $response_closure($closure, $url); } catch (Exception $e) { $this->logError($url, $e->getMessage()); $this->_has_network_error = true; @@ -171,7 +184,6 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic public function httpGetNotice($params, $reader) { $xml = $this->httpGet($params); - if ($notice = $reader->getNoticeFromXML($xml)) $this->cacheNotice($notice); @@ -332,4 +344,9 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic protected function _getErrorFromCode($error_code, $default_message) { return $default_message; } + + + public static function shouldThrowError($should) { + static::$_should_throw_error = $should; + } } \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Koha.php b/library/Class/WebService/SIGB/Koha.php index f3b0c7b64a1dcda0f3154206ccf97124b3d5a857..c67a04f72c0c80d3a9565a5fe085298a5e5b984d 100644 --- a/library/Class/WebService/SIGB/Koha.php +++ b/library/Class/WebService/SIGB/Koha.php @@ -54,7 +54,7 @@ class Class_WebService_SIGB_Koha { $service ->setCodificationDisponibilites(Class_WebService_SIGB_Abstract::decodeMapping($params['Codification_disponibilites'])) ->setWithdrawnMapping(Class_WebService_SIGB_Abstract::decodeMapping($params['withdrawn_mapping'])) - ->setGroupedHoldsITypes(array_filter(explode("\n", $params['grouped_holds_itypes']))) + ->setGroupedHoldsITypes(static::_extractGroupedHoldsItypes($params)) ->setBundledHoldsMinimalDuration($params['bundled_holds_minimal_duration']) ->setBundledHoldsMaximalDuration($params['bundled_holds_maximal_duration']); @@ -70,4 +70,10 @@ class Class_WebService_SIGB_Koha { public static function reset() { static::$services = []; } + + + protected static function _extractGroupedHoldsItypes($params) { + return array_filter(explode("\n", + $params['grouped_holds_itypes'])); + } } diff --git a/library/Class/WebService/SIGB/Koha/GetRecordsResponseReader.php b/library/Class/WebService/SIGB/Koha/GetRecordsResponseReader.php index ad31261f821576f02a8706ab4f5b3fcacdbb14c9..33d1452fb92fee2e2dd5274a2b902a6f3e07cd86 100644 --- a/library/Class/WebService/SIGB/Koha/GetRecordsResponseReader.php +++ b/library/Class/WebService/SIGB/Koha/GetRecordsResponseReader.php @@ -152,7 +152,13 @@ class Class_WebService_SIGB_Koha_GetRecordsResponseReader { if (!$this->_hasChild('itype', $this->_xml_item)) return $this; - if (in_array((string)$this->_xml_item->itype, $this->_grouped_holds_itypes)) + $itype = strtolower(trim((string) $this->_xml_item->itype)); + $itypes = array_map(function($itype) + { + return strtolower(trim((string) $itype)); + }, $this->_grouped_holds_itypes); + + if (in_array($itype, $itypes)) $this->_item->doRequiresCalendarHold(); return $this; diff --git a/library/Class/WebService/SIGB/Koha/Service.php b/library/Class/WebService/SIGB/Koha/Service.php index 037087058f432405b750baf74792f886630d249a..eb8492f2d2b5cedc4da4ab2f6cf664bc31493325 100644 --- a/library/Class/WebService/SIGB/Koha/Service.php +++ b/library/Class/WebService/SIGB/Koha/Service.php @@ -33,10 +33,6 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR $_bundled_holds_minimal_duration = 0, $_bundled_holds_maximal_duration = 0; - public static function newInstance() { - return new static(); - } - public static function getService($params) { return static::newInstance() diff --git a/library/ZendAfi/View/Helper/BaseHelper.php b/library/ZendAfi/View/Helper/BaseHelper.php index e6d92f6709cc906fa17fc73fbc1bf345cc5d471d..cf4db9a25b04f749c334e52268778df18d22fbde 100644 --- a/library/ZendAfi/View/Helper/BaseHelper.php +++ b/library/ZendAfi/View/Helper/BaseHelper.php @@ -71,6 +71,11 @@ class ZendAfi_View_Helper_BaseHelper extends Zend_View_Helper_HtmlElement { } + protected function _tagSuccess($message) { + return call_user_func_array([$this->view, 'tagSuccess'], func_get_args()); + } + + protected function _tagWarning($message) { return call_user_func_array([$this->view, 'tagWarning'], func_get_args()); } diff --git a/library/ZendAfi/View/Helper/DigitalResource/Dashboard/Harvest.php b/library/ZendAfi/View/Helper/DigitalResource/Dashboard/Harvest.php index bb3ed791f9e472cddca788d09e6e47fd21d136b5..39e5d08723acaca1d51958d9794dd26475eb9c0f 100644 --- a/library/ZendAfi/View/Helper/DigitalResource/Dashboard/Harvest.php +++ b/library/ZendAfi/View/Helper/DigitalResource/Dashboard/Harvest.php @@ -33,6 +33,9 @@ class ZendAfi_View_Helper_DigitalResource_Dashboard_Harvest extends ZendAfi_View protected function _render($config) { $html = [$this->_tag('h3', $this->_('Diagnostic moissonnage'))]; + if ($config->isFirstHarvestAware()) + $html = $this->_addFirstHarvestAware($html, $config); + if (!$config->getBatch()) { $html [] = $this->_tagNotice($this->_('Cette ressource ne prend pas en charge le moissonnage')) ; return implode($html); @@ -51,7 +54,7 @@ class ZendAfi_View_Helper_DigitalResource_Dashboard_Harvest extends ZendAfi_View protected function _getTypedocImage($config){ return $this->_tag('h4', - $this->_('Image du type de document: ') + $this->_('Image du type de document: ') . $config->getTypeDocImage($this->view)); } @@ -106,7 +109,7 @@ class ZendAfi_View_Helper_DigitalResource_Dashboard_Harvest extends ZendAfi_View 'condition' => function($model) { return Class_Users::isCurrentUserSuperAdmin() && $model->isActive(); - }, + }, 'anchorOptions' => ['data-popup' => 'true']], ['url' => '/admin/batch/run/id/%s', @@ -200,4 +203,52 @@ class ZendAfi_View_Helper_DigitalResource_Dashboard_Harvest extends ZendAfi_View $this->_('Nombre de notices présentes dans Bokeh : %d', $count)), $records_link]); } + + + protected function _addFirstHarvestAware($html, $config) { + if ( $harvest_done = $config->isFirstHarvestDone()) + $html [] = $this->_tagSuccess($this->_('Le premier moissonnage a été effectué.')); + + if ( $import_done = $config->isFirstImportDone()) + $html [] = $this->_tagSuccess($this->_('Le premier import d\'albums a été effectué.')); + + if ( $harvest_done && $import_done) + return $html = $this->_allowDeletionOfFiles($html, $config); + + $html [] = $this->_tagError($this->_('Cette ressource nécessite un premier moissonnage manuel et un premier import manuel.')); + + $html [] = $this->_tagError($this->_('Vous devez contacter votre hébergeur pour réaliser ces actions.')); + + if ( $harvest_running = $config->isFirstHarvestRunning() ) + $html [] = $this->_tagWarning($this->_('Le premier moissonnage d\'albums est en cours.')); + + if ( $import_running = $config->isFirstImportRunning() ) + $html [] = $this->_tagWarning($this->_('Le premier import d\'albums est en cours.')); + + $html [] = $this->_tagError($this->_('En attendant le batch %s ne doit ni être lancé ni être plannifié.', + $config->getBatchInstance()->getLabel())); + + return $html; + } + + + protected function _allowDeletionOfFiles($html, $config) { + $importer = $config->getImporterInstance(); + + if ($userfiles_folder = $importer->getUserfilesFolderToDelete()) { + $delete_folder_anchor = + $this->view->tagAnchor($this->_url(['module' => 'admin', + 'controller' => 'file-manager', + 'action' => 'delete', + 'item' => $userfiles_folder], + null, true), + $this->_('Supprimer')); + + $html [] = $this->_tagNotice($this->_('Vous pouvez supprimer le dossier %s dans l\'explorateur de fichier : %s', + $userfiles_folder, + $delete_folder_anchor)); + } + + return $html; + } } \ No newline at end of file diff --git a/library/digital_resources/DiMusic/Config.php b/library/digital_resources/DiMusic/Config.php index bf5750388727ee271f39c939dfd8811af4bafcfa..5e2e95fb00dd69b8cad7ebb8ad6eeb09aa006e43 100644 --- a/library/digital_resources/DiMusic/Config.php +++ b/library/digital_resources/DiMusic/Config.php @@ -38,6 +38,9 @@ class DiMusic_Config extends Class_DigitalResource_Config { 'Service' => $this->withNameSpace('Service'), 'Batch' => $this->withNameSpace('Batch'), + 'Importer' => $this->withNameSpace('Importer'), + 'Harvester' => $this->withNameSpace('Harvester'), + 'DocTypeLabel' => $this->_('Ressource diMusic'), 'PhoneLabel' => $this->_('Accéder à l\'album'), diff --git a/library/digital_resources/DiMusic/Harvester.php b/library/digital_resources/DiMusic/Harvester.php new file mode 100644 index 0000000000000000000000000000000000000000..a1e75f1141153e5939c1a548e846668f217b9eab --- /dev/null +++ b/library/digital_resources/DiMusic/Harvester.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 DiMusic_Harvester extends Class_DigitalResource_Harvester_OAI {} \ No newline at end of file diff --git a/library/digital_resources/DiMusic/Importer.php b/library/digital_resources/DiMusic/Importer.php new file mode 100644 index 0000000000000000000000000000000000000000..f3d6fb666ec27b760cc115a1d1834628b605dd0e --- /dev/null +++ b/library/digital_resources/DiMusic/Importer.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 DiMusic_Importer extends Class_DigitalResource_Importer_OAI{} diff --git a/library/digital_resources/DiMusic/tests/DiMusicTest.php b/library/digital_resources/DiMusic/tests/DiMusicTest.php index 9beb08b88a23e0109f6a910a9897158f1cce3768..e3501f96f24d0cebd5c01c29e532678684f79c1a 100644 --- a/library/digital_resources/DiMusic/tests/DiMusicTest.php +++ b/library/digital_resources/DiMusic/tests/DiMusicTest.php @@ -44,6 +44,11 @@ abstract class DiMusicActivatedTestCase extends AbstractControllerTestCase { ['id' => 1, 'code' => 'DiMusic']) ->permitTo($group, new Class_Entity()); + + $now = new TimeSourceForTest('2021-11-18 14:21:00'); + + DiMusic_Harvester::setTimeSource($now); + DiMusic_Importer::setTimeSource($now); } } @@ -108,7 +113,7 @@ class DiMusicDashboardUnactivatedTest extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/DiMusic_Plugin', true); + $this->dispatch('/DiMusic_Plugin'); } @@ -128,8 +133,6 @@ class DiMusicDashboardUnactivatedTest extends Admin_AbstractControllerTestCase { class DiMusicDashboardActivatedTest extends DiMusicActivatedTestCase { - protected $_storm_default_to_volatile = true; - public function setUp() { parent::setUp(); @@ -154,7 +157,7 @@ class DiMusicDashboardActivatedTest extends DiMusicActivatedTestCase { 'password' => 'admin', 'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN])); - $this->dispatch('/DiMusic_Plugin', true); + $this->dispatch('/DiMusic_Plugin'); } @@ -199,9 +202,22 @@ class DiMusicDashboardActivatedTest extends DiMusicActivatedTestCase { public function doctypeImageUrlShouldBePresent() { $this->assertXPath('//h4/img[contains(@src, "/digital-resource/typedoc-icon/id/DiMusic")]'); } -} + /** @test */ + public function firstHarvestErrorMessageShouldBeDisplay() { + $this->assertXPathContentContains('//p[@class="error"]', + 'Cette ressource nécessite un premier moissonnage manuel et un premier import manuel.'); + } + + + /** @test */ + public function contextShouldExpectation() { + $this->assertXPathContentContains('//p[@class="error"]', + 'Vous devez contacter votre hébergeur pour réaliser ces actions.'); + } +} + @@ -657,4 +673,444 @@ class DiMusicNoticeAjaxControllerTest extends AbstractControllerTestCase { public function onloadUtilShouldBeLoaded() { $this->assertXPath('//script[contains(@src, "onload_util")]'); } +} + + + + +abstract class DiMusicOAIFirstHarvestTestCase extends DiMusicActivatedTestCase { + protected + $_logger, + $_log = [], + $_web_client, + $_file_system, + $_userfiles, + $_page1, + $_page2, + $_page1_xml, + $_page2_xml; + + + public function setUp() { + parent::setUp(); + + Class_AdminVar::set('DiMusic_Harvest_Url','https://music.divercities.eu/oai'); + + $this->_page1_xml = file_get_contents(__DIR__ . '/oai_page1.xml'); + $this->_page2_xml = file_get_contents(__DIR__ . '/oai_page2.xml'); + + $this->_page1 = $this + ->mock() + ->whenCalled('getModels') + ->answers(1); + + $this->_page2 = $this + ->mock() + ->whenCalled('getModels') + ->answers(1); + + $this->_userfiles = $this + ->mock() + + ->whenCalled('isWritable')->answers(true) + + ->whenCalled('isDir')->answers(true) + + ->whenCalled('getId')->answers('userfiles') + + ->beStrict(); + + $this->_file_system = $this + ->mock() + + ->whenCalled('disableCache') + ->answers(true) + + ->beStrict(); + + $this->_web_client = $this + ->mock() + ->beStrict(); + + Class_FileManager::setFileSystem($this->_file_system); + Class_WebService_OAI::setWebClient($this->_web_client); + } +} + + + + +class DiMusicHarvesterTest extends DiMusicOAIFirstHarvestTestCase { + + public function setUp() { + parent::setUp(); + + $this->_file_system + ->whenCalled('filesAt')->with('userfiles/dimusic_oai_xml_responses') + ->answers([$this->_page1, $this->_page2]) + + ->whenCalled('directoryAt')->with('userfiles') + ->answers($this->_userfiles) + + ->whenCalled('create')->with('userfiles/dimusic_oai_xml_responses') + ->answers(true) + + ->whenCalled('createImage')->with('userfiles/dimusic_oai_xml_responses/1.xml', + $this->_page1_xml) + ->answers(true) + + ->whenCalled('createImage')->with('userfiles/dimusic_oai_xml_responses/2.xml', + $this->_page2_xml) + ->answers(true); + + $this->_web_client + ->whenCalled('open_url')->with('https://music.divercities.eu/oai?verb=ListRecords&metadataPrefix=oai1dtouch_dc') + ->answers($this->_page1_xml) + + ->whenCalled('open_url') + ->with('https://music.divercities.eu/oai?verb=ListRecords&resumptionToken=oai1dtouch_dc.f%282015-02-09T08%3A46%3A09Z%29.u%282015-02-09T08%3A47%3A27Z%29%3A133') + ->answers($this->_page2_xml); + + $this->_logger = new Class_Cata_LogVolatile; + $harvester = (new DiMusic_Harvester) + ->setLogger($this->_logger); + $harvester->run(); + $this->_log = $this->_logger->getLines(); + } + + + /** @test */ + public function diMusicHarvestShouldCollectOAI() { + $page1_start = substr($this->_page1_xml, 0, 200); + $page1_end = substr($this->_page1_xml, -200); + + $page2_start = substr($this->_page2_xml, 0, 200); + $page2_end = substr($this->_page2_xml, -200); + + $this->assertEquals(["\nDiMusic : Début premier moissonnage de l'OAI à 2021-11-18 14:21:00.", + "\nSuppression des précédents journaux de moissonnage de DiMusic.", + "\nSuppression des fichiers XML existants dans userfiles/dimusic_oai_xml_responses", + "\nDébut du moissonnage.", + "Url : https://music.divercities.eu/oai?verb=ListRecords&metadataPrefix=oai1dtouch_dc", + "Réponse :", + $page1_start, + "[…]", + $page1_end, + "Url : https://music.divercities.eu/oai?verb=ListRecords&resumptionToken=oai1dtouch_dc.f%282015-02-09T08%3A46%3A09Z%29.u%282015-02-09T08%3A47%3A27Z%29%3A133", + "Réponse :", + $page2_start, + "[…]", + $page2_end, + "\n2 fichiers sauvegardés.", + "\nDiMusic : Fin du premier moissonnage de l'OAI à 2021-11-18 14:21:00."], + $this->_log); + } + + + /** @test */ + public function harvestLogShouldHaveBeenCreated() { + $this->assertNotNull(Class_WebService_HarvestLog::find(1)); + } +} + + + + +class DiMusicImporterTest extends DiMusicOAIFirstHarvestTestCase { + + + public function setUp() { + parent::setUp(); + + + $this->fixture(Class_Album::class, + ['id' => 1, + 'titre' => 'old_album', + 'type_doc_id' => 'DiMusic']); + + $this->_page1 + ->whenCalled('getContent') + ->answers($this->_page1_xml) + + ->whenCalled('getPath') + ->answers('userfiles/dimusic_oai_xml_responses/1.xml') + + ->whenCalled('isWritable') + ->answers(true) + + ->whenCalled('isDir') + ->answers(false) + + ->whenCalled('getId') + ->answers('userfiles/dimusic_oai_xml_responses/1.xml') + + ->whenCalled('getName') + ->answers('1.xml'); + + $this->_page2 + ->whenCalled('getContent') + ->answers($this->_page2_xml) + + ->whenCalled('getPath') + ->answers('userfiles/dimusic_oai_xml_responses/2.xml') + + ->whenCalled('isWritable') + ->answers(true) + + ->whenCalled('isDir') + ->answers(false) + + ->whenCalled('getName') + ->answers('2.xml') + + ->whenCalled('getId') + ->answers('userfiles/dimusic_oai_xml_responses/2.xml'); + + $dimusic_oai_xml_responses = $this + ->mock() + ->whenCalled('isWritable') + ->answers(true) + + ->whenCalled('isDir') + ->answers(true) + + ->whenCalled('getId') + ->answers('dimusic_oai_xml_responses'); + + $this->_file_system + ->whenCalled('directoryAt')->with('userfiles/dimusic_oai_xml_responses') + ->answers($dimusic_oai_xml_responses) + + ->whenCalled('filesAt')->with('userfiles/dimusic_oai_xml_responses/done') + ->answers([]) + + ->whenCalled('create')->with('dimusic_oai_xml_responses/done') + ->answers(true) + + ->whenCalled('filesAt')->with('userfiles/dimusic_oai_xml_responses') + ->answers([$this->_page1, $this->_page2]) + + ->whenCalled('rename')->with('userfiles/dimusic_oai_xml_responses/1.xml', + 'userfiles/dimusic_oai_xml_responses/done/1.xml') + ->answers(true) + + ->whenCalled('rename')->with('userfiles/dimusic_oai_xml_responses/2.xml', + 'userfiles/dimusic_oai_xml_responses/done/2.xml') + ->answers(true); + + $this->_logger = new Class_Cata_LogVolatile; + (new DiMusic_Importer) + ->setLogger($this->_logger) + ->run(); + + $this->_log = $this->_logger->getLines(); + } + + + /** @test */ + public function diMusicImporterShouldCreateFourAlbums() { + $this->assertEquals(4, Class_Album::countBy(['type_doc_id' => DiMusic_Config::getInstance()->getDocType()])); + } + + + /** @test */ + public function diMusicImportLogShouldBeHasExpected() { + $this->assertEquals(["\nDiMusic : Début premier import des albums à 2021-11-18 14:21:00.", + "\nDiMusic : suppression des albums existants", + "\n1/1", + "\nDiMusic : création des albums.", + "\nTraitement du fichier : userfiles/dimusic_oai_xml_responses/1.xml. 1/2", + "\nTraitement du fichier : userfiles/dimusic_oai_xml_responses/2.xml. 2/2", + "\nDiMusic : Fin du premier import des albums à 2021-11-18 14:21:00."], + $this->_log); + } +} + + + + +class DiMusicOAIFirstHarvestLoadingTest extends DiMusicActivatedTestCase { + /** @test */ + public function diMusicHarvesterShouldExists() { + $this->assertEquals(['DiMusic' => (new DiMusic_Harvester)], Class_DigitalResource::getInstance()->getHarvesters()); + } + + + /** @test */ + public function diMusicImporterShouldExists() { + $this->assertEquals(['DiMusic' => (new DiMusic_Importer)], Class_DigitalResource::getInstance()->getImporters()); + } +} + + + + +class DiMusicDashboardActivatedAndFirstRunDoneTest extends DiMusicActivatedTestCase { + + public function setUp() { + parent::setUp(); + + $album = $this->fixture('Class_Album', + ['id' => 20, + 'titre' => '10 moutons', + 'type_doc_id' => 'DiMusic', + ]); + + $album->addPosterURI('https://assest.server.eu/cargo/1.jpg') + ->assertSave(); + + Class_WebService_BibNumerique_Vignette::setHttpClient($this->mock() + ->whenCalled('getResponse') + ->answers(new Class_Testing_HttpResponse(['Body' => true]))); + + ZendAfi_Auth::getInstance() + ->logUser($this->fixture('Class_Users', + ['id' => 2, + 'login' => 'admin', + 'password' => 'admin', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN])); + + $this->fixture(Class_WebService_HarvestLog::class, + ['id' => 1, + 'type_doc' => 'DiMusic']); + + $file_system = $this + ->mock() + + ->whenCalled('disableCache') + ->answers(true) + + ->whenCalled('directoryAt')->with('userfiles/dimusic_oai_xml_responses/done') + ->answers(true) + + ->beStrict(); + + Class_FileManager::setFileSystem($file_system); + + $this->dispatch('/DiMusic_Plugin'); + } + + + public function tearDown() { + Class_WebService_BibNumerique_Vignette::setHttpClient(null); + parent::tearDown(); + } + + + /** @test */ + public function shouldDisplayActivated() { + $this->assertXPathContentContains('//button', 'Activé'); + } + + + /** @test */ + public function firstImportSuccessMessageShouldBeDisplay() { + $this->assertXPathContentContains('//p[@class="success"]', + 'Le premier import d\'albums a été effectué.'); + } + + + /** @test */ + public function firstHarvestSuccessMessageShouldBeDisplay() { + $this->assertXPathContentContains('//p[@class="success"]', + 'Le premier moissonnage a été effectué.'); + } + + + /** @test */ + public function removeDiMusicFilesMessageShouldBeDisplay() { + $this->assertXPathContentContains('//p[@class="notice"]', + 'Vous pouvez supprimer le dossier userfiles/dimusic_oai_xml_responses dans l\'explorateur de fichier :'); + } + + + /** @test */ + public function removeDiMusicLinkShouldBeDisplay() { + $this->assertXPathContentContains('//p[@class="notice"]//a[@href = "/admin/file-manager/delete/item/userfiles%2Fdimusic_oai_xml_responses"]', + 'Supprimer'); + } +} + + + +class DiMusicDashboardActivatedAndFirstRunRunningTest extends DiMusicActivatedTestCase { + + public function setUp() { + parent::setUp(); + + $album = $this->fixture('Class_Album', + ['id' => 20, + 'titre' => '10 moutons', + 'type_doc_id' => 'DiMusic', + ]); + + $album->addPosterURI('https://assest.server.eu/cargo/1.jpg') + ->assertSave(); + + Class_WebService_BibNumerique_Vignette::setHttpClient($this->mock() + ->whenCalled('getResponse') + ->answers(new Class_Testing_HttpResponse(['Body' => true]))); + + ZendAfi_Auth::getInstance() + ->logUser($this->fixture('Class_Users', + ['id' => 2, + 'login' => 'admin', + 'password' => 'admin', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN])); + + $file_system = $this + ->mock() + + ->whenCalled('disableCache') + ->answers(true) + + ->whenCalled('directoryAt')->with('userfiles/dimusic_oai_xml_responses/done') + ->answers(true) + + ->whenCalled('directoryAt')->with('userfiles/dimusic_oai_xml_responses') + ->answers(true) + + ->whenCalled('countFilesIn')->with('userfiles/dimusic_oai_xml_responses') + ->answers(3) + + ->beStrict(); + + Class_FileManager::setFileSystem($file_system); + + $this->dispatch('/DiMusic_Plugin'); + } + + + public function tearDown() { + Class_WebService_BibNumerique_Vignette::setHttpClient(null); + Class_FileManager::reset(); + parent::tearDown(); + } + + + /** @test */ + public function shouldDisplayActivated() { + $this->assertXPathContentContains('//button', 'Activé'); + } + + + /** @test */ + public function firstImportSuccessMessageShouldBeDisplay() { + $this->assertXPathContentContains('//p[@class="warning"]', + 'Le premier import d\'albums est en cours.'); + } + + + /** @test */ + public function firstHarvestSuccessMessageShouldBeDisplay() { + $this->assertXPathContentContains('//p[@class="warning"]', + 'Le premier moissonnage d\'albums est en cours.'); + } + + + /** @test */ + public function removeDiMusicLinkShouldBeDisplay() { + $this->assertNotXPathContentContains('//p[@class="notice"]//a', + 'Supprimer'); + } } \ No newline at end of file diff --git a/library/digital_resources/DiMusic/tests/oai_page1.xml b/library/digital_resources/DiMusic/tests/oai_page1.xml index 5e92ceb4c116b36df9feaa36311ceb24948d6ad3..c4fb631a08080d1dc0e70840a0183d66867c2c82 100644 --- a/library/digital_resources/DiMusic/tests/oai_page1.xml +++ b/library/digital_resources/DiMusic/tests/oai_page1.xml @@ -7,639 +7,637 @@ <ListRecords> <record> <header status="deleted"> - <identifier>oai:oai1dtouch.com/album2</identifier> - <datestamp>2017-02-22T12:46:19Z</datestamp> - <setSpec>music</setSpec> + <identifier>oai:oai1dtouch.com/album2</identifier> + <datestamp>2017-02-22T12:46:19Z</datestamp> + <setSpec>music</setSpec> </header> </record> <record> <header> - <identifier>oai:oai1dtouch.com:124 - </identifier> - <datestamp>2015-02-09T08:47:27Z - </datestamp> + <identifier>oai:oai1dtouch.com:124 + </identifier> + <datestamp>2015-02-09T08:47:27Z + </datestamp> </header> <metadata> - <oai1dtouch_dc xmlns="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/ http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc.xsd"> - <id>124 - </id> - <icpn>3610159181474 - </icpn> - <title>WOLFEP0241</title> - <description>A Dance House music album</description> - <date>2014-11-03T00:00:00Z - </date> - <label>Wolf Music Recordings - </label> - <cover_url>https://commondatastorage.googleapis.com/music-staging/cargo/medium_3610159181474.jpg - </cover_url> - <url>http://music.1dtouch.com/albums/124 - </url> - <artists> - <artist>Ishmael - </artist> - </artists> - <styles> - <style>Dance - </style> - <style>House - </style> - <style>Deep - </style> - </styles> - <tracks> - <track> - <id>1789AEYU89 - </id> - <isrc>GB2SA1200088 - </isrc> - <position>1 - </position> - <title>Dejong - </title> - <length>PT0H7M20S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200088_320k.mp3 - </url> - <artists> - <artist>Ishmael - </artist> - </artists> - </track> - <track> - <isrc>GB2SA1200089 - </isrc> - <position>2 - </position> - <title>Takoma - </title> - <length>PT0H5M30S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200089_320k.mp3 - </url> - <artists> - <artist>Ishmael - </artist> - </artists> - </track> - <track> - <isrc>GB2SA1200090 - </isrc> - <position>3 - </position> - <title>Ashbury Roll - </title> - <length>PT0H5M26S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200090_320k.mp3 - </url> - <artists> - <artist>Ishmael - </artist> - </artists> - </track> - <track> - <isrc>GB2SA1200091 - </isrc> - <position>4 - </position> - <title>Takoma - </title> - <length>PT0H7M13S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200091_320k.mp3 - </url> - <artists> - <artist>Ishmael - </artist> - </artists> - </track> - </tracks> - </oai1dtouch_dc> + <oai1dtouch_dc xmlns="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/ http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc.xsd"> + <id>124 + </id> + <icpn>3610159181474 + </icpn> + <title>WOLFEP0241</title> + <description>A Dance House music album</description> + <date>2014-11-03T00:00:00Z + </date> + <label>Wolf Music Recordings + </label> + <cover_url>https://commondatastorage.googleapis.com/music-staging/cargo/medium_3610159181474.jpg + </cover_url> + <url>http://music.1dtouch.com/albums/124 + </url> + <artists> + <artist>Ishmael + </artist> + </artists> + <styles> + <style>Dance + </style> + <style>House + </style> + <style>Deep + </style> + </styles> + <tracks> + <track> + <id>1789AEYU89 + </id> + <isrc>GB2SA1200088 + </isrc> + <position>1 + </position> + <title>Dejong + </title> + <length>PT0H7M20S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200088_320k.mp3 + </url> + <artists> + <artist>Ishmael + </artist> + </artists> + </track> + <track> + <isrc>GB2SA1200089 + </isrc> + <position>2 + </position> + <title>Takoma + </title> + <length>PT0H5M30S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200089_320k.mp3 + </url> + <artists> + <artist>Ishmael + </artist> + </artists> + </track> + <track> + <isrc>GB2SA1200090 + </isrc> + <position>3 + </position> + <title>Ashbury Roll + </title> + <length>PT0H5M26S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200090_320k.mp3 + </url> + <artists> + <artist>Ishmael + </artist> + </artists> + </track> + <track> + <isrc>GB2SA1200091 + </isrc> + <position>4 + </position> + <title>Takoma + </title> + <length>PT0H7M13S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200091_320k.mp3 + </url> + <artists> + <artist>Ishmael + </artist> + </artists> + </track> + </tracks> + </oai1dtouch_dc> </metadata> </record> <record> <header> - <identifier>oai:oai1dtouch.com:125 - </identifier> - <datestamp>2015-02-09T08:47:27Z - </datestamp> + <identifier>oai:oai1dtouch.com:125 + </identifier> + <datestamp>2015-02-09T08:47:27Z + </datestamp> </header> <metadata> - <oai1dtouch_dc xmlns="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/ http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc.xsd"> - <id>125 - </id> - <icpn>3610159181993 - </icpn> - <title>Ataché - </title> - <date>2014-11-06T00:00:00Z - </date> - <label>Altino's Music / Couleurs Music Publishing - </label> - <cover_url>https://commondatastorage.googleapis.com/music-staging/cargo/medium_3610159181993.jpg - </cover_url> - <url>http://music.1dtouch.com/albums/125 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - <styles> - <style>World - </style> - </styles> - <tracks> - <track> - <isrc>GBGYQ1400032 - </isrc> - <position>1 - </position> - <title>Pa kite - </title> - <length>PT0H4M54S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400032_320k.mp3 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - </track> - <track> - <isrc>FR6V82527830 - </isrc> - <position>2 - </position> - <title>Nou pare - </title> - <length>PT0H3M50S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr6v82527830_320k.mp3 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - </track> - <track> - <isrc>GBGYQ1400033 - </isrc> - <position>3 - </position> - <title>Manvi kwazé L - </title> - <length>PT0H3M27S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400033_320k.mp3 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - </track> - <track> - <isrc>GBGYQ1400034 - </isrc> - <position>4 - </position> - <title>Kite L ale - </title> - <length>PT0H4M38S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400034_320k.mp3 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - </track> - <track> - <isrc>GBGYQ1400035 - </isrc> - <position>5 - </position> - <title>Pale yo - </title> - <length>PT0H3M39S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400035_320k.mp3 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - </track> - <track> - <isrc>GBGYQ1400036 - </isrc> - <position>6 - </position> - <title>Love Me - </title> - <length>PT0H4M14S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400036_320k.mp3 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - </track> - <track> - <isrc>GBGYQ1200019 - </isrc> - <position>7 - </position> - <title>N'oublies pas - </title> - <length>PT0H3M50S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1200019_320k.mp3 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - </track> - <track> - <isrc>GBGYQ1400037 - </isrc> - <position>8 - </position> - <title>Mèt bliye M - </title> - <length>PT0H3M43S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400037_320k.mp3 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - </track> - <track> - <isrc>GBGYQ1400038 - </isrc> - <position>9 - </position> - <title>Mesi manman - </title> - <length>PT0H4M35S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400038_320k.mp3 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - </track> - <track> - <isrc>GBGYQ1400039 - </isrc> - <position>10 - </position> - <title>San ou - </title> - <length>PT0H4M14S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400039_320k.mp3 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - </track> - <track> - <isrc>GBGYQ1400040 - </isrc> - <position>11 - </position> - <title>Sere mwen - </title> - <length>PT0H4M20S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400040_320k.mp3 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - </track> - <track> - <isrc>GBGYQ1400041 - </isrc> - <position>12 - </position> - <title>Nouvèl la gaye - </title> - <length>PT0H3M44S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400041_320k.mp3 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - </track> - <track> - <isrc>GBGYQ1400042 - </isrc> - <position>13 - </position> - <title>Yo met pale - </title> - <length>PT0H4M6S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400042_320k.mp3 - </url> - <artists> - <artist>T-Micky - </artist> - </artists> - </track> - </tracks> - </oai1dtouch_dc> + <oai1dtouch_dc xmlns="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/ http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc.xsd"> + <id>125 + </id> + <icpn>3610159181993 + </icpn> + <title>Ataché + </title> + <date>2014-11-06T00:00:00Z + </date> + <label>Altino's Music / Couleurs Music Publishing + </label> + <cover_url>https://commondatastorage.googleapis.com/music-staging/cargo/medium_3610159181993.jpg + </cover_url> + <url>http://music.1dtouch.com/albums/125 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + <styles> + <style>World + </style> + </styles> + <tracks> + <track> + <isrc>GBGYQ1400032 + </isrc> + <position>1 + </position> + <title>Pa kite + </title> + <length>PT0H4M54S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400032_320k.mp3 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + </track> + <track> + <isrc>FR6V82527830 + </isrc> + <position>2 + </position> + <title>Nou pare + </title> + <length>PT0H3M50S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr6v82527830_320k.mp3 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + </track> + <track> + <isrc>GBGYQ1400033 + </isrc> + <position>3 + </position> + <title>Manvi kwazé L + </title> + <length>PT0H3M27S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400033_320k.mp3 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + </track> + <track> + <isrc>GBGYQ1400034 + </isrc> + <position>4 + </position> + <title>Kite L ale + </title> + <length>PT0H4M38S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400034_320k.mp3 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + </track> + <track> + <isrc>GBGYQ1400035 + </isrc> + <position>5 + </position> + <title>Pale yo + </title> + <length>PT0H3M39S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400035_320k.mp3 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + </track> + <track> + <isrc>GBGYQ1400036 + </isrc> + <position>6 + </position> + <title>Love Me + </title> + <length>PT0H4M14S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400036_320k.mp3 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + </track> + <track> + <isrc>GBGYQ1200019 + </isrc> + <position>7 + </position> + <title>N'oublies pas + </title> + <length>PT0H3M50S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1200019_320k.mp3 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + </track> + <track> + <isrc>GBGYQ1400037 + </isrc> + <position>8 + </position> + <title>Mèt bliye M + </title> + <length>PT0H3M43S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400037_320k.mp3 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + </track> + <track> + <isrc>GBGYQ1400038 + </isrc> + <position>9 + </position> + <title>Mesi manman + </title> + <length>PT0H4M35S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400038_320k.mp3 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + </track> + <track> + <isrc>GBGYQ1400039 + </isrc> + <position>10 + </position> + <title>San ou + </title> + <length>PT0H4M14S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400039_320k.mp3 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + </track> + <track> + <isrc>GBGYQ1400040 + </isrc> + <position>11 + </position> + <title>Sere mwen + </title> + <length>PT0H4M20S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400040_320k.mp3 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + </track> + <track> + <isrc>GBGYQ1400041 + </isrc> + <position>12 + </position> + <title>Nouvèl la gaye + </title> + <length>PT0H3M44S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400041_320k.mp3 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + </track> + <track> + <isrc>GBGYQ1400042 + </isrc> + <position>13 + </position> + <title>Yo met pale + </title> + <length>PT0H4M6S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gbgyq1400042_320k.mp3 + </url> + <artists> + <artist>T-Micky + </artist> + </artists> + </track> + </tracks> + </oai1dtouch_dc> </metadata> </record> <record> <header> - <identifier>oai:oai1dtouch.com:126 - </identifier> - <datestamp>2015-02-09T08:47:27Z - </datestamp> + <identifier>oai:oai1dtouch.com:126 + </identifier> + <datestamp>2015-02-09T08:47:27Z + </datestamp> </header> <metadata> - <oai1dtouch_dc xmlns="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/ http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc.xsd"> - <id>126 - </id> - <icpn>3610159198724 - </icpn> - <title>Impact - </title> - <date>2015-01-12T00:00:00Z - </date> - <label>Karlito - </label> - <cover_url>https://commondatastorage.googleapis.com/music-staging/cargo/medium_3610159198724.jpg - </cover_url> - <url>http://music.1dtouch.com/albums/126 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - <styles> - <style>Hip Hop - </style> - <style>French Hip Hop - </style> - </styles> - <tracks> - <track> - <isrc>FR10S1493172 - </isrc> - <position>1 - </position> - <title>Undercover - </title> - <length>PT0H3M22S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493172_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493173 - </isrc> - <position>2 - </position> - <title>Le zoo - </title> - <length>PT0H3M10S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493173_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493174 - </isrc> - <position>3 - </position> - <title>Continue - </title> - <length>PT0H4M17S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493174_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493175 - </isrc> - <position>4 - </position> - <title>A la kiss - </title> - <length>PT0H3M6S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493175_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493176 - </isrc> - <position>5 - </position> - <title>Banga - </title> - <length>PT0H1M41S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493176_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493177 - </isrc> - <position>6 - </position> - <title>Ego - </title> - <length>PT0H3M37S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493177_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493178 - </isrc> - <position>7 - </position> - <title>O.Dog Psycho - </title> - <length>PT0H3M17S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493178_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493179 - </isrc> - <position>8 - </position> - <title>Affranchis - </title> - <length>PT0H3M12S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493179_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493180 - </isrc> - <position>9 - </position> - <title>Biz Biz - </title> - <length>PT0H1M22S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493180_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493181 - </isrc> - <position>10 - </position> - <title>Ghetto Youth - </title> - <length>PT0H3M42S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493181_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493182 - </isrc> - <position>11 - </position> - <title>Défoncer - </title> - <length>PT0H3M5S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493182_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493183 - </isrc> - <position>12 - </position> - <title>Illimité - </title> - <length>PT0H4M22S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493183_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493184 - </isrc> - <position>13 - </position> - <title>No Drama - </title> - <length>PT0H3M35S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493184_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493185 - </isrc> - <position>14 - </position> - <title>La folie - </title> - <length>PT0H3M48S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493185_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - <track> - <isrc>FR10S1493186 - </isrc> - <position>15 - </position> - <title>Victoria - </title> - <length>PT0H4M46S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493186_320k.mp3 - </url> - <artists> - <artist>Karlito - </artist> - </artists> - </track> - </tracks> - </oai1dtouch_dc> + <oai1dtouch_dc xmlns="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/ http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc.xsd"> + <id>126 + </id> + <icpn>3610159198724 + </icpn> + <title>Impact + </title> + <date>2015-01-12T00:00:00Z + </date> + <label>Karlito + </label> + <cover_url>https://commondatastorage.googleapis.com/music-staging/cargo/medium_3610159198724.jpg + </cover_url> + <url>http://music.1dtouch.com/albums/126 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + <styles> + <style>Hip Hop + </style> + <style>French Hip Hop + </style> + </styles> + <tracks> + <track> + <isrc>FR10S1493172 + </isrc> + <position>1 + </position> + <title>Undercover + </title> + <length>PT0H3M22S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493172_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493173 + </isrc> + <position>2 + </position> + <title>Le zoo + </title> + <length>PT0H3M10S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493173_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493174 + </isrc> + <position>3 + </position> + <title>Continue + </title> + <length>PT0H4M17S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493174_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493175 + </isrc> + <position>4 + </position> + <title>A la kiss + </title> + <length>PT0H3M6S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493175_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493176 + </isrc> + <position>5 + </position> + <title>Banga + </title> + <length>PT0H1M41S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493176_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493177 + </isrc> + <position>6 + </position> + <title>Ego + </title> + <length>PT0H3M37S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493177_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493178 + </isrc> + <position>7 + </position> + <title>O.Dog Psycho + </title> + <length>PT0H3M17S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493178_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493179 + </isrc> + <position>8 + </position> + <title>Affranchis + </title> + <length>PT0H3M12S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493179_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493180 + </isrc> + <position>9 + </position> + <title>Biz Biz + </title> + <length>PT0H1M22S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493180_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493181 + </isrc> + <position>10 + </position> + <title>Ghetto Youth + </title> + <length>PT0H3M42S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493181_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493182 + </isrc> + <position>11 + </position> + <title>Défoncer + </title> + <length>PT0H3M5S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493182_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493183 + </isrc> + <position>12 + </position> + <title>Illimité + </title> + <length>PT0H4M22S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493183_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493184 + </isrc> + <position>13 + </position> + <title>No Drama + </title> + <length>PT0H3M35S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493184_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493185 + </isrc> + <position>14 + </position> + <title>La folie + </title> + <length>PT0H3M48S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493185_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + <track> + <isrc>FR10S1493186 + </isrc> + <position>15 + </position> + <title>Victoria + </title> + <length>PT0H4M46S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/fr10s1493186_320k.mp3 + </url> + <artists> + <artist>Karlito + </artist> + </artists> + </track> + </tracks> + </oai1dtouch_dc> </metadata> </record> - - -<resumptionToken>oai1dtouch_dc.f(2015-02-09T08:46:09Z).u(2015-02-09T08:47:27Z):133</resumptionToken></ListRecords></OAI-PMH> + <resumptionToken>oai1dtouch_dc.f(2015-02-09T08:46:09Z).u(2015-02-09T08:47:27Z):133</resumptionToken></ListRecords></OAI-PMH> diff --git a/library/digital_resources/DiMusic/tests/oai_page2.xml b/library/digital_resources/DiMusic/tests/oai_page2.xml index bfa106a4d517a166463d0273dcf2a9036177630d..ffd514a10980087d4dd4bedb193b34fad3c0527a 100644 --- a/library/digital_resources/DiMusic/tests/oai_page2.xml +++ b/library/digital_resources/DiMusic/tests/oai_page2.xml @@ -7,107 +7,107 @@ <ListRecords> <record> <header> - <identifier>oai:oai1dtouch.com:128 - </identifier> - <datestamp>2015-02-09T08:47:27Z - </datestamp> + <identifier>oai:oai1dtouch.com:128 + </identifier> + <datestamp>2015-02-09T08:47:27Z + </datestamp> </header> <metadata> - <oai1dtouch_dc xmlns="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/ http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc.xsd"> - <id>128 - </id> - <icpn>3610159181474 - </icpn> - <title>WOLFEP026 - </title> - <date>2014-11-03T00:00:00Z - </date> - <label>Wolf Music Recordings - </label> - <cover_url>https://commondatastorage.googleapis.com/music-staging/cargo/medium_3610159181474.jpg - </cover_url> - <url>http://music.1dtouch.com/albums/124 - </url> - <artists> - <artist>Ishmael - </artist> - </artists> - <styles> - <style>Dance - </style> - <style>House - </style> - <style>Deep - </style> - </styles> - <tracks> - <track> - <isrc>GB2SA1200088 - </isrc> - <position>1 - </position> - <title>Dejong - </title> - <length>PT0H7M20S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200088_320k.mp3 - </url> - <artists> - <artist>Ishmael - </artist> - </artists> - </track> - <track> - <isrc>GB2SA1200089 - </isrc> - <position>2 - </position> - <title>Takoma - </title> - <length>PT0H5M30S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200089_320k.mp3 - </url> - <artists> - <artist>Ishmael - </artist> - </artists> - </track> - <track> - <isrc>GB2SA1200090 - </isrc> - <position>3 - </position> - <title>Ashbury Roll - </title> - <length>PT0H5M26S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200090_320k.mp3 - </url> - <artists> - <artist>Ishmael - </artist> - </artists> - </track> - <track> - <isrc>GB2SA1200091 - </isrc> - <position>4 - </position> - <title>Takoma - </title> - <length>PT0H7M13S - </length> - <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200091_320k.mp3 - </url> - <artists> - <artist>Ishmael - </artist> - </artists> - </track> - </tracks> - </oai1dtouch_dc> + <oai1dtouch_dc xmlns="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc/ http://dev.1dtouch.com/OAI/2.0/oai1dtouch_dc.xsd"> + <id>128 + </id> + <icpn>3610159181474 + </icpn> + <title>WOLFEP026 + </title> + <date>2014-11-03T00:00:00Z + </date> + <label>Wolf Music Recordings + </label> + <cover_url>https://commondatastorage.googleapis.com/music-staging/cargo/medium_3610159181474.jpg + </cover_url> + <url>http://music.1dtouch.com/albums/124 + </url> + <artists> + <artist>Ishmael + </artist> + </artists> + <styles> + <style>Dance + </style> + <style>House + </style> + <style>Deep + </style> + </styles> + <tracks> + <track> + <isrc>GB2SA1200088 + </isrc> + <position>1 + </position> + <title>Dejong + </title> + <length>PT0H7M20S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200088_320k.mp3 + </url> + <artists> + <artist>Ishmael + </artist> + </artists> + </track> + <track> + <isrc>GB2SA1200089 + </isrc> + <position>2 + </position> + <title>Takoma + </title> + <length>PT0H5M30S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200089_320k.mp3 + </url> + <artists> + <artist>Ishmael + </artist> + </artists> + </track> + <track> + <isrc>GB2SA1200090 + </isrc> + <position>3 + </position> + <title>Ashbury Roll + </title> + <length>PT0H5M26S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200090_320k.mp3 + </url> + <artists> + <artist>Ishmael + </artist> + </artists> + </track> + <track> + <isrc>GB2SA1200091 + </isrc> + <position>4 + </position> + <title>Takoma + </title> + <length>PT0H7M13S + </length> + <url>https://commondatastorage.googleapis.com/music-staging/cargo/gb2sa1200091_320k.mp3 + </url> + <artists> + <artist>Ishmael + </artist> + </artists> + </track> + </tracks> + </oai1dtouch_dc> </metadata> </record> -<resumptionToken></resumptionToken> + <resumptionToken></resumptionToken> </ListRecords></OAI-PMH> diff --git a/library/templates/Intonation/Library/AjaxPaginatedListHelper.php b/library/templates/Intonation/Library/AjaxPaginatedListHelper.php index f6df317b087ae367155092637a3b3cf093f3a3c9..a66a17c1a6cfc39b1969ecff6652e304a8d4e2dc 100644 --- a/library/templates/Intonation/Library/AjaxPaginatedListHelper.php +++ b/library/templates/Intonation/Library/AjaxPaginatedListHelper.php @@ -139,10 +139,11 @@ class Intonation_Library_AjaxPaginatedListHelper { return $this->_collection_ids = $this->getCollection() - ->select(function($wrapper) - { - return $wrapper->getId(); - }); + ->injectInto([], function($ids, $wrapper) + { + $ids [] = get_class($wrapper) . ':' . $wrapper->getId(); + return $ids; + }); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/Abstract.php index fc62551da387f6042ee6d6b5067d2297db812f0f..751235c53ad7225bef956f243a051716d259476f 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/Abstract.php @@ -37,7 +37,7 @@ abstract class Intonation_Library_View_Wrapper_Abstract { public function __sleep() { if ($this->_model) { - $this->_model_id = $this->getModelId(); + $this->_model_id = $this->getId(); $this->_model_classname = $this->getModelClassname(); } @@ -58,7 +58,16 @@ abstract class Intonation_Library_View_Wrapper_Abstract { public function getId() { - return $this->_model_id; + return $this->_model_id + ? $this->_model_id + : $this->_model_id = $this->_getModelId(); + } + + + protected function _getModelId() { + return $this->_model + ? $this->_model->getId() + : ''; } @@ -94,11 +103,6 @@ abstract class Intonation_Library_View_Wrapper_Abstract { } - public function getModelId() { - return $this->_model->getId(); - } - - public function getAnchor() { return ''; } diff --git a/library/templates/Intonation/Library/View/Wrapper/AbstractCardOperation.php b/library/templates/Intonation/Library/View/Wrapper/AbstractCardOperation.php new file mode 100644 index 0000000000000000000000000000000000000000..eddd7fe15c0edc29ef3c6da9c6ce244eb8d41baa --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/AbstractCardOperation.php @@ -0,0 +1,159 @@ +<?php +/** + * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +abstract class Intonation_Library_View_Wrapper_AbstractCardOperation extends Intonation_Library_View_Wrapper_Abstract { + + protected + $_operation, + $_record_cache, + $_ready, + $_library_label, + $_end_availability; + + + public function __sleep() { + $this->_operation = $this->_model->getOperation(); + $sleep_params = parent::__sleep(); + $sleep_params [] = '_operation'; + return $sleep_params; + } + + + public function getSecondaryTitle() { + return ($record = $this->_getRecord()) + ? $record->getSecondaryTitle() + : $this->_model->getAuteur(); + } + + + public function getPicture() { + return ($record = $this->_getRecord()) + ? $record->getPicture() + : ''; + } + + + public function getPictureAction() { + return ''; + } + + + public function getDescriptionTitle() { + return ''; + } + + + public function getMainLink() { + return ($record = $this->_getRecord()) + ? $record->getMainLink() + : null; + } + + + public function getSecondaryLink() { + return ($record = $this->_getRecord()) + ? $record->getSecondaryLink() + : null; + } + + + public function getSecondaryIco() { + return ($record = $this->_getRecord()) + ? $record->getSecondaryIco() + : null; + } + + + public function getDocType() { + return ($record = $this->_getRecord()) + ? $record->getDocType() + : null; + } + + + public function getDocTypeLabel() { + return ($record = $this->_getRecord()) + ? $record->getDocTypeLabel() + : ''; + } + + + public function getEmbedMedia() { + return ''; + } + + + public function getHtmlPicture() { + return ''; + } + + + public function getOsmData() { + return null; + } + + + protected function _getRecord() { + if ($this->_record_cache) + return $this->_record_cache; + + if (!$db_record = $this->_model->getNoticeOPAC()) + return $this->_record_cache = null; + + return $this->_record_cache = Class_Template::current()->newWrapper($db_record, $this->_view); + } + + + protected function _getOperationId() { + return $this->_model->getOperationId(); + } + + + protected function _getModelId() { + $id = ($user = $this->_model->getUser()) + ? $user->getId() + : 0; + + $this->_operation = $this->_model->getOperation(); + return $this->_model_id = serialize([$this->_operation, $id]); + } + + + protected function _getModelIdAsJson() { + $id = ($user = $this->_model->getUser()) + ? $user->getId() + : 0; + + return $this->_model_id = json_encode([$this->_model->getOperationId(), $id]); + } + + + public function getModelClassname() { + return get_class($this); + } + + + public static function find($id) { + $id = unserialize($id); + return new Class_User_CardsOperationDecorator($id[0], Class_Users::find($id[1])); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/ActivitySession.php b/library/templates/Intonation/Library/View/Wrapper/ActivitySession.php index d933caa5810d919b49118a68b7ceb722af3fb64d..b174572930a753f840b37035b05e61e85568260c 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ActivitySession.php +++ b/library/templates/Intonation/Library/View/Wrapper/ActivitySession.php @@ -37,7 +37,7 @@ class Intonation_Library_View_Wrapper_ActivitySession return (new Intonation_Library_Link) ->setUrl($this->_view->url(['controller' => 'abonne', 'action' => 'detail-session', - 'id' => $this->getModelId()], + 'id' => $this->getId()], null, true)) ->setText($this->_('En savoir plus')) ->setImage($this->getIco('read-document', 'library')) @@ -70,7 +70,7 @@ class Intonation_Library_View_Wrapper_ActivitySession $actions = [(new Intonation_Library_Link) ->setUrl($this->_view->url(['controller' => 'abonne', 'action' => 'inscrire-session', - 'id' => $this->getModelId()], + 'id' => $this->getId()], null, true)) ->setImage($this->getIco('add', 'utils')) ->setText($this->_('S\'inscrire')) diff --git a/library/templates/Intonation/Library/View/Wrapper/ActivitySessionInscription.php b/library/templates/Intonation/Library/View/Wrapper/ActivitySessionInscription.php index 974656b29d7c47d74ad130e9317bf49d1c37fe1d..851e48f180383afb1dc165a629d248484afa13d0 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ActivitySessionInscription.php +++ b/library/templates/Intonation/Library/View/Wrapper/ActivitySessionInscription.php @@ -42,7 +42,7 @@ class Intonation_Library_View_Wrapper_ActivitySessionInscription $links [] = (new Intonation_Library_Link) ->setUrl($this->_view->url(['controller' => 'abonne', 'action' => 'edit-session', - 'id' => $this->getModelId()], + 'id' => $this->getId()], null, true)) ->setText($this->_('Modifier')) ->setImage($this->getIco('edit', 'utils')) diff --git a/library/templates/Intonation/Library/View/Wrapper/Hold.php b/library/templates/Intonation/Library/View/Wrapper/Hold.php index 3475530756680d339b29813f3608b64d0e22d7c8..32124baef2eb2a11235cfc78d64de738b1549358 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Hold.php +++ b/library/templates/Intonation/Library/View/Wrapper/Hold.php @@ -20,22 +20,7 @@ */ -class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapper_Abstract { - - protected - $_operation, - $_wrapper_cache, - $_ready, - $_library_label, - $_end_availability; - - - public function __sleep() { - $this->_operation = $this->_model->getOperation(); - $sleep_params = parent::__sleep(); - $sleep_params [] = '_operation'; - return $sleep_params; - } +class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapper_AbstractCardOperation { public function getMainTitle() { @@ -48,55 +33,26 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp $hold_by = $this->_div(['class' => 'hold_by'], $hold_by); - if ( ! $this->_model->getNoticeOPAC()) + if ( ! $record = $this->_getRecord()) return $hold_by . $this->_div(['class' => 'document_title'], $this->_model->getTitre()); - $wrapper = $this->_getWrapper(); - return $hold_by . $this->_div(['class' => 'document_title'], - $wrapper->getMainTitle()); - } - - - public function getSecondaryTitle() { - if (!$this->_model->getNoticeOPAC()) - return $this->_model->getAuteur(); - - $wrapper = $this->_getWrapper(); - - return $wrapper->getSecondaryTitle(); - } - - - public function getPicture() { - if (!$this->_model->getNoticeOPAC()) - return ''; - - $wrapper = $this->_getWrapper(); - - return $wrapper->getPicture(); - } - - - public function getPictureAction() { - return ''; + $record->getMainTitle()); } public function getDescription() { $html = [$this->getBadges()]; - if (!$this->_model->getNoticeOPAC()) + if ( ! $record = $this->_getRecord()) return implode($html); - $wrapper = $this->_getWrapper(); - $html = $this->_addParagraphe($html); - $html [] = $wrapper->getDescription(); + $html [] = $record->getDescription(); return implode($html); } @@ -117,72 +73,15 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp public function getFullDescription() { $html = [$this->getBadges()]; - if (!$this->_model->getNoticeOPAC()) + if ( ! $record = $this->_getRecord()) return implode($html); - $wrapper = $this->_getWrapper(); - - $html [] = $wrapper->getFullDescription(); + $html [] = $record->getFullDescription(); return implode($html); } - public function getDescriptionTitle() { - return ''; - } - - - public function getMainLink() { - if (!$this->_model->getNoticeOPAC()) - return null; - - $wrapper = $this->_getWrapper(); - - return $wrapper->getMainLink(); - } - - - public function getSecondaryLink() { - if (!$this->_model->getNoticeOPAC()) - return null; - - $wrapper = $this->_getWrapper(); - - return $wrapper->getSecondaryLink(); - } - - - public function getSecondaryIco() { - if (!$this->_model->getNoticeOPAC()) - return null; - - $wrapper = $this->_getWrapper(); - - return $wrapper->getSecondaryIco(); - } - - - public function getDocType() { - if (!$this->_model->getNoticeOPAC()) - return null; - - $wrapper = $this->_getWrapper(); - - return $wrapper->getDocType(); - } - - - public function getDocTypeLabel() { - if (!$this->_model->getNoticeOPAC()) - return null; - - $wrapper = $this->_getWrapper(); - - return $wrapper->getDocTypeLabel(); - } - - public function getBadges() { $rang = $this->_model->getRang(); $badges = []; @@ -242,47 +141,4 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp ->setText($this->_('Supprimer')) ->setTitle($this->_('Supprimer la réservation %s', $this->_model->getTitre()))]; } - - - public function getEmbedMedia() { - return ''; - } - - - public function getHtmlPicture() { - return ''; - } - - - public function getOsmData() { - return null; - } - - - protected function _getWrapper() { - if ( $this->_wrapper_cache) - return $this->_wrapper_cache; - - return $this->_wrapper_cache = - Class_Template::current()->newWrapper($this->_model->getNoticeOPAC(), $this->_view); - } - - - public function getModelId() { - $id = ($user = $this->_model->getUser()) - ? $user->getId() - : 0; - - return [$this->_operation, $id]; - } - - - public function getModelClassname() { - return get_class($this); - } - - - public static function find($id) { - return new Class_User_CardsOperationDecorator($id[0], Class_Users::find($id[1])); - } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Loan.php b/library/templates/Intonation/Library/View/Wrapper/Loan.php index c0fbd6282a780a79c95aef404fb6c4e8e420b910..7c21ea195a51a15ca7f90e56d5a5313bfd7be1be 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Loan.php +++ b/library/templates/Intonation/Library/View/Wrapper/Loan.php @@ -20,19 +20,7 @@ */ -class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapper_Abstract { - - protected - $_record, - $_operation; - - - public function __sleep() { - $this->_operation = $this->_model->getOperation(); - $sleep_params = parent::__sleep(); - $sleep_params [] = '_operation'; - return $sleep_params; - } +class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapper_AbstractCardOperation { public function getMainTitle() { @@ -53,25 +41,6 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapp } - public function getSecondaryTitle() { - return ($record = $this->_getRecord()) - ? $record->getSecondaryTitle() - : $this->_model->getAuteur(); - } - - - public function getPicture() { - return ($record = $this->_getRecord()) - ? $record->getPicture() - : ''; - } - - - public function getPictureAction() { - return ''; - } - - public function getDescription() { return ($record = $this->_getRecord()) ? $this->getBadges() . $record->getDescription() @@ -86,46 +55,6 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapp } - public function getDescriptionTitle() { - return ''; - } - - - public function getMainLink() { - return ($record = $this->_getRecord()) - ? $record->getMainLink() - : null; - } - - - public function getSecondaryLink() { - return ($record = $this->_getRecord()) - ? $record->getSecondaryLink() - : null; - } - - - public function getSecondaryIco() { - return ($record = $this->_getRecord()) - ? $record->getSecondaryIco() - : ''; - } - - - public function getDocType() { - return ($record = $this->_getRecord()) - ? $record->getDocType() - : ''; - } - - - public function getDocTypeLabel() { - return ($record = $this->_getRecord()) - ? $record->getDocTypeLabel() - : ''; - } - - public function getBadges() { $issue_date = $this->_model->getIssueDate(); $return_date = $this->_model->getDateRetour(); @@ -220,49 +149,4 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapp return $actions; } - - - public function getEmbedMedia() { - return ''; - } - - - public function getHtmlPicture() { - return ''; - } - - - protected function _getRecord() { - if ($this->_record) - return $this->_record; - - if (!$db_record = $this->_model->getNoticeOPAC()) - return $this->_record = null; - - return $this->_record = Class_Template::current()->newWrapper($db_record, $this->_view); - } - - - public function getOsmData() { - return null; - } - - - public function getModelId() { - $id = ($user = $this->_model->getUser()) - ? $user->getId() - : 0; - - return [$this->_operation, $id]; - } - - - public function getModelClassname() { - return get_class($this); - } - - - public static function find($id) { - return new Class_User_CardsOperationDecorator($id[0], Class_Users::find($id[1])); - } } diff --git a/library/templates/Intonation/Library/View/Wrapper/MenuEntry.php b/library/templates/Intonation/Library/View/Wrapper/MenuEntry.php index 50432761b90e9025179b3113c3353980d6a7ff4e..ead6369acccaad5185c4bdfb28e564d697bb8363 100644 --- a/library/templates/Intonation/Library/View/Wrapper/MenuEntry.php +++ b/library/templates/Intonation/Library/View/Wrapper/MenuEntry.php @@ -128,10 +128,11 @@ class Intonation_Library_View_Wrapper_MenuEntry extends Intonation_Library_View_ } - public function getModelId() { - return [$this->_model->getId(), - $this->_model->getParent(), - $this->_model->getProfileId()]; + protected function _getModelId() { + return $this->_model_id = + json_encode([$this->_model->getId(), + $this->_model->getParent(), + $this->_model->getProfileId()]); } @@ -141,6 +142,7 @@ class Intonation_Library_View_Wrapper_MenuEntry extends Intonation_Library_View_ public static function find($id) { + $id = json_decode($id); return (new Class_Systeme_Widget_Menu) ->setId($id[0]) ->setParent($id[1]) diff --git a/library/templates/Intonation/Library/View/Wrapper/PNBHold.php b/library/templates/Intonation/Library/View/Wrapper/PNBHold.php index 8bf27a32bd1fb167047a8953f547713ca15349a0..3c30bd81cc6caf517bbbd752b9c0437ee9385c07 100644 --- a/library/templates/Intonation/Library/View/Wrapper/PNBHold.php +++ b/library/templates/Intonation/Library/View/Wrapper/PNBHold.php @@ -63,7 +63,7 @@ class Intonation_Library_View_Wrapper_PNBHold extends Intonation_Library_View_Wr return [(new Intonation_Library_Link) ->setUrl($this->_view->url(['controller' => 'abonne', 'action' => 'delete-pnb-hold', - 'id' => $this->_getModelId()])) + 'id' => $this->_getOperationId()])) ->setImage($this->getIco('delete', 'utils')) ->setText($this->_('Supprimer')) ->setTitle($this->_('Supprimer la réservation du document %s', $this->_model->getTitre())) @@ -73,23 +73,14 @@ class Intonation_Library_View_Wrapper_PNBHold extends Intonation_Library_View_Wr } - private function _getModelId() { - return $this->_model->getOperationId(); - } - - - public function getModelId() { - $id = ($user = $this->_model->getUser()) - ? $user->getId() - : 0; - - return [$this->_model->getOperationId(), $id]; + protected function _getModelId() { + return $this->_getModelIdAsJson(); } public static function find($id) { - return new Class_User_CardsOperationDecorator(Class_Hold_Pnb::findFirstBy(['id' => $id[0], - 'user_id' => $id[1]]), + $id = json_decode($id); + return new Class_User_CardsOperationDecorator(Class_Hold_Pnb::find($id[0]), Class_Users::find($id[1])); } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/PNBLoan.php b/library/templates/Intonation/Library/View/Wrapper/PNBLoan.php index 2e61e8b558371ce18354d01d73e64b17550baac4..3440a09153feb040b33b7b9a40df79dfeb2518b3 100644 --- a/library/templates/Intonation/Library/View/Wrapper/PNBLoan.php +++ b/library/templates/Intonation/Library/View/Wrapper/PNBLoan.php @@ -30,13 +30,6 @@ class Intonation_Library_View_Wrapper_PNBLoan extends Intonation_Library_View_Wr } - public function getSecondaryTitle() { - return ($record = $this->_getRecord()) - ? $record->getSecondaryTitle() - : ''; - } - - public function getBadges() { $issue_date = $this->_model->getIssueDate(); $return_date = $this->_model->getDateRetourISO8601(); @@ -119,19 +112,15 @@ class Intonation_Library_View_Wrapper_PNBLoan extends Intonation_Library_View_Wr } - public function getModelId() { - $id = ($user = $this->_model->getUser()) - ? $user->getId() - : 0; - - return [$this->_model->getOperationId(), $id]; + protected function _getModelId() { + return $this->_getModelIdAsJson(); } public static function find($id) { - return new Class_User_CardsOperationDecorator(Class_Loan_Pnb::findFirstBy(['id' => $id[0], - 'user_id' => $id[1]]), + $id = json_decode($id); + return new Class_User_CardsOperationDecorator(Class_Loan_Pnb::find($id[0]), Class_Users::find($id[1])); } } diff --git a/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php index 3c086dba837cfa16de959ad2f8605fb340d03a29..7f31e47b68caae5bea3f15fae1da7eb2872b67cd 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php +++ b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php @@ -154,16 +154,16 @@ class Intonation_Library_View_Wrapper_ReviewsByRecord extends Intonation_Library } - public function getModelId() { + protected function _getModelId() { $ids = []; if ($this->_record) - $ids = [$this->_record->getModelId()]; + $ids = [$this->_record->getId()]; foreach ( $this->_reviews as $review) - $ids [][] = $review->getModelId(); + $ids [][] = $review->getId(); - return $ids; + return $this->_model_id = json_encode($ids); } @@ -173,6 +173,8 @@ class Intonation_Library_View_Wrapper_ReviewsByRecord extends Intonation_Library public static function find($ids) { + $ids = json_decode($ids); + $record_data = array_slice($ids, 0, 1, true); $record = Class_Notice::find(array_shift($record_data)); diff --git a/library/templates/Intonation/Library/View/Wrapper/Selection.php b/library/templates/Intonation/Library/View/Wrapper/Selection.php index a35b3a041bc6b15512ad5fde4bcf1449acf654bf..cf56b0c13e39f057301bc13f0e88def2d713e025 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Selection.php +++ b/library/templates/Intonation/Library/View/Wrapper/Selection.php @@ -101,7 +101,7 @@ class Intonation_Library_View_Wrapper_Selection extends Intonation_Library_View_ return (new Intonation_Library_Link) ->setUrl($this->_view->url(['controller' => 'recherche', 'action' => 'simple', - 'id_panier' => $this->getModelId()], + 'id_panier' => $this->getId()], null, true)) ->setImage($this->getIco('search_more', 'library')) ->setText($this->_('Voir')) diff --git a/library/templates/Intonation/Library/View/Wrapper/Suggestion.php b/library/templates/Intonation/Library/View/Wrapper/Suggestion.php index a9b7c57c16a130db149486425190321db3714f49..80183a0b71cd113d367f88f88f73e7f47037fa96 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Suggestion.php +++ b/library/templates/Intonation/Library/View/Wrapper/Suggestion.php @@ -201,16 +201,17 @@ class Intonation_Library_View_Wrapper_Suggestion extends Intonation_Library_View } - public function getModelId() { + protected function _getModelId() { $id = ($user = $this->_model->getUser()) ? $user->getId() : 0; - return [$this->_model->getOperationId(), $id]; + return $this->_model_id = json_encode([$this->_model->getOperationId(), $id]); } public static function find($id) { + $id = json_decode($id); return new Class_User_CardsOperationDecorator(Class_SuggestionAchat::findFirstBy(['id' => $id[0], 'user_id' => $id[1]]), Class_Users::find($id[1])); diff --git a/library/templates/Intonation/Library/View/Wrapper/Work.php b/library/templates/Intonation/Library/View/Wrapper/Work.php index 487e53d83de648dde6fcab21898f34a5f1807dc9..ee0b5d73b93e4b6a1dbe9bcfaabee39c32650360 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Work.php +++ b/library/templates/Intonation/Library/View/Wrapper/Work.php @@ -173,8 +173,8 @@ class Intonation_Library_View_Wrapper_Work extends Intonation_Library_View_Wrapp } - public function getModelId() { - return ($model = $this->_model->getRecord()) + protected function _getModelId() { + return $this->_model_id = ($model = $this->_model->getRecord()) ? $model->getClefOeuvre() : ''; } diff --git a/scripts/album_clear_codif.php b/scripts/album_clear_codif.php new file mode 100644 index 0000000000000000000000000000000000000000..ba1d9f1afefbb0605c8e7ab699d8f0c42225ad41 --- /dev/null +++ b/scripts/album_clear_codif.php @@ -0,0 +1,4 @@ +<?php +require __DIR__ . '/../console.php'; + +(new Class_Migration_AlbumClearCodif($argv[1]))->run(); diff --git a/scripts/dimusic_first_harvest.php b/scripts/dimusic_first_harvest.php new file mode 100644 index 0000000000000000000000000000000000000000..d613ec5506b259236f7c08644da8463f7dbe8e17 --- /dev/null +++ b/scripts/dimusic_first_harvest.php @@ -0,0 +1,25 @@ +<?php +require('console.php'); + +class Write_Log_In_Temp { + protected $_path = './temp/dimusic_harvest_log.txt'; + + public function __construct() { + file_put_contents($this->_path, + ''); + } + + + public function log($message) { + file_put_contents($this->_path, + $message . "\n", + FILE_APPEND); + } +} + +Class_DigitalResource::getInstance()->getHarvesters(); + +(new Dimusic_Harvester) + ->setLogger(new Write_Log_In_Temp) + ->run(); +?> \ No newline at end of file diff --git a/scripts/dimusic_first_import.php b/scripts/dimusic_first_import.php new file mode 100644 index 0000000000000000000000000000000000000000..1bbcf67d5615290196a3e93d29ed22b36914acb9 --- /dev/null +++ b/scripts/dimusic_first_import.php @@ -0,0 +1,25 @@ +<?php +require('console.php'); + +class Write_Log_In_Temp { + protected $_path = './temp/dimusic_import_log.txt'; + + public function __construct() { + file_put_contents($this->_path, + ''); + } + + + public function log($message) { + file_put_contents($this->_path, + $message . "\n", + FILE_APPEND); + } +} + +Class_DigitalResource::getInstance()->getImporters(); + +(new Dimusic_Importer) + ->setLogger(new Write_Log_In_Temp) + ->run(); +?> \ No newline at end of file diff --git a/tests/TearDown.php b/tests/TearDown.php new file mode 100644 index 0000000000000000000000000000000000000000..19532ce8e10cc964df0ae24c58638ac109e2511b --- /dev/null +++ b/tests/TearDown.php @@ -0,0 +1,110 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 TearDown { + + public function __construct($volatile_status, $sql = null, $cfg = null) { + $this->_reset($volatile_status, + $sql, + $cfg); + } + + + protected function _reset($volatile_status, $sql, $cfg) { + if ($volatile_status) { + Storm_Model_Loader::defaultToDb(); + Class_Versions::defaultToFile(); + } + + if ($sql) + Zend_Registry::set('sql', $sql); + + if ($cfg) + Zend_Registry::set('cfg', $cfg); + + Bokeh_Engine::reset(); + + Class_Album::setFileSystem(null); + + Class_Codification::reset(); + Class_Codification::resetInstance(); + Class_CommSigb::setInstance(null); + Class_Cosmogramme_LandingDirectory::reset(); + Class_Cosmogramme_Generator_KindsTask::setDbAdapter(null); + Class_Crypt::setPhpCommand(null); + + Class_DigitalResource::resetInstance(); + + Class_I18n::reset(); + + Class_FederationReview::resetInstance(); + Class_FileManager::reset(); + + Class_Log::resetInstance(); + + Class_MoteurRecherche::resetInstance(); + Class_MoteurRecherche::setTimeSource(null); + Class_MoteurRecherche_FacetsByCount::reset(); + Class_MoteurRecherche_Facettes::reset(); + + Class_Notice_Thumbnail_ResizeImage::reset(); + Class_Notice_Xsl::reset(); + Class_Notice::setTimeSource(null); + Class_Notice_Facette::reset(); + + Class_Profil::getCurrentProfil()->clearInstanceCache(); + Class_Profil::clearCache(); + + Class_ScriptLoader::resetInstance(); + + Class_Systeme_Report_Portal::setIp(null); + Class_Systeme_ModulesMenu::reset(); + Class_Systeme_Widget_Abstract::reset(); + Class_Systeme_ModulesAccueil::reset(); + + Class_Template::reset(); + + Class_User_Settings::clearCache(); + + Class_Url::setBaseUrl(null); + Class_Url::setPhpMode(null); + + Class_WebService_Abstract::resetHttpClient(); + Class_WebService_Afi::setHttpClient(null); + Class_WebService_Afi::setKey(null); + Class_WebService_AllServices::setHttpClient(null); + Class_WebService_BibNumerique_Vignette::resetInstance(); + Class_WebService_BibNumerique_Vignette::resetHttpClient(); + Class_WebService_SIGB_Nanook::reset(); + Class_WebService_SIGB_Nanook_PatronPasswordNotSecure::resetInstance(); + Class_WebService_SIGB_AbstractService::setLogger(null); + Class_WebService_SIGB_AbstractRESTService::shouldThrowError(false); + + Intonation_Library_Record::reset(); + + Storm_Model_Abstract::unsetLoaders(); + + ZendAfi_Form_Element_Captcha::reset(); + ZendAfi_Acl_AdminControllerGroup::setAcl(null); + ZendAfi_Acl_AdminControllerRoles::reset(); + } +} diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php index 3f041ba0b648733b9d7c79ceb6d25cd8b8555c24..48ae2d067ecd3906722a44bdc934fe4423be4966 100644 --- a/tests/application/modules/AbstractControllerTestCase.php +++ b/tests/application/modules/AbstractControllerTestCase.php @@ -164,57 +164,9 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe public function tearDown() { - if ($this->_storm_default_to_volatile) { - Storm_Model_Loader::defaultToDb(); - Class_Versions::defaultToFile(); - } - - Storm_Model_Abstract::unsetLoaders(); - Zend_Registry::set('sql', $this->_registry_sql); - Zend_Registry::set('cfg', $this->_registry_cfg); - Class_ScriptLoader::resetInstance(); - Class_Codification::resetInstance(); - Class_MoteurRecherche::resetInstance(); - Class_MoteurRecherche::setTimeSource(null); - Class_WebService_Abstract::resetHttpClient(); - Class_WebService_AllServices::setHttpClient(null); - Class_WebService_Afi::setHttpClient(null); - Class_WebService_Afi::setKey(null); - Class_I18n::reset(); - ZendAfi_Form_Element_Captcha::reset(); - Class_Url::setBaseUrl(null); - Class_Url::setPhpMode(null); - Class_Log::resetInstance(); - Class_WebService_BibNumerique_Vignette::resetInstance(); - Class_WebService_BibNumerique_Vignette::resetHttpClient(); - Class_Notice_Thumbnail_ResizeImage::reset(); - Class_FileManager::reset(); - Class_Notice_Xsl::reset(); - Class_Notice::setTimeSource(null); - Class_CommSigb::setInstance(null); - ZendAfi_Acl_AdminControllerGroup::setAcl(null); - Class_Systeme_ModulesAccueil::reset(); - Class_Album::setFileSystem(null); - Class_Crypt::setPhpCommand(null); - Class_User_Settings::clearCache(); - Class_Profil::getCurrentProfil()->clearInstanceCache(); - Class_Profil::clearCache(); - Class_DigitalResource::resetInstance(); - Class_Systeme_ModulesMenu::reset(); - Class_WebService_SIGB_Nanook::reset(); - Class_WebService_SIGB_Nanook_PatronPasswordNotSecure::resetInstance(); - Class_WebService_SIGB_AbstractService::setLogger(null); - Class_FederationReview::resetInstance(); - Class_Template::reset(); - Class_Systeme_Report_Portal::setIp(null); - Class_Systeme_ModulesMenu::reset(); - Class_MoteurRecherche_FacetsByCount::reset(); - Class_MoteurRecherche_Facettes::reset(); - Class_Notice_Facette::reset(); - Class_Systeme_Widget_Abstract::reset(); - Class_Codification::reset(); - ZendAfi_Acl_AdminControllerRoles::reset(); - Intonation_Library_Record::reset(); + new TearDown($this->_storm_default_to_volatile, + $this->_registry_sql, + $this->_registry_cfg); } diff --git a/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php b/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php index 4d5159defc6b6e325adf66a4df7a83509d2ccea4..c8e741d2c0f4d1479d6c2a254333f84997b093e8 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php @@ -106,7 +106,7 @@ class RechercheControllerReservationPickupAjaxActionPostTest 'id_origine' => 12, 'code_annexe' => '36']); - $this->assertRedirectTo(Class_Url::absolute('/recherche/reservationajax/code_annexe/36')); + $this->assertRedirectTo('/recherche/reservationajax/code_annexe/36'); } @@ -1392,4 +1392,96 @@ class RechercheControllerReservationPickupAjaxAndNotifyByMailEnabledTest public function mailBodyShouldContainsContent($content) { $this->assertContains($content,quoted_printable_decode(current($this->_sent_mails)->getBodyHtml(true))); } +} + + + + +require_once 'tests/fixtures/KohaFixtures.php'; + +class RechercheControllerReservationWithWebServiceKohaAndItypesTest + extends AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + Class_WebService_SIGB_AbstractRESTService::shouldThrowError(true); + + $koha_service_params = ['url_serveur' => 'http://bib.valensol.net', + 'grouped_holds_itypes' => " PRET_MALLE + OUT +PRET_GLACIERE +PRET_VALISE", + 'bundled_holds_minimal_duration' => 30, + 'bundled_holds_maximal_duration' => 60, + 'id_bib' => 1, + 'type' => 5]; + + $bib = $this->fixture('Class_IntBib', + ['id' => 1, + 'comm_sigb' => Class_IntBib::COM_KOHA, + 'comm_params' => $koha_service_params]); + + $http_client = $this + ->mock() + + ->whenCalled('open_url') + ->with('http://bib.valensol.net?service=GetRecords') + ->answers(KohaFixtures::getRecordsWithGroupHoldsItypes()) + + ->beStrict(); + + Class_WebService_SIGB_Koha::getService($koha_service_params) + ->setWebClient($http_client); + + $record = + $this->fixture('Class_Notice', + ['id' => 8890, + 'titre_principal' => 'Elementaire mon cher polar', + 'auteur_principal' => 'Conan Doyle']); + + $this->fixture('Class_Exemplaire', + ['id' => 456, + 'code_barres' => 5360246264, + 'id_int_bib' => 1, + 'notice' => $record]); + + $this->fixture('Class_CodifAnnexe', + ['id' => 3, + 'code' => 'VS', + 'id_origine' => 'VS', + 'libelle' => 'Cran', + 'no_pickup' => '0']); + + Class_CosmoVar::setValueOf('site_retrait_resa', 1); + + $user = $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'jajm', + 'password' => 'secret', + 'int_bib' => $bib, + 'idabon' => '395749' + ]); + + ZendAfi_Auth::getInstance()->logUser($user); + } + + + /** @test */ + public function reservationAjaxWithItemRequiringCalendarHoldShouldRedirectToReservationCalendarAjaxWithoutException() { + $this->postDispatch('/recherche/reservation-pickup-ajax/id_bib/1/copy_id/456/code_annexe/VS', + ['code_annexe' => 'VS']); + + $this->assertRedirectTo('/recherche/reservationajax/id_bib/1/copy_id/456/code_annexe/VS'); + } + + + /** @test */ + public function dispatchReservationajaxShouldRenderCalendar() { + $this->dispatch('/recherche/reservationajax/id_bib/1/copy_id/456/code_annexe/VS'); + $this->assertRedirectTo('/recherche/reservation-calendar-ajax/id_bib/1/copy_id/456/code_annexe/VS'); + } } \ No newline at end of file diff --git a/tests/fixtures/KohaFixtures.php b/tests/fixtures/KohaFixtures.php index 209008aed3a3078db531128ed77291ba18b18ae1..7d68fa69889be34370e21dd54aa660802af9fbc3 100644 --- a/tests/fixtures/KohaFixtures.php +++ b/tests/fixtures/KohaFixtures.php @@ -895,7 +895,7 @@ class KohaFixtures { } - public static function xmlLookupPatronLaure() { + public static function xmlLookupPatronLaure() { return '<?xml version="1.0" encoding="ISO-8859-1" ?> <LookupPatron> <id>572</id> @@ -903,24 +903,23 @@ class KohaFixtures { } - - public static function xmlAuthenticatePatronOk() { + public static function xmlAuthenticatePatronOk() { return '<?xml version="1.0" encoding="UTF-8" ?> <AuthenticatePatron> <id>96138</id> </AuthenticatePatron>'; - } + } - public static function xmlAuthenticatePatronLostCard() { - return '<?xml version="1.0" encoding="UTF-8" ?> + public static function xmlAuthenticatePatronLostCard() { + return '<?xml version="1.0" encoding="UTF-8" ?> <AuthenticatePatron> <code>PatronLostCard</code> </AuthenticatePatron>'; - } + } - public static function xmlGetPatronInfoLaure() { + public static function xmlGetPatronInfoLaure() { return '<?xml version="1.0" encoding="UTF-8" ?> <GetPatronInfo> <category_type>A</category_type> @@ -1052,11 +1051,11 @@ class KohaFixtures { <sort1>10</sort1> <sex></sex> </GetPatronInfo>'; - } + } - public static function xmlGetPatronInfoLaureLoans() { - return '<?xml version="1.0" encoding="UTF-8" ?> + public static function xmlGetPatronInfoLaureLoans() { + return '<?xml version="1.0" encoding="UTF-8" ?> <GetPatronInfo> <category_type>A</category_type> <categorycode>INDIVIDU</categorycode> @@ -1092,17 +1091,17 @@ class KohaFixtures { <sort1>10</sort1> <sex></sex> </GetPatronInfo>'; - } + } - public static function xmlGetPatronLaureIssuesHistoryError() { - return ''; - } + public static function xmlGetPatronLaureIssuesHistoryError() { + return ''; + } - public static function jsonGetPatronLaureIssueHistoryFourItems() { - return '[ + public static function jsonGetPatronLaureIssueHistoryFourItems() { + return '[ { "itemnumber" : 89658, "booksellerid" : null, @@ -1515,11 +1514,11 @@ class KohaFixtures { "booksellerid" : null, "itemnumber" : 104955 }]'; - } + } - public static function jsonGetPatronLaureIssueHistoryMoreThan20() { - return '[ + public static function jsonGetPatronLaureIssueHistoryMoreThan20() { + return '[ { "itemnumber" : 89658, "booksellerid" : null, @@ -3685,43 +3684,42 @@ class KohaFixtures { } ]'; - } + } - public static function xmlLookupPatronJeanAndre() { - return '<?xml version="1.0" encoding="UTF-8" ?> + public static function xmlLookupPatronJeanAndre() { + return '<?xml version="1.0" encoding="UTF-8" ?> <LookupPatron> <id>419</id> </LookupPatron>'; - } - + } - public static function xmlLookupPatronDebarred() { - return '<?xml version="1.0" encoding="UTF-8" ?> + public static function xmlLookupPatronDebarred() { + return '<?xml version="1.0" encoding="UTF-8" ?> <LookupPatron> <id>420</id> </LookupPatron>'; - } + } - public static function xmlLookupPatronLisianne() { - return '<?xml version="1.0" encoding="UTF-8" ?> + public static function xmlLookupPatronLisianne() { + return '<?xml version="1.0" encoding="UTF-8" ?> <LookupPatron> <id>16186</id> </LookupPatron>'; - } + } - public static function xmlLookupPatronJamesBond() { - return '<?xml version="1.0" encoding="UTF-8" ?> + public static function xmlLookupPatronJamesBond() { + return '<?xml version="1.0" encoding="UTF-8" ?> <LookupPatron> <id>007</id> </LookupPatron>'; - } + } - public static function xmlGetPatronInfoDupont() { + public static function xmlGetPatronInfoDupont() { return '<?xml version="1.0" encoding="UTF-8" ?> <GetPatronInfo> <category_type>A</category_type> @@ -3764,11 +3762,11 @@ class KohaFixtures { <reservefee>0.000000</reservefee> </GetPatronInfo>'; - } + } - public static function xmlGetPatronInfoJeanAndre() { - return '<?xml version="1.0" encoding="UTF-8" ?> + public static function xmlGetPatronInfoJeanAndre() { + return '<?xml version="1.0" encoding="UTF-8" ?> <GetPatronInfo> <category_type>A</category_type> <categorycode>ADUEXT</categorycode> @@ -3794,11 +3792,11 @@ class KohaFixtures { <sort1>CSP5</sort1> <sex>M</sex> </GetPatronInfo>'; - } + } - public static function xmlGetPatronInfoJeanAndreLoans() { - return '<?xml version="1.0" encoding="UTF-8" ?> + public static function xmlGetPatronInfoJeanAndreLoans() { + return '<?xml version="1.0" encoding="UTF-8" ?> <GetPatronInfo> <category_type>A</category_type> <categorycode>ADUEXT</categorycode> @@ -3902,11 +3900,11 @@ class KohaFixtures { </loan> </loans> </GetPatronInfo>'; - } + } - public static function xmlGetPatronInfoJamesBond() { - return '<?xml version="1.0" encoding="UTF-8" ?> + public static function xmlGetPatronInfoJamesBond() { + return '<?xml version="1.0" encoding="UTF-8" ?> <GetPatronInfo> <borrowernumber>007</borrowernumber> <cardnumber>007</cardnumber> @@ -4009,12 +4007,12 @@ class KohaFixtures { <loans> </loans> </GetPatronInfo>' - ; - } + ; + } - public static function xmlGetRecordsElementaireMonCherPolar () { - return + public static function xmlGetRecordsElementaireMonCherPolar () { + return '<?xml version="1.0" encoding="ISO-8859-1" ?> <GetRecords> <record> @@ -4114,11 +4112,11 @@ class KohaFixtures { </items> </record> </GetRecords>'; - } + } - public static function elementaireMonCherPolarHolds() { - return + public static function elementaireMonCherPolarHolds() { + return '{ "holds": [ { @@ -4192,11 +4190,11 @@ class KohaFixtures { } ] }'; - } + } - public static function xmlGetRecordsWithTransfert () { - return '<?xml version="1.0" encoding="UTF-8" ?> + public static function xmlGetRecordsWithTransfert () { + return '<?xml version="1.0" encoding="UTF-8" ?> <GetRecords> <record> <itemtype>LIVR</itemtype> @@ -4369,11 +4367,11 @@ class KohaFixtures { </record> </GetRecords> '; - } + } - public static function xmlGetRecordsWithOnLoan () { - return - '<?xml version="1.0" encoding="ISO-8859-1" ?> + + public static function xmlGetRecordsWithOnLoan () { + return '<?xml version="1.0" encoding="ISO-8859-1" ?> <GetRecords> <record> <biblioitemnumber>1</biblioitemnumber> @@ -4464,10 +4462,11 @@ class KohaFixtures { </items> </record> </GetRecords>'; - } + } + - public static function xmlGetPatronInfoDebarred() { - return '<?xml version="1.0" encoding="UTF-8" ?> + public static function xmlGetPatronInfoDebarred() { + return '<?xml version="1.0" encoding="UTF-8" ?> <GetPatronInfo> <privacy_guarantor_checkouts>0</privacy_guarantor_checkouts> <updated_on>2019-02-18 09:26:19</updated_on> @@ -4524,11 +4523,11 @@ class KohaFixtures { <login_attempts>0</login_attempts> </GetPatronInfo> '; - } + } - public static function xmlGetPatronInfoDebarredWithDate() { - return '<?xml version="1.0" encoding="UTF-8" ?> + public static function xmlGetPatronInfoDebarredWithDate() { + return '<?xml version="1.0" encoding="UTF-8" ?> <GetPatronInfo> <privacy_guarantor_checkouts>0</privacy_guarantor_checkouts> <updated_on>2019-02-18 09:26:19</updated_on> @@ -4585,11 +4584,11 @@ class KohaFixtures { <login_attempts>0</login_attempts> </GetPatronInfo> '; - } + } - public static function xmlGetRecord2046() { - return '<?xml version="1.0" encoding="UTF-8" ?> + public static function xmlGetRecord2046() { + return '<?xml version="1.0" encoding="UTF-8" ?> <GetRecords> <record> <reserves> @@ -5329,5 +5328,230 @@ class KohaFixtures { </record> </GetRecords> '; - } -} + } + + + public static function getRecordsWithGroupHoldsItypes() { + return '<?xml version="1.0" encoding="UTF-8" ?> +<GetRecords> + <record> + <itemtype>OUTIL</itemtype> + <cn_sort></cn_sort> + <reserves> + </reserves> + <items> + <item> + <holdingbranch>VITRE</holdingbranch> + <dateaccessioned>2018-04-18</dateaccessioned> + <replacementpricedate>2018-04-18</replacementpricedate> + <barcode>5360246264</barcode> + <location>FPROA</location> + <withdrawn>0</withdrawn> + <homebranch>VITRE</homebranch> + <timestamp>2021-09-14 11:23:43</timestamp> + <homebranchname>Vitré - Médiathèque Madame de Sévigné</homebranchname> + <itemlost>0</itemlost> + <holdingbranchname>Vitré - Médiathèque Madame de Sévigné</holdingbranchname> + <notforloan>0</notforloan> + <datelastseen>2021-09-14</datelastseen> + <itemnumber>191100</itemnumber> + <onloan>2021-10-26</onloan> + <issues>15</issues> + <renewals>5</renewals> + <replacementprice>229.25</replacementprice> + <damaged>0</damaged> + <biblioitemnumber>179788</biblioitemnumber> + <biblionumber>179788</biblionumber> + <cn_sort>ARLEANE_CUBETTO1</cn_sort> + <itemcallnumber>ARLEANE-CUBETTO1</itemcallnumber> + <datelastborrowed>2021-09-14</datelastborrowed> + <permanent_location>FPROA</permanent_location> + <itype>OUT</itype> + </item> + <item> + <itemlost>0</itemlost> + <holdingbranchname>Vitré - Médiathèque Madame de Sévigné</holdingbranchname> + <notforloan>0</notforloan> + <itemnumber>191217</itemnumber> + <datelastseen>2020-01-09</datelastseen> + <issues>7</issues> + <renewals>7</renewals> + <holdingbranch>VITRE</holdingbranch> + <dateaccessioned>2018-04-19</dateaccessioned> + <replacementpricedate>2018-04-19</replacementpricedate> + <barcode>5360246513</barcode> + <location>FPROA</location> + <withdrawn>0</withdrawn> + <homebranch>VITRE</homebranch> + <timestamp>2021-08-30 14:53:45</timestamp> + <homebranchname>Vitré - Médiathèque Madame de Sévigné</homebranchname> + <cn_sort>ARLEANE_CUBETTO2</cn_sort> + <datelastborrowed>2019-12-12</datelastborrowed> + <itemcallnumber>ARLEANE-CUBETTO2</itemcallnumber> + <permanent_location>FPROA</permanent_location> + <itype>OUT</itype> + <replacementprice>229.25</replacementprice> + <damaged>0</damaged> + <biblionumber>179788</biblionumber> + <biblioitemnumber>179788</biblioitemnumber> + </item> + </items> + <publishercode>Primo Toys</publishercode> + <biblionumber>179788</biblionumber> + <biblioitemnumber>179788</biblioitemnumber> + <issues> + <issue> + <lastreneweddate>2018-10-04 00:00:00</lastreneweddate> + <issue_id>1883862</issue_id> + <biblionumber>179788</biblionumber> + <timestamp>2018-10-09 18:50:12</timestamp> + <barcode>5360246513</barcode> + <onsite_checkout>0</onsite_checkout> + <branchcode>VITRE</branchcode> + <issuedate>2018-08-31 16:21:49</issuedate> + <renewals>1</renewals> + <title>Cubetto Playset 1 - touch, program, play</title> + <date_due>2018-10-25 23:59:00</date_due> + <auto_renew>0</auto_renew> + <itemnumber>191217</itemnumber> + <returndate>2018-10-09 18:50:12</returndate> + </issue> + </issues> + <place>London</place> + <timestamp>2021-09-15 01:10:07</timestamp> + <publicationyear>2016</publicationyear> + <pages>2 coffrets (Kit robot + Kit Tapis)</pages> + <totalissues>22</totalissues> + <size>14 x 26 x 27 cm</size> + <url>https://www.primotoys.com/fr/</url> +<marcxml><?xml version="1.0" encoding="UTF-8"?> +<record + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" + xmlns="http://www.loc.gov/MARC21/slim"> + + <leader>01230 2200241 4500</leader> + <controlfield tag="001">119018</controlfield> + <datafield tag="010" ind1=" " ind2=" "> + <subfield code="a">291409650X</subfield> + <subfield code="d">30.00 EUR</subfield> + </datafield> + <datafield tag="035" ind1=" " ind2=" "> + <subfield code="a">SMH_12290</subfield> + </datafield> + <datafield tag="035" ind1=" " ind2=" "> + <subfield code="a">AG-0174-00172383</subfield> + </datafield> + <datafield tag="090" ind1=" " ind2=" "> + <subfield code="a">119018</subfield> + </datafield> + <datafield tag="091" ind1=" " ind2=" "> + <subfield code="a">0</subfield> + </datafield> + <datafield tag="099" ind1=" " ind2=" "> + <subfield code="t">OUTIL</subfield> + <subfield code="c">2010-08-31</subfield> + <subfield code="d">2021-04-25</subfield> + </datafield> + <datafield tag="100" ind1=" " ind2=" "> + <subfield code="a">20210625d2006 frey50 </subfield> + </datafield> + <datafield tag="101" ind1=" " ind2=" "> + <subfield code="a">fre</subfield> + </datafield> + <datafield tag="102" ind1=" " ind2=" "> + <subfield code="a">FR</subfield> + </datafield> + <datafield tag="200" ind1=" " ind2=" "> + <subfield code="a">Les trois Zouloulais</subfield> + <subfield code="f">texte Florence-Jenner Metz</subfield> + <subfield code="g">illustrations de Stéphane Henrich</subfield> + <subfield code="b">IF</subfield> + <subfield code="e">[Kamishibaï]</subfield> [99/600] + </datafield> + <datafield tag="210" ind1=" " ind2=" "> + <subfield code="a">Strasbourg</subfield> + <subfield code="c">Callicéphale</subfield> + <subfield code="d">2006</subfield> + </datafield> + <datafield tag="215" ind1=" " ind2=" "> + <subfield code="c">1 kamishibaï de 16 pl.</subfield> + <subfield code="d">27 x 37 cm</subfield> + <subfield code="a">ill. en coul.</subfield> + </datafield> + <datafield tag="300" ind1=" " ind2=" "> + <subfield code="a">Nécessite un butaï pour la lecture.</subfield> + </datafield> + <datafield tag="330" ind1=" " ind2=" "> + <subfield code="a">Lorsque Zoré, le sorcier de la tribu des Zouloulais, décide de partir regagner ses pouvoirs auprès de ses ancêtres, il doit trouver quelqu\'un capable de protéger le village durant son absence, de lutter contre les mauvais esprits et les fléaux des vents. 14 planches : une face dessinée, l\'autre pour le texte, permettent de présenter le dessin au spectateur alors que le récitant narre l\'histoire.</subfield> + </datafield> + <datafield tag="700" ind1=" " ind2="1"> + <subfield code="a">Jenner-Metz</subfield> + <subfield code="b">Florence</subfield> + <subfield code="4">070</subfield> + <subfield code="3">13774643</subfield> + </datafield> + <datafield tag="702" ind1=" " ind2="1"> + <subfield code="a">Henrich</subfield> + <subfield code="b">Stéphane</subfield> + <subfield code="4">440</subfield> + <subfield code="3">13630025</subfield> + </datafield> + <datafield tag="856" ind1=" " ind2=" "> + <subfield code="u">https://www.callicephale.fr/wp-content/uploads/2017/05/wkm_57f247329ca4a.pdf</subfield> + </datafield> + <datafield tag="995" ind1=" " ind2=" "> + <subfield code="2">0</subfield> + <subfield code="3">0</subfield> + <subfield code="5">2010-08-31</subfield> + <subfield code="9">96090</subfield> + <subfield code="b">VITRE</subfield> + <subfield code="c">VITRE</subfield> + <subfield code="e">FPROA</subfield> + <subfield code="f">5360143266</subfield> + <subfield code="i">30.00</subfield> + <subfield code="j">0</subfield> + <subfield code="k">ARLEANE-KAM1</subfield> + <subfield code="m">2012-06-20</subfield> + <subfield code="o">0</subfield> + <subfield code="r">NOUT</subfield> + <subfield code="x">ARLEANE_KAM1</subfield> + <subfield code="z">0</subfield> + <subfield code="q">ADULTE</subfield> + <subfield code="s">Achat</subfield> + <subfield code="t">KAM</subfield> + </datafield> + <datafield tag="995" ind1=" " ind2=" "> + <subfield code="2">0</subfield> + <subfield code="3">0</subfield> + <subfield code="5">2009-05-07</subfield> + <subfield code="9">321318</subfield> + <subfield code="b">SMH</subfield> + <subfield code="c">SMH</subfield> + <subfield code="e">JEU</subfield> + <subfield code="f">1061773530018</subfield> + <subfield code="i">29.50</subfield> + <subfield code="j">0</subfield> + <subfield code="k">E JEN</subfield> + <subfield code="m">2021-06-28</subfield> + <subfield code="o">3</subfield> + <subfield code="r">NOUT</subfield> + <subfield code="x">E_JEN</subfield> + <subfield code="z">0</subfield> + <subfield code="g">ACHAT</subfield> + <subfield code="q">JEUNESSE</subfield> + </datafield> +</record> +</marcxml> + </record> +</GetRecords> +'; + } + + public static function holdTitleResponseWithItemHoldsItypeOut() { + return '<?xml version="1.0" encoding="UTF-8" ?> +<HoldItem> + <pickup_location>Vitré - Médiathèque Madame de Sévigné</pickup_location> +</HoldItem>'; + } +} \ No newline at end of file diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseFlushIntegrationTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseFlushIntegrationTest.php index fc98483c5a985a1622c3b86358ce4845fef7575a..3790bcb376a42a28f4007f7823c525a9db6df881 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhaseFlushIntegrationTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhaseFlushIntegrationTest.php @@ -39,10 +39,18 @@ class PhaseFlushIntegrationWithFilesTestCase extends Class_Cosmogramme_Integrati $this->fixture(Class_Cosmogramme_Integration::class, ['id' => 3, - 'fichier' => 'integre3.pan']); + 'fichier' => 'integre1.pan']); $this->fixture(Class_Cosmogramme_Integration::class, ['id' => 4, + 'fichier' => 'integre2.pan']); + + $this->fixture(Class_Cosmogramme_Integration::class, + ['id' => 5, + 'fichier' => 'integre3.pan']); + + $this->fixture(Class_Cosmogramme_Integration::class, + ['id' => 6, 'fichier' => 'integre4.pan']); $integre2 = $this @@ -110,8 +118,8 @@ class PhaseFlushIntegrationWithFilesTestCase extends Class_Cosmogramme_Integrati /** @test */ - public function integrationsShouldHaveBeenSetToDestroy() { - $this->assertEquals(2, Class_Cosmogramme_Integration::countBy(['destroy' => 1])); + public function fourIntegrationsShouldHaveBeenSetToDestroy() { + $this->assertEquals(4, Class_Cosmogramme_Integration::countBy(['destroy' => 1])); } @@ -130,15 +138,29 @@ class PhaseFlushIntegrationWithFilesTestCase extends Class_Cosmogramme_Integrati /** @test */ - public function integrations3ShouldNotBeDestroy() { - $this->assertNotNull(Class_Cosmogramme_Integration::findFirstBy(['destroy' => 0, + public function integrations3ShouldBeDestroy() { + $this->assertNotNull(Class_Cosmogramme_Integration::findFirstBy(['destroy' => 1, 'id' => 3])); } /** @test */ - public function integrations4ShouldNotBeDestroy() { - $this->assertNotNull(Class_Cosmogramme_Integration::findFirstBy(['destroy' => 0, + public function integrations4ShouldBeDestroy() { + $this->assertNotNull(Class_Cosmogramme_Integration::findFirstBy(['destroy' => 1, 'id' => 4])); } -} + + + /** @test */ + public function integrations5ShouldNotBeDestroy() { + $this->assertNotNull(Class_Cosmogramme_Integration::findFirstBy(['destroy' => 0, + 'id' => 5])); + } + + + /** @test */ + public function integrations6ShouldNotBeDestroy() { + $this->assertNotNull(Class_Cosmogramme_Integration::findFirstBy(['destroy' => 0, + 'id' => 6])); + } +} \ No newline at end of file diff --git a/tests/library/Class/Migration/AlbumClearCodifTest.php b/tests/library/Class/Migration/AlbumClearCodifTest.php new file mode 100644 index 0000000000000000000000000000000000000000..96abc2590685e2ab1ff307ae4d91973f45681b7f --- /dev/null +++ b/tests/library/Class/Migration/AlbumClearCodifTest.php @@ -0,0 +1,135 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 + */ + + +/* hotline: #143141 */ +class AlbumClearCodifTest extends ModelTestCase { + + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $this->fixture(Class_CodifGenre::class, + ['id' => 1, + 'libelle' => 'Adulte' + ]); + $this->fixture(Class_CodifAnnexe::class, + ['id' => 4, + 'libelle' => 'Biviers' + ]); + $this->fixture(Class_CodifAnnexe::class, + ['id' => 7, + 'libelle' => 'Froges' + ]); + $this->fixture(Class_CodifMatiere::class, + ['id' => 8, + 'libelle' => 'Documentaire Guides' + ]); + $this->fixture(Class_CodifMatiere::class, + ['id' => 9, + 'libelle' => 'Documentaire Histoire' + ]); + $this->fixture(Class_CodifMatiere::class, + ['id' => 12, + 'libelle' => 'Documentaire Humour' + ]); + + $this->fixture(Class_AlbumCategorie::class, + ['id' => 100, + 'parent_id' => 0 + ]); + $this->fixture(Class_AlbumCategorie::class, + ['id' => 101, + 'parent_id' => 0 + ]); + + $this->fixture(Class_Album::class, + ['id' => 200, + 'cat_id' => 100, + 'genre' => '1;5', + 'sections' => '2', + 'annexes' => '4;6;7', + 'matiere' => '8;9;10;11;12', + 'titre' => 'Amuse-bouche' + ]); + $this->fixture(Class_Album::class, + ['id' => 201, + 'cat_id' => 101, + 'genre' => '1;5', + 'sections' => '2', + 'annexes' => '4;6;7', + 'matiere' => '8;9;10;11;12', + 'titre' => 'Animal' + ]); + + (new Class_Migration_AlbumClearCodif(100))->run(); + } + + + /** @test */ + public function album200ShouldHaveLostGenreId5() { + $this->assertEquals('1', Class_Album::find(200)->getGenre()); + } + + + /** @test */ + public function album201ShouldNotHaveLostGenreIds() { + $this->assertEquals('1;5', Class_Album::find(201)->getGenre()); + } + + + /** @test */ + public function album200ShouldHaveLostSectionId2() { + $this->assertEquals('', Class_Album::find(200)->getSections()); + } + + + /** @test */ + public function album201ShouldNotHaveLostSectionIds() { + $this->assertEquals('2', Class_Album::find(201)->getSections()); + } + + + /** @test */ + public function album200ShouldHaveLostAnnexeId6() { + $this->assertEquals('4;7', Class_Album::find(200)->getAnnexes()); + } + + + /** @test */ + public function album201ShouldNotHaveLostAnnexeIds() { + $this->assertEquals('4;6;7', Class_Album::find(201)->getAnnexes()); + } + + + /** @test */ + public function album200ShouldHaveLostMatiereId10And11() { + $this->assertEquals('8;9;12', Class_Album::find(200)->getMatiere()); + } + + + /** @test */ + public function album201ShouldNotHaveLostMatiereIds() { + $this->assertEquals('8;9;10;11;12', Class_Album::find(201)->getMatiere()); + } + +} diff --git a/tests/library/Class/ModelTestCase.php b/tests/library/Class/ModelTestCase.php index 25bb6a495bbfe5e157b6fa95ac539ca2033237d1..703002c6ce3ef4b2441840040eaa27357170b9b9 100644 --- a/tests/library/Class/ModelTestCase.php +++ b/tests/library/Class/ModelTestCase.php @@ -99,28 +99,9 @@ abstract class ModelTestCase extends Storm_Test_ModelTestCase { protected function tearDown() { - Bokeh_Engine::reset(); - Class_Url::setPhpMode(null); - Class_Notice_Thumbnail_ResizeImage::reset(); - Class_Album::setFileSystem(null); - Class_FileManager::reset(); - Class_MoteurRecherche::resetInstance(); - Class_Crypt::setPhpCommand(null); - Class_Cosmogramme_LandingDirectory::reset(); - Class_Cosmogramme_Generator_KindsTask::setDbAdapter(null); - - if($this->_storm_default_to_volatile) { - Storm_Model_Loader::defaultToDb(); - Class_Versions::defaultToFile(); - } - - Storm_Model_Abstract::unsetLoaders(); - Class_Systeme_ModulesAccueil::reset(); - if ($this->_registry_sql) - Zend_Registry::set('sql', $this->_registry_sql); - - Class_Systeme_Report_Portal::setIp(null); - parent::tearDown(); + new TearDown($this->_storm_default_to_volatile, + $this->_registry_sql); + return parent::tearDown(); } diff --git a/tests/scenarios/CiteDeLaMusique/CiteDeLaMusiqueTest.php b/tests/scenarios/CiteDeLaMusique/CiteDeLaMusiqueTest.php index bf1b5fa72ff9fce28d8931d0a047b256518ffa66..251e3321af706384c35899b282bb13a515da0b12 100644 --- a/tests/scenarios/CiteDeLaMusique/CiteDeLaMusiqueTest.php +++ b/tests/scenarios/CiteDeLaMusique/CiteDeLaMusiqueTest.php @@ -63,7 +63,6 @@ class CiteDeLaMusiqueFixtures { $user->beAbonneSIGB() ->assertSave(); - $test->fixture('Class_Profil', ['id' => 5, 'browser' => 'opac', @@ -133,6 +132,9 @@ class CiteDeLaMusiqueDisabledAdminTest extends Admin_AbstractControllerTestCase class CiteDeLaMusiqueModulesControllerTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { parent::setUp(); CiteDeLaMusiqueFixtures::prepare($this); @@ -172,6 +174,10 @@ class CiteDeLaMusiqueModulesControllerTest extends AbstractControllerTestCase { class CiteDeLaMusiqueRenderAlbumTest extends ViewHelperTestCase { + + protected $_storm_default_to_volatile = true; + + public function setUp() { parent::setUp(); CiteDeLaMusiqueFixtures::prepare($this); @@ -470,7 +476,14 @@ class CiteDeLaMusiqueOAIHarvestTest extends ModelTestCase { ->answers(CiteDeLaMusiqueFixtures::getFixtureContent('cite_de_la_musique_oai.xml')) ->whenCalled('open_url') - ->answers(''); + ->with('https://pad.philharmoniedeparis.fr/EXPLOITATION/oaiserver.ashx?verb=ListRecords&resumptionToken=%21%21videos-concerts-docu-entiers%21100%211061%21Ermes') + ->answers('') + + ->whenCalled('open_url') + ->with('https://pad.philharmoniedeparis.fr/EXPLOITATION/oaiserver.ashx?verb=ListRecords&metadataPrefix=ermes&set=audios-concerts-entiers&from=2017-10-11') + ->answers('') + + ->beStrict(); Class_WebService_BibNumerique_CiteDeLaMusique::setDefaultHttpClient($http_client); diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index 5c47ac1999ecdc0a7efe098a52a91e8831713d5b..b028fd18b00b85d999457a5972490d5b61aec544 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -21,6 +21,7 @@ require_once 'TemplatesTest.php'; + abstract class TemplatesIntonationAccountTestCase extends TemplatesIntonationTestCase { protected $_mock_emprunts, $_emprunteur; @@ -147,6 +148,7 @@ abstract class TemplatesIntonationAccountTestCase extends TemplatesIntonationTes 'libelle' => 'Istres', 'id_origine' => 'IST']); + $this->_emprunteur = new Class_WebService_SIGB_Emprunteur('1234', 'Florence'); $this->_emprunteur ->setLibraryCode('IST') @@ -284,13 +286,35 @@ class TemplatesDispatchAbonneLoansTest extends TemplatesIntonationAccountTestCas -class TemplatesAbonneSearchAjaxInReview extends TemplatesIntonationAccountTestCase { - protected $_storm_default_to_volatile = true, - $_id; +class TemplatesDispatchAbonneLoansPaginatedTest extends TemplatesIntonationAccountTestCase { + /** @test */ + public function page2ShouldContainsSearchInputWithMd5Key() { + Storm_Cache::beVolatile(); + $cards = new Class_User_Cards(Class_Users::getIdentity()); + $loans = $cards->getLoansWithOutPNB([]); + $loans = array_map(function($loan) + { + return (new Intonation_Library_View_Wrapper_Loan) + ->setModel($loan) + ->setView($this->view); + }, $loans->getArrayCopy()); - public function setUp() { - parent::setUp(); + $collection = new Storm_Collection($loans); + + $helper = (new Intonation_Library_AjaxPaginatedListHelper) + ->setCollection($collection) + ->setRendering('cardifyHorizontal'); + + $id = $helper->getId(); + + $this->dispatch('/opac/index/ajax-paginated-list/id/' . $id . '/page/2/render/ajax/id_profil/72'); + $this->assertContains('input_ba399369f4582ca10ca7b1651defce91', $this->_response->getBody()); + } + + + /** @test */ + public function page2ReviewsShouldContainsSearchInputWithMd5Key() { Storm_Cache::beVolatile(); $this->fixture('Class_AvisNotice', ['id' => 4, @@ -302,6 +326,7 @@ class TemplatesAbonneSearchAjaxInReview extends TemplatesIntonationAccountTestCa 'avis' => 'Le Roi des cons sur son throne', 'source_author' => null]); + $this->fixture('Class_AvisNotice', ['id' => 5, 'id_user' => 666, @@ -312,16 +337,6 @@ class TemplatesAbonneSearchAjaxInReview extends TemplatesIntonationAccountTestCa 'avis' => 'Le Roi des cons avec sa couronne', 'source_author' => null]); - $this->fixture('Class_AvisNotice', - ['id' => 6, - 'id_user' => 666, - 'id_notice' => 3, - 'clef_oeuvre' => 'PSYKO', - 'note' => '4', - 'entete' => 'les cons avec sa couronne', - 'avis' => 'les cons avec sa couronne', - 'source_author' => null]); - $this->fixture('Class_Notice', ['id' => 2, 'clef_oeuvre' => 'PSYKO', @@ -332,84 +347,26 @@ class TemplatesAbonneSearchAjaxInReview extends TemplatesIntonationAccountTestCa 'clef_oeuvre' => 'PSYKOTIC', ]); + $reviews = Class_AvisNotice::groupByRecords(Class_AvisNotice::findAll()); $reviews = array_map(function($review) - { - return (new Intonation_Library_View_Wrapper_ReviewsByRecord) - ->setModel($review) - ->setView($this->view); - }, $reviews); - + { + return (new Intonation_Library_View_Wrapper_ReviewsByRecord) + ->setModel($review) + ->setView($this->view); + }, $reviews); $collection = new Storm_Collection($reviews); - $helper = (new Intonation_Library_AjaxPaginatedListHelper) - ->setCollection($collection) - ->setRendering('cardifyHorizontal'); - - $this->_id = $helper->getId(); - } - - - /** @test */ - public function searchTermConRoiShouldReturn2Reviews() { - $this->dispatch('/opac/index/ajax-paginated-list/id/' . $this->_id . '/page/1/render/ajax/id_profil/72/size/3/search/cons+roi'); - $this->assertXPathCount('//div[contains(@class, "list-group-item")]', 2); - } - - - /** @test */ - public function nextAnchorUrlShouldContainsSearchTermConsRoi() { - $this->dispatch('/opac/index/ajax-paginated-list/id/' . $this->_id . '/page/1/render/ajax/id_profil/72/size/3/search/cons+roi'); - $this->assertXPath('//a[contains(@class, "next_ajax_anchor")][contains(@href, "/search/cons+roi")]'); - } - - - /** @test */ - public function searchTermConRoiShouldReturnReviewAtPageTwo() { - $this->dispatch('/opac/index/ajax-paginated-list/id/' . $this->_id . '/page/2/render/ajax/id_profil/72/size/1/search/cons+roi'); - - $this->assertXPathContentContains('//div','avec sa couronne', $this->_response->getBody()); - } - - - /** @test */ - public function searchInputShouldBePresentWithExpectedHash() { - $this->dispatch('/opac/index/ajax-paginated-list/id/' . $this->_id . '/page/2/render/ajax/id_profil/72/size/1/search/cons+roi'); - - $this->assertContains('input_99914b932bd37a50b983c5e7c90ae93b', $this->_response->getBody()); - $this->assertContains('avec sa couronne', $this->_response->getBody()); - - } -} - - - - -class TemplatesDispatchAbonneLoansPaginatedTest extends TemplatesIntonationAccountTestCase { - /** @test */ - public function page2ShouldContainsSearchInputWithMd5Key() { - Storm_Cache::beVolatile(); - $cards = new Class_User_Cards(Class_Users::getIdentity()); - $loans = $cards->getLoansWithOutPNB([]); - $loans = array_map(function($loan) - { - return (new Intonation_Library_View_Wrapper_Loan) - ->setModel($loan) - ->setView($this->view); - }, $loans->getArrayCopy()); - - $collection = new Storm_Collection($loans); - $helper = (new Intonation_Library_AjaxPaginatedListHelper) ->setCollection($collection) ->setRendering('cardifyHorizontal'); $id = $helper->getId(); - $this->dispatch('/opac/index/ajax-paginated-list/id/' . $id . '/page/2/render/ajax/id_profil/72'); - $this->assertContains('input_99914b932bd37a50b983c5e7c90ae93b', $this->_response->getBody()); - + $this->dispatch('/opac/index/ajax-paginated-list/id/' . $id . '/page/2/render/ajax/id_profil/72/size/1/search/roi'); + $this->assertContains('input_db436b32a1026df5398c4c8e32b1c51b', $this->_response->getBody()); + $this->assertContains('avec sa couronne', $this->_response->getBody()); } @@ -422,11 +379,11 @@ class TemplatesDispatchAbonneLoansPaginatedTest extends TemplatesIntonationAccou $loans = $cards->getPNBLoans([]); $loans = array_map(function($loan) - { - return (new Intonation_Library_View_Wrapper_PNBLoan) - ->setModel($loan) - ->setView($this->view); - }, $loans->getArrayCopy()); + { + return (new Intonation_Library_View_Wrapper_PNBLoan) + ->setModel($loan) + ->setView($this->view); + }, $loans->getArrayCopy()); $collection = new Storm_Collection($loans); @@ -434,12 +391,13 @@ class TemplatesDispatchAbonneLoansPaginatedTest extends TemplatesIntonationAccou ->setCollection($collection) ->setRendering('cardifyHorizontal'); + $id = $helper->getId(); $this->dispatch('/opac/index/ajax-paginated-list/id/' . $id . '/page/1/id_profil/72/search/house/size/10'); $this->assertXPathContentContains('//div//a', 'Dr House'); - $this->assertXPathContentContains('//div//a[contains(@href, "/bib-numerique/return-pnb-loan/id/99914b932bd37a50b983c5e7c90ae93b/page/1/id_profil/72/search/house/size/10/loan_id/666_3")]', 'Retour anticip', $this->_response->getBody()); - $this->assertXPathContentContains('//div//a[contains(@href, "/bib-numerique/extends-pnb-loan/id/99914b932bd37a50b983c5e7c90ae93b/page/1/id_profil/72/search/house/size/10/loan_id/666_3")]', 'Prolonger'); + $this->assertXPathContentContains('//div//a[contains(@href, "/bib-numerique/return-pnb-loan/id/ec2c17cefacacad7f25f875ae87956c1/page/1/id_profil/72/search/house/size/10/loan_id/666_3")]', 'Retour anticip', $this->_response->getBody()); + $this->assertXPathContentContains('//div//a[contains(@href, "/bib-numerique/extends-pnb-loan/id/ec2c17cefacacad7f25f875ae87956c1/page/1/id_profil/72/search/house/size/10/loan_id/666_3")]', 'Prolonger'); } @@ -522,6 +480,7 @@ class TemplatesDispatchAbonneAjaxLoansTest extends TemplatesIntonationAccountTes + class TemplatesDispatchAbonneMonHistoriqueTest extends TemplatesIntonationAccountTestCase { public function setUp(){ parent::setUp(); @@ -571,6 +530,7 @@ class TemplatesDispatchAbonneMonHistoriqueTest extends TemplatesIntonationAccoun } + /** @test */ public function pageShouldDisplayTitleMonHistoriqueDePrets() { $this->assertXPathContentContains('//h2//span', 'Mon historique de prêts'); @@ -627,6 +587,7 @@ class TemplatesDispatchAbonneLoansWithHistoryTest extends TemplatesIntonationAcc $this->_emprunteur->setService($this->_mock_emprunts); + $this->dispatch('/opac/abonne/ajax-loans/history/1/id_profil/72'); } @@ -831,7 +792,6 @@ class TemplatesDispatchAbonneConfigurationsTest extends TemplatesIntonationAccou - class TemplatesDispatchAbonneDonnerDesAvisTest extends TemplatesIntonationAccountTestCase { /** @test */ public function donnerDesAvisShouldBeDisplay() { @@ -842,7 +802,6 @@ class TemplatesDispatchAbonneDonnerDesAvisTest extends TemplatesIntonationAccoun - class TemplatesDispatchAbonneSuivreUneRechercheTest extends TemplatesIntonationAccountTestCase { /** @test */ public function suivreUneRechercheShouldBeDisplay() { @@ -915,7 +874,6 @@ class TemplatesAbonneAccountFieldsTest extends TemplatesIntonationAccountTestCas ['mode_contact', Class_Users::MODE_CONTACT_SMS]]; } - /** * @test * @dataProvider fields @@ -1227,8 +1185,6 @@ class TemplatesDispatchAbonneCardsTest extends TemplatesIntonationAccountTestCas } - - class TemplatesDispatchAbonnePagesTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; @@ -1268,10 +1224,10 @@ class TemplatesDispatchAbonnePagesTest extends AbstractControllerTestCase { - class TemplatesAbonneWithPNBHoldsTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); @@ -1355,6 +1311,7 @@ class TemplatesAbonneWithPNBHoldsTest extends AbstractControllerTestCase { class TemplatesAbonneSearchHistoryTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); @@ -1408,6 +1365,7 @@ class TemplatesAbonneEditActionFicheTest extends Admin_AbstractControllerTestCas 'fiche')), [Intonation_Library_View_Wrapper_User_RichContent_Agenda::class => '0']); + $this->dispatch('/admin/widget/edit-action/id/abonne_fiche/id_profil/19'); } @@ -1432,6 +1390,7 @@ class TemplatesAbonneAgendaDisabledTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); @@ -1758,3 +1717,105 @@ class TemplatesAbonneCacheSuggestionsTest extends TemplatesAbonneCacheTestCase { $this->dispatch('/opac/abonne/suggestions'); } } + + + + +class TemplatesAbonneSearchAjaxInReview extends TemplatesIntonationAccountTestCase { + protected $_storm_default_to_volatile = true, + $_id; + + + public function setUp() { + parent::setUp(); + Storm_Cache::beVolatile(); + $this->fixture('Class_AvisNotice', + ['id' => 4, + 'id_user' => 666, + 'id_notice' => 2, + 'clef_oeuvre' => 'PSYKO', + 'note' => '4', + 'entete' => 'Le Roi', + 'avis' => 'Le Roi des cons sur son throne', + 'source_author' => null]); + + $this->fixture('Class_AvisNotice', + ['id' => 5, + 'id_user' => 666, + 'id_notice' => 3, + 'clef_oeuvre' => 'PSYKO', + 'note' => '4', + 'entete' => 'Le Roi des cons avec sa couronne', + 'avis' => 'Le Roi des cons avec sa couronne', + 'source_author' => null]); + + $this->fixture('Class_AvisNotice', + ['id' => 6, + 'id_user' => 666, + 'id_notice' => 3, + 'clef_oeuvre' => 'PSYKO', + 'note' => '4', + 'entete' => 'les cons avec sa couronne', + 'avis' => 'les cons avec sa couronne', + 'source_author' => null]); + + $this->fixture('Class_Notice', + ['id' => 2, + 'clef_oeuvre' => 'PSYKO', + ]); + + $this->fixture('Class_Notice', + ['id' => 3, + 'clef_oeuvre' => 'PSYKOTIC', + ]); + + $reviews = Class_AvisNotice::groupByRecords(Class_AvisNotice::findAll()); + $reviews = array_map(function($review) + { + return (new Intonation_Library_View_Wrapper_ReviewsByRecord) + ->setModel($review) + ->setView($this->view); + }, $reviews); + + + $collection = new Storm_Collection($reviews); + + $helper = (new Intonation_Library_AjaxPaginatedListHelper) + ->setCollection($collection) + ->setRendering('cardifyHorizontal'); + + $this->_id = $helper->getId(); + } + + + /** @test */ + public function searchTermConRoiShouldReturn2Reviews() { + $this->dispatch('/opac/index/ajax-paginated-list/id/' . $this->_id . '/page/1/render/ajax/id_profil/72/size/3/search/cons+roi'); + $this->assertXPathCount('//div[contains(@class, "list-group-item")]', 2); + } + + + /** @test */ + public function nextAnchorUrlShouldContainsSearchTermConsRoi() { + $this->dispatch('/opac/index/ajax-paginated-list/id/' . $this->_id . '/page/1/render/ajax/id_profil/72/size/3/search/cons+roi'); + $this->assertXPath('//a[contains(@class, "next_ajax_anchor")][contains(@href, "/search/cons+roi")]'); + } + + + /** @test */ + public function searchTermConRoiShouldReturnReviewAtPageTwo() { + $this->dispatch('/opac/index/ajax-paginated-list/id/' . $this->_id . '/page/2/render/ajax/id_profil/72/size/1/search/cons+roi'); + + $this->assertXPathContentContains('//div','avec sa couronne', $this->_response->getBody()); + } + + + /** @test */ + public function searchInputShouldBePresentWithExpectedHash() { + $this->dispatch('/opac/index/ajax-paginated-list/id/' . $this->_id . '/page/2/render/ajax/id_profil/72/size/1/search/cons+roi'); + + $this->assertContains('input_7e2bd926b5277b4a85b9bb18b72a431a', $this->_response->getBody()); + $this->assertContains('avec sa couronne', $this->_response->getBody()); + + } +} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php b/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php index 55b794a69d32c88fd33f7987cf39c63599d79f86..0a5327e72b37bcc895c612cde65c3ab9a1884988 100644 --- a/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php +++ b/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php @@ -109,7 +109,7 @@ abstract class TemplatesAjaxPaginatedListTestCase extends AbstractControllerTest $data = $this->_ajax_paginated_list_helper->getDataToCache(); $serialized = serialize($data); $size = mb_strlen($serialized); - $this->assertTrue('1024' > $size); + $this->assertTrue(1024 > $size); } @@ -263,7 +263,7 @@ class TemplatesAjaxPaginatedListWithHoldTest extends TemplatesAjaxPaginatedListT $data = $this->_ajax_paginated_list_helper->getDataToCache(); $serialized = serialize($data); $size = mb_strlen($serialized); - $this->assertTrue('1524' > $size); + $this->assertTrue(3072 > $size); } } @@ -331,7 +331,7 @@ class TemplatesAjaxPaginatedListWithLoanTest extends TemplatesAjaxPaginatedListT $data = $this->_ajax_paginated_list_helper->getDataToCache(); $serialized = serialize($data); $size = mb_strlen($serialized); - $this->assertTrue('1524' > $size); + $this->assertTrue(2048 > $size); } } @@ -605,7 +605,7 @@ class TemplatesAjaxPaginatedListWithRssItemTest extends TemplatesAjaxPaginatedLi $data = $this->_ajax_paginated_list_helper->getDataToCache(); $serialized = serialize($data); $size = mb_strlen($serialized); - $this->assertTrue('1524' > $size); + $this->assertTrue(1524 > $size); } } @@ -906,6 +906,63 @@ class TemplatesAjaxPaginatedListWithLoanAndSearchTest extends TemplatesAjaxPagin $data = $this->_ajax_paginated_list_helper->getDataToCache(); $serialized = serialize($data); $size = mb_strlen($serialized); - $this->assertTrue('1524' > $size); + $this->assertTrue(2048 > $size); + } +} + + + + +class TemplatesAjaxPaginatedListWithSameCollectionIdsTest extends AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + + /** @test */ + public function withDifferentClassesCacheKeyShouldBeDifferent() { + $records = [$this->fixture(Class_Notice::class, ['id' => 1]), + $this->fixture(Class_Notice::class, ['id' => 2])]; + + $items = [$this->fixture(Class_Exemplaire::class, ['id' => 1]), + $this->fixture(Class_Exemplaire::class, ['id' => 2])]; + + $key_1 = (new Intonation_Library_AjaxPaginatedListHelper) + ->setCollection(new Storm_Collection($records)) + ->getId(); + + $key_2 = (new Intonation_Library_AjaxPaginatedListHelper) + ->setCollection(new Storm_Collection($items)) + ->getId(); + + $this->assertNotEquals($key_1, $key_2); + } + + + + /** @test */ + public function withDifferentIdCacheKeyShouldBeDifferent() { + $user = $this->fixture(Class_Users::class, + ['id' => 1, + 'login'=> 'log', + 'password' => 'pass']); + + $item_1 = new Class_WebService_SIGB_Exemplaire(1); + $loan_1 = new Class_WebService_SIGB_Emprunt(1, $item_1); + + $item_2 = new Class_WebService_SIGB_Exemplaire(2); + $loan_2 = new Class_WebService_SIGB_Emprunt(2, $item_2); + + $card_operation_decorator_1 = new Class_User_CardsOperationDecorator($loan_1, $user); + $card_operation_decorator_2 = new Class_User_CardsOperationDecorator($loan_2, $user); + + $key_1 = (new Intonation_Library_AjaxPaginatedListHelper) + ->setCollection(new Storm_Collection([new Intonation_Library_View_Wrapper_Loan($card_operation_decorator_1)])) + ->getId(); + + $key_2 = (new Intonation_Library_AjaxPaginatedListHelper) + ->setCollection(new Storm_Collection([new Intonation_Library_View_Wrapper_Loan($card_operation_decorator_2)])) + ->getId(); + + $this->assertNotEquals($key_1, $key_2); } } \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesWebsitesTest.php b/tests/scenarios/Templates/TemplatesWebsitesTest.php index 8c606bb41b662e76f7cb66a18937532b300e6d79..cdd7e36e41b74fc757468c2879339f3473acfe01 100644 --- a/tests/scenarios/Templates/TemplatesWebsitesTest.php +++ b/tests/scenarios/Templates/TemplatesWebsitesTest.php @@ -431,6 +431,6 @@ class TemplatesWebsitesDispatchPaginatedTest extends TemplatesWebsitesFixturesTe $id = $helper->getId(); $this->dispatch('/opac/index/ajax-paginated-list/id/' . $id . '/page/1/render/ajax/id_profil/19'); - $this->assertXPath('//form//input[@name="input_99914b932bd37a50b983c5e7c90ae93b"]'); + $this->assertXPath('//form//input[@name="input_3bbeeef790e61514feb083341497ce60"]'); } } \ No newline at end of file