From 558cc1b32f96003d2080ac8c027612d9adafaf3b Mon Sep 17 00:00:00 2001 From: efalcy <efalcy@afi-sa.fr> Date: Fri, 18 Sep 2020 14:42:33 +0200 Subject: [PATCH] dev#103866 cosmo variables zendification --- FEATURES/103866 | 10 ++ VERSIONS_WIP/103866 | 1 + .../controllers/ConfigVariablesController.php | 39 +++++ .../scripts/config-variables/index.phtml | 1 + .../cosmo/controllers/ConfigVariablesTest.php | 137 ++++++++++++++++++ .../Plugin/Manager/ConfigVariables.php | 26 ++++ .../ResourceDefinition/ConfigVariables.php | 41 ++++++ 7 files changed, 255 insertions(+) create mode 100644 FEATURES/103866 create mode 100644 VERSIONS_WIP/103866 create mode 100644 cosmogramme/cosmozend/application/modules/cosmo/controllers/ConfigVariablesController.php create mode 100644 cosmogramme/cosmozend/application/modules/cosmo/views/scripts/config-variables/index.phtml create mode 100644 cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/ConfigVariablesTest.php create mode 100644 library/ZendAfi/Controller/Plugin/Manager/ConfigVariables.php create mode 100644 library/ZendAfi/Controller/Plugin/ResourceDefinition/ConfigVariables.php diff --git a/FEATURES/103866 b/FEATURES/103866 new file mode 100644 index 00000000000..5fc583772be --- /dev/null +++ b/FEATURES/103866 @@ -0,0 +1,10 @@ + '103866' => + ['Label' => $this->_('FRBR : Configuration clé Oeuvre'), + 'Desc' => '', + 'Image' => '', + 'Video' => '', + 'Category' => '', + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => '', + 'Test' => '', + 'Date' => '2020-09-17'], \ No newline at end of file diff --git a/VERSIONS_WIP/103866 b/VERSIONS_WIP/103866 new file mode 100644 index 00000000000..93ee66d567a --- /dev/null +++ b/VERSIONS_WIP/103866 @@ -0,0 +1 @@ + - ticket #103866 : FRBR : Configuration clé Oeuvre \ No newline at end of file diff --git a/cosmogramme/cosmozend/application/modules/cosmo/controllers/ConfigVariablesController.php b/cosmogramme/cosmozend/application/modules/cosmo/controllers/ConfigVariablesController.php new file mode 100644 index 00000000000..37e0902f47e --- /dev/null +++ b/cosmogramme/cosmozend/application/modules/cosmo/controllers/ConfigVariablesController.php @@ -0,0 +1,39 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Cosmo_ConfigVariablesController extends ZendAfi_Controller_Action { + + public function getPlugins() { + return ['ZendAfi_Controller_Plugin_ResourceDefinition_ConfigVariables', + 'ZendAfi_Controller_Plugin_Manager_ConfigVariables']; + } + + + protected function _redirectToIndex() { + $url = '/cosmo/'.$this->_request->getControllerName().'/index'; + if (($scope_field = $this->_definitions->getScope()) + && ($scope_value = $this->_getParam($scope_field))) + $url .= '/'.$scope_field.'/'.$scope_value; + $this->_redirect($url); + } +} +?> \ No newline at end of file diff --git a/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/config-variables/index.phtml b/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/config-variables/index.phtml new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/config-variables/index.phtml @@ -0,0 +1 @@ + diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/ConfigVariablesTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/ConfigVariablesTest.php new file mode 100644 index 00000000000..8a982704458 --- /dev/null +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/ConfigVariablesTest.php @@ -0,0 +1,137 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +abstract class Cosmo_ConfigVariablesControllerTestCase extends CosmoControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + Class_IntProfilDonnees::forKoha() + ->setId(56) + ->setItemField(Class_IntProfilDonnees::FIELD_ITEM_ID_ORIGINE, ['zone' => '999', + 'champ' => 'c']) + ->setItemField(Class_IntProfilDonnees::FIELD_ITEM_BUNDLE_ID, 8) + ->save(); + + Class_IntProfilDonnees::forNanook() + ->setId(105) + ->save(); + + Class_IntProfilDonnees::forPergamePatrons() + ->setId(106) + ->save(); + + $this->fixture('Class_CosmoVar', + ['id' => 'champs_pret', + 'valeur' => null, + 'liste' => "ID_PERGAME:id_pret Pergame\r\nIDABON:id abonné\r\nORDREABON:no d'ordre\r\nEN_COURS:prêt en cours\r\nDATE_PRET:date du prêt\r\nDATE_RETOUR:date de retour\r\nID_NOTICE_ORIGINE:id notice Pergame\r\nSUPPORT:code support\r\nETIQUETTE:numéro d'étiquette (incrémental)"]); + + $this->fixture('Class_CosmoVar', + ['id' => 'types_docs', + 'valeur' => null, + 'liste' => "0:non identifié\r\n1:Livres\r\n"]); + + $this->fixture('Class_CosmoVar', + ['id' => 'id_article_periodique', + 'valeur' => null, + 'liste' => "0:aucun\r\n1:pergame\r\n2:opsys indexpresse\r\n3:Koha\r\n4:Orphée"]); + } + + + public function tearDown() { + Class_IntProfilDonnees::clearCache(); + Class_CosmoVar::clearCache(); + Class_TypeDoc::clearCache(); + Class_ScriptLoader::resetInstance(); + parent::tearDown(); + } +} + + + +class Cosmo_ConfigVariablesIndexTest extends Cosmo_ConfigVariablesControllerTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/cosmo/config-variables', true); + } + + + public function addNewProfileShouldBePresent() { + $this->assertXPath('//div', 'Integration'); + } + + + /** @test */ + public function secondTrShouldContainsKoha() { + $this->assertXPathContentContains('//table//tr[2]/td', 'Koha'); + } + + + /** @test */ + public function thirdTrShouldContainsRecordsFileType() { + $this->assertXPathContentContains('//table//tr[3]/td[2]', 'Notices'); + } + + + /** @test */ + public function thirdTrShouldContainsUnimarcFormat() { + $this->assertXPathContentContains('//table//tr[3]/td[3]', 'Unimarc'); + } + + + /** @test */ + public function thirdTrShouldContainsNonUsedFlag() { + $this->assertXPathContentContains('//table//tr[3]/td[4]', 'Non'); + } + + + /** @test */ + public function secondTrShouldContainsLinkEditKohaProfile() { + $this->assertXPath('//table//tr[2]/td/a[contains(@href, "/cosmo/data-profile/edit/id/56")]'); + } + + + /** @test */ + public function thirdTrShouldContainsNanook() { + $this->assertXPathContentContains('//table//tr[3]/td', 'Nanook'); + } + + + /** @test */ + public function tableSorterJsShouldBeloaded() { + $this->assertXPath('//script[contains(@src, "/public/opac/js/tablesorter/js/jquery.tablesorter.")]'); + } + + + /** @test */ + public function jQueryUIShouldBeLoaded() { + $this->assertXPath('//script[contains(@src, "/public/admin/js/jquery-ui")]'); + } + + + /** @test */ + public function jQueryShouldBeLoaded() { + $this->assertXPath('//script[contains(@src, "/public/admin/js/jquery-")]'); + } +} diff --git a/library/ZendAfi/Controller/Plugin/Manager/ConfigVariables.php b/library/ZendAfi/Controller/Plugin/Manager/ConfigVariables.php new file mode 100644 index 00000000000..7f373fa03f0 --- /dev/null +++ b/library/ZendAfi/Controller/Plugin/Manager/ConfigVariables.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_Controller_Plugin_Manager_ConfigVariables extends ZendAfi_Controller_Plugin_Manager_ExternalManager { + +} +?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/ConfigVariables.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/ConfigVariables.php new file mode 100644 index 00000000000..767d490dbd1 --- /dev/null +++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/ConfigVariables.php @@ -0,0 +1,41 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_Controller_Plugin_ResourceDefinition_ConfigVariables extends ZendAfi_Controller_Plugin_ResourceDefinition_Abstract { + + public function getDefinitions() { + return ['model' => ['class' => 'Class_CosmoVar', + 'name' => 'variables', + 'order' => 'libelle'], + + 'messages' => ['successful_save' => $this->_('Profil "%s" sauvegardé'), + 'successful_add' => $this->_('Profil "%s" ajouté'), + 'successful_delete' => $this->_('Profil "%s" supprimé')], + + 'actions' => ['add' => ['title' => $this->_('Nouveau profil de données')], + 'edit' => ['title' => $this->_('Modifier le profil de données : %s')], + 'index' => ['title' => $this->_('Profils de données')]], + + 'form_class_name' => 'ZendAfi_Form_Cosmo_DataProfile']; + } +} +?> \ No newline at end of file -- GitLab