From df694ba5771c63abaa76005dc252d6bcc5caa384 Mon Sep 17 00:00:00 2001 From: pbarroca <pbarroca@git-test.afi-sa.fr> Date: Fri, 10 Jan 2014 10:28:35 +0000 Subject: [PATCH] Bibnum : Indexation des genres d'album --- .../php/classes/classe_notice_integration.php | 11 ++-- .../php/classes/NoticeIntegrationTest.php | 12 +++- library/Class/Album.php | 1 + tests/library/Class/AlbumTest.php | 59 ++++++------------- 4 files changed, 35 insertions(+), 48 deletions(-) diff --git a/cosmogramme/php/classes/classe_notice_integration.php b/cosmogramme/php/classes/classe_notice_integration.php index 7b0a4986284..fddb5a87aa4 100644 --- a/cosmogramme/php/classes/classe_notice_integration.php +++ b/cosmogramme/php/classes/classe_notice_integration.php @@ -377,7 +377,7 @@ class notice_integration $table="cms_article"; $colonne_clef="ID_ARTICLE"; $label="m1"; - $enreg["DESCRIPTION"]=strip_tags($enreg["CONTENU"]); + $enreg["DESCRIPTION"] = strip_tags($enreg["CONTENU"]); break; case 9: // rss $table="rss_flux"; @@ -390,7 +390,7 @@ class notice_integration $label="m3"; break; default: // Albums - if($type_doc>99) { + if($type_doc > 99) { $table = "album"; $colonne_clef = "id"; $colonne_id_notice = "notice_id"; @@ -405,7 +405,8 @@ class notice_integration $display_facettes = ['B' => function ($album) {return $album->getBibliotheques();}, 'Y' => function ($album) {return $album->getAnnexes();}, - 'S' => function ($album) {return $album->getSections();}]; + 'S' => function ($album) {return $album->getSections();}, + 'G' => function ($album) {return $album->getGenre();}]; foreach ($display_facettes as $k => $closure) { $values = explode(';', $closure($album)); @@ -422,8 +423,8 @@ class notice_integration $id_ressource=$enreg[$colonne_clef]; // Création notice - $enreg[$colonne_id_notice]=sqlInsert("notices",array("type_doc" => $type_doc)); - $code_barres=str_repeat("0",(4-strlen($enreg["id_bib"]))).$enreg["id_bib"]."-".$enreg[$colonne_id_notice]; + $enreg[$colonne_id_notice] = sqlInsert('notices', ['type_doc' => $type_doc]); + $code_barres = str_repeat("0", (4-strlen($enreg["id_bib"]))) . $enreg["id_bib"] . "-" . $enreg[$colonne_id_notice]; $sql->execute("insert into exemplaires(id_notice,id_bib,activite) Values(".$enreg[$colonne_id_notice].",".$enreg["id_bib"].",'A consulter sur le portail')"); $sql->execute("update ".$table." set ".$colonne_id_notice."=".$enreg[$colonne_id_notice]." where ".$colonne_clef."=".$enreg[$colonne_clef]); $ret["statut"]=1; diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php index d9eea63d309..1809137d94b 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php @@ -162,7 +162,7 @@ abstract class NoticeIntegrationSacramentariumTestCase extends NoticeIntegration 'fichier'=>'144_B031906101_MS_014_0033R.jpg', 'type_doc_id'=>'100', 'id_langue'=>'lat', - 'genre'=>'', + 'genre'=>'7;99', 'dewey'=>'', 'matiere'=>'62115', 'id_origine'=>'D09030160', @@ -252,6 +252,16 @@ class NoticeIntegrationSacramentariumParsingTest extends NoticeIntegrationSacram public function section23ShouldBeInFacettes() { $this->assertFacettesContains('S23'); } + + /** @test */ + public function genre7ShouldBeInFacettes() { + $this->assertFacettesContains('G7'); + } + + /** @test */ + public function genre99ShouldBeInFacettes() { + $this->assertFacettesContains('G99'); + } } diff --git a/library/Class/Album.php b/library/Class/Album.php index fa272774a20..7e752726caa 100644 --- a/library/Class/Album.php +++ b/library/Class/Album.php @@ -113,6 +113,7 @@ class Class_Album extends Storm_Model_Abstract { 'auteur' => '', 'description' => '', 'date_maj' => '', + 'genre' => '', 'matiere' => '', 'type_doc_id' => 0, 'annee' => '', diff --git a/tests/library/Class/AlbumTest.php b/tests/library/Class/AlbumTest.php index 3f9667e66a2..8c59e9b51eb 100644 --- a/tests/library/Class/AlbumTest.php +++ b/tests/library/Class/AlbumTest.php @@ -128,48 +128,23 @@ class AlbumHarlockBasicTest extends AlbumHarlockTestCase { } /** @test */ - function toArrayShouldContainsNativeAndThumbnailsAttributes() { - $this->assertEquals( - ['id' => 999, - 'titre' => 'Harlock', - 'type_doc_id' => 2, - 'fichier' => '', - 'date_maj' => '', - 'annee' => '', - 'description' => '', - 'id_langue' => 'fre', - 'id_origine' => '', - 'thumbnail_width' => 400, - 'thumbnail_left_page_crop_top' => 0, - 'thumbnail_left_page_crop_right' => 0, - 'thumbnail_left_page_crop_bottom' => 0, - 'thumbnail_left_page_crop_left' => 0, - 'thumbnail_right_page_crop_top' => 0, - 'thumbnail_right_page_crop_right' => 0, - 'thumbnail_right_page_crop_bottom' => 0, - 'thumbnail_right_page_crop_left' => 0, - 'thumbnail_crop_top' => 0, - 'thumbnail_crop_right' => 0, - 'thumbnail_crop_bottom' => 0, - 'thumbnail_crop_left' => 0, - 'display_one_page' => false, - 'cfg_thumbnails' => '', - 'sous_titre' => '', - 'pdf' => '', - 'auteur' => '', - 'matiere' => '', - 'provenance' => '', - 'cote' => '', - 'editeur' => '', - 'visible' => true, - 'droits' => '', - 'nature_doc' => '', - 'nature_doc_ids' => [], - 'cat_id' => 0, - 'bibliotheques' => '', - 'annexes' => '', - 'sections' => ''], - $this->_album->toArray()); + function toArrayShouldContainsThumbnailsAttributes() { + $properties = $this->_album->toArray(); + foreach (['thumbnail_width', + 'thumbnail_left_page_crop_top', + 'thumbnail_left_page_crop_right', + 'thumbnail_left_page_crop_bottom', + 'thumbnail_left_page_crop_left', + 'thumbnail_right_page_crop_top', + 'thumbnail_right_page_crop_right', + 'thumbnail_right_page_crop_bottom', + 'thumbnail_right_page_crop_left', + 'thumbnail_crop_top', + 'thumbnail_crop_right', + 'thumbnail_crop_bottom', + 'thumbnail_crop_left'] as $thumb_property) { + $this->assertTrue(array_key_exists($thumb_property, $properties)); + } } -- GitLab