From cae9d7f73ff8b0ad0f3d3efbdabe6f33cc5aff07 Mon Sep 17 00:00:00 2001 From: Ghislain Loas <ghislo@sandbox.pergame.net> Date: Tue, 29 Mar 2016 15:27:59 +0200 Subject: [PATCH] dev #35088 implementing post --- .../controllers/DataProfileControllerTest.php | 43 ++++++++++++++++--- library/Class/IntProfilDonnees.php | 32 +++++++++++--- library/Class/ProfileSerializer.php | 33 ++++++++++---- 3 files changed, 90 insertions(+), 18 deletions(-) diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php index 76442fb3f55..c69b3915a30 100644 --- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php @@ -348,7 +348,7 @@ class Cosmo_DataProfileControllerEditUnimarcKohaFileFormatTest extends Cosmo_Dat class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo_DataProfileControllerTestCase { - protected $_storm_default_to_volatile = false; + protected $_koha; public function setUp() { parent::setUp(); @@ -367,6 +367,12 @@ class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo 'champ_emplacement' => 'u', 'champ_annexe' => 'a', 'champ_availability' => 't', + 'url_zone' => [0 => '', + 1 => '932', + 2 => ''], + 'url_champ' => [0 => '', + 1 => 'n', + 2 => ''], 'rejet_periodiques' => 1, 'id_article_periodique' => 1, 'nouveaute_format' => 4, @@ -384,6 +390,8 @@ class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo 'carts' => 'LIBELLE; ROLE']; $this->postDispatch('cosmo/data-profile/edit/id/56', $post, true); + + $this->_koha = Class_IntProfilDonnees::find(56); } @@ -395,24 +403,49 @@ class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo /** @test */ public function libelleShouldBeNewKoha() { - $this->assertEquals('New Koha', Class_IntProfilDonnees::find(56)->getLibelle()); + $this->assertEquals('New Koha', $this->_koha->getLibelle()); } /** @test */ public function accentsShouldBeISO2709() { - $this->assertEquals(Class_IntProfilDonnees::ENCODING_ISO2709, Class_IntProfilDonnees::find(56)->getAccents()); + $this->assertEquals(Class_IntProfilDonnees::ENCODING_ISO2709, $this->_koha->getAccents()); } /** @test */ public function xmlBaliseAbonneShouldBeSubscribers() { - $this->assertEquals('subscribers', Class_IntProfilDonnees::find(56)->getXmlBaliseAbonne()); + $this->assertEquals('subscribers', $this->_koha->getXmlSubscriberField()); } /** @test */ public function xmlAbonneIdShouldBeId() { - $this->assertEquals('id', Class_IntProfilDonnees::find(56)->getXmlAbonneId()); + $this->assertEquals('id', $this->_koha->getXmlSubscriberFieldsAt('IDABON')); + } + + + /** @test */ + public function champsCodeBarresShouldBeF() { + $this->assertEquals('f', $this->_koha->getBarCode()); + } + + + /** @test */ + public function champsAvailabilityBeT() { + $this->assertEquals('t', $this->_koha->getAvailability()); } + + + /** @test */ + public function urlLabelShouldBeIn932() { + $this->assertEquals('932', $this->_koha->getUrlLabel()); + } + + + /** @test */ + public function urlFieldShouldBeInN() { + $this->assertEquals('n', $this->_koha->getUrlField()); + } + } \ No newline at end of file diff --git a/library/Class/IntProfilDonnees.php b/library/Class/IntProfilDonnees.php index 9611876969a..6438adb4c50 100644 --- a/library/Class/IntProfilDonnees.php +++ b/library/Class/IntProfilDonnees.php @@ -22,6 +22,19 @@ class IntProfilDonneesLoader extends Storm_Model_Loader { use Trait_Translator; + + public function getItemFields() { + return [Class_IntProfilDonnees::FIELD_ITEM_BARCODE => '', + Class_IntProfilDonnees::FIELD_ITEM_COTE => '', + Class_IntProfilDonnees::FIELD_ITEM_TYPE_DOC => '', + Class_IntProfilDonnees::FIELD_ITEM_GENRE => '', + Class_IntProfilDonnees::FIELD_ITEM_SECTION => '', + Class_IntProfilDonnees::FIELD_ITEM_EMPLACEMENT => '', + Class_IntProfilDonnees::FIELD_ITEM_ANNEXE => '', + Class_IntProfilDonnees::FIELD_ITEM_AVAILABILITY => '']; + } + + public function getEncodings() { return [ Class_IntProfilDonnees::ENCODING_UTF8 => $this->_('UTF-8'), Class_IntProfilDonnees::ENCODING_ISO2709 => $this->_('ISO 2709'), @@ -170,8 +183,7 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { NOVELTY_FORMAT = 'format', NOVELTY_VALEURS = 'valeurs', XML_SUBSCRIBER_FIELD = 'xml_balise_abonne', - XML_SUBSCRIBER_FIELDS = 'xml_champs_abonne', - XML_IDABON = 'IDABON'; + XML_SUBSCRIBER_FIELDS = 'xml_champs_abonne'; protected $_table_name = 'profil_donnees', @@ -707,13 +719,23 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { } - public function getXmlBaliseAbonne() { + public function getXmlSubscriberField() { return $this->getProfilePrefs()->getSubscriberXmlField(); } - public function getXmlAbonneId() { - return $this->getProfilePrefs()->getSubscriberXmlFieldValue(Class_IntProfilDonnees::XML_IDABON); + public function getXmlSubscriberFieldsAt($key) { + return $this->getProfilePrefs()->getSubscriberXmlFieldValue($key); + } + + + public function getBarCode() { + return $this->getProfilePrefs()->getItemBarCode(); + } + + + public function getAvailability() { + return $this->getProfilePrefs()->getItemAvailability(); } diff --git a/library/Class/ProfileSerializer.php b/library/Class/ProfileSerializer.php index f517ea462e6..61d77c4b22c 100644 --- a/library/Class/ProfileSerializer.php +++ b/library/Class/ProfileSerializer.php @@ -36,27 +36,37 @@ class Class_ProfileSerializer { $data[] = $this->extractCarts(); $data[] = $this->extractLoans(); $data[] = $this->extractHolds(); - xdebug_break(); + return serialize($data); } public function extractRecords() { - return [$this->extractDocTypes(), - $this->extractItemFields(), - $this->extractSerialFields(), - $this->extractInterestFields(), - $this->extractNoveltyfields()]; + $datas = array_merge($this->extractDocTypes(), $this->extractItemFields(), $this->extractItemUrl()); + return $datas; + +/* $this->extractDocTypes(), */ +/* $this->extractItemFields(), */ +/* $this->extractSerialFields(), */ +/* $this->extractInterestFields(), */ +/* $this->extractNoveltyfields()]; */ } public function extractDocTypes() { + return [Class_IntProfilDonnees::PROFILE_DOC_TYPES => []]; + } + + public function extractItemUrl() { + return [Class_IntProfilDonnees::FIELD_ITEM_URL => []]; } public function extractItemFields() { - + $datas = array_intersect_key($this->_datas, Class_IntProfilDonnees::getItemFields()); + xdebug_break(); + return $datas; } @@ -102,7 +112,14 @@ class Class_ProfileSerializer { public function extractSubscriberFields() { - return [Class_IntProfilDonnees::XML_IDABON => $this->_datas[static::XML_PREFIX . Class_IntProfilDonnees::XML_IDABON]]; + $xml_fields = Class_IntProfilDonnees::getSubscriberFields(); + $subscriber_fields = []; + foreach($xml_fields as $key => $field) { + $key = trim(strtoupper($key)); + $subscriber_fields[$key] = $this->_datas[static::XML_PREFIX . $key]; + } + + return $subscriber_fields; } } ?> \ No newline at end of file -- GitLab