From 3d2d6e8e42071b9692b8866c70b647205dbc009f Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@afi-sa.fr> Date: Thu, 21 May 2015 17:29:28 +0200 Subject: [PATCH] hotline #25250 notices articles null data insertion Add Aloes indexpress articles test case --- cosmogramme/php/classes/classe_unimarc.php | 2 +- .../php/classes/NoticeIntegrationTest.php | 39 ++++++++++++++++++- .../php/classes/unimarc_petit_doucet.txt | 1 + library/Class/Notice/SerialArticles.php | 15 +++++++ 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 cosmogramme/tests/php/classes/unimarc_petit_doucet.txt diff --git a/cosmogramme/php/classes/classe_unimarc.php b/cosmogramme/php/classes/classe_unimarc.php index 24247080769..498c1bc850f 100644 --- a/cosmogramme/php/classes/classe_unimarc.php +++ b/cosmogramme/php/classes/classe_unimarc.php @@ -203,7 +203,7 @@ class notice_unimarc extends iso2709_record { { // type de doc $notice["type_doc"] = 100; - $notice["infos_type_doc"] = array("code"=>100,libelle=>"article de périodique"); + $notice["infos_type_doc"] = ["code"=>100, 'libelle'=>"article de périodique"]; // statut $notice["statut"] = $this->getStatut(); diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php index 9a679cd3b9e..d00feec099d 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php @@ -2384,4 +2384,41 @@ class NoticeIntegrationSerialTopSanteTest extends NoticeIntegrationTestCase { public function noticeShouldHaveFiveArticles() { $this->assertCount(5, $this->notice->getArticlesPeriodique()); } -} \ No newline at end of file +} + + + +class NoticeIntegrationAloesSerialIndexpressBellesHistoireTest extends NoticeIntegrationTestCase { + public function getProfilDonnees() { + return Class_IntProfilDonnees::forALOES() + ->setIdProfil(111) + ->getRawAttributes(); + } + + + public function setUp() { + parent::setUp(); + + $contents = file_get_contents(dirname(__FILE__)."/unimarc_petit_doucet.txt"); + + array_map([$this, 'loadNoticeFromString'], + preg_split('/'.chr(30).chr(29).'/', $contents)); + + $this->notice = Class_Notice::find(1); + } + + + /** @test */ + public function mainTitleShouldBeBellesHistoires() { + $this->assertEquals('Belles histoires (Les)', $this->notice->getTitrePrincipal()); + } + + + /** @test */ + public function noArticleShouldHaveBeenSaved() { + $this->assertCount(0, Class_Notice_SerialArticles::findAll()); + } +} + + +?> \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/unimarc_petit_doucet.txt b/cosmogramme/tests/php/classes/unimarc_petit_doucet.txt new file mode 100644 index 00000000000..bc11399aa4c --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_petit_doucet.txt @@ -0,0 +1 @@ +00369nas0 2200097 450 0010008000001000041000082000044000494610036000934620093001299950049002220690665 a20150429a|||| uu y0frey0103 ba| aBelles histoires (Les)h509i01/05/2015 |30627457tBelles histoires (Les) 30690669tLe petit Doucet et les 7 filles de l'ogrefHistoire Âecrite par Arnaud AlmÂeras 30690666aBDYbYf16431346045kA ALM bqJruu00638naa0 2200181 450 0010008000001000041000081010008000491020007000572000113000642150010001773300159001876760006003467000037003527020023003898010028004129020010004409030006004500690669 a20150429a|||| u y0frey0103 ba| afre aFR| aLe petit Doucet et les 7 filles de l'ogrefHistoire Âecrite par Arnaud AlmÂerasgillustrÂee par Sara Ogilvie a42 p. aIl Âetait une fois un petit garÐcon et trÁes gentil... Un jour, ses six frÁeres trÁes moqueurs et trÁes mÂechants dÂecident de le perdre dans la forÃet... aA 1aAlmÂerasbArnaudf1967-....4070 1aOgilviebSara4440 1aFRbBDP YONNEc20150429 aAlbum ab \ No newline at end of file diff --git a/library/Class/Notice/SerialArticles.php b/library/Class/Notice/SerialArticles.php index 0f6c821d08b..ebf55ba7833 100644 --- a/library/Class/Notice/SerialArticles.php +++ b/library/Class/Notice/SerialArticles.php @@ -23,6 +23,21 @@ class Class_Notice_SerialArticles extends Storm_Model_Abstract { protected $_table_name = 'notices_articles', $_table_primary = 'id_article'; + + + protected $_default_attribute_values = ['clef_chapeau' => '', + 'clef_numero' => '', + 'clef_article' => '', + 'unimarc' => '']; + + + public function validate() { + if (!$this->getClefChapeau()) + $this->addError('Clé chapeau requise'); + + if (!$this->getClefNumero()) + $this->addError('Clé numero requise'); + } } ?> \ No newline at end of file -- GitLab