From 83f8c17398a051543a7c8b9fb4889b199c0feac4 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Tue, 14 Feb 2017 11:09:39 +0100 Subject: [PATCH] dev #50215 wip --- .../controllers/DataProfileControllerTest.php | 6 + .../Integration/Record/DublinCore.php | 1 + .../Cosmogramme/Integration/Bibliondemand.xml | 1 + .../RecordPhaseBibliondemandTest.php | 299 ++++++++++++++++++ 4 files changed, 307 insertions(+) create mode 100644 tests/library/Class/Cosmogramme/Integration/Bibliondemand.xml create mode 100644 tests/library/Class/Cosmogramme/Integration/RecordPhaseBibliondemandTest.php diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php index 7821df274d0..4fd85e564af 100644 --- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php @@ -216,6 +216,12 @@ class Cosmo_DataProfileControllerEditUnimarcKohaTest extends Cosmo_DataProfileCo } + /** @test */ + public function formatBibliondemandShouldBeAvailable() { + $this->assertXPathContentContains('//form//select[@name="format"]/option[@value="11"]', 'Dublin Core Bibliondemand'); + } + + /** @test */ public function fieldNouveauteJoursShouldBePresent() { $this->assertXPath('//form//input[@id="nouveaute_jours"]'); diff --git a/library/Class/Cosmogramme/Integration/Record/DublinCore.php b/library/Class/Cosmogramme/Integration/Record/DublinCore.php index da9b91a32c1..da643868c88 100644 --- a/library/Class/Cosmogramme/Integration/Record/DublinCore.php +++ b/library/Class/Cosmogramme/Integration/Record/DublinCore.php @@ -31,6 +31,7 @@ class Class_Cosmogramme_Integration_Record_DublinCore extends notice_unimarc { public function ouvrirNotice($data, $id_data_profile, $sigb, $type_doc_force) { + xdebug_break(); $this->_profil = Class_IntProfilDonnees::find($id_data_profile); $this->_types = $data['type']; $this->_formats = $data['format']; diff --git a/tests/library/Class/Cosmogramme/Integration/Bibliondemand.xml b/tests/library/Class/Cosmogramme/Integration/Bibliondemand.xml new file mode 100644 index 00000000000..ea75ba4df91 --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/Bibliondemand.xml @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd"><responseDate>2017-02-14T09:28:12Z</responseDate><request verb="ListRecords">oai.bibliondemand.com/oaiserver.ashx</request><ListRecords><record><header><identifier>CG62_5532b9e4e47a7d41fe81d125d3ba7863</identifier><datestamp>2016-12-23T08:42:33Z</datestamp></header><metadata><oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:identifier>Url : http://music.1dtouch.com/users/auth/assa?dest=albums/137962&bibid=CG62</dc:identifier><dc:identifier>Vignette : http://play-assets-production.1dtouch.com/cargo/medium_8017297007164.jpg</dc:identifier><dc:title>Piero Soffici Quartet</dc:title><dc:type>Document sonore</dc:type><dc:creator>Piero Soffici Quartet</dc:creator><dc:source>1DTOUCH</dc:source><dc:publisher /></oai_dc:dc></metadata></record><record><header><identifier>CG62_516fbc7cfe8fe5e7b6a3c5577b9894dc</identifier><datestamp>2016-12-23T08:42:33Z</datestamp></header><metadata><oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:identifier>Url : http://music.1dtouch.com/users/auth/assa?dest=albums/109814&bibid=CG62</dc:identifier><dc:identifier>Vignette : http://play-assets-production.1dtouch.com/cargo/medium_5051142090607.jpg</dc:identifier><dc:title>Island Row</dc:title><dc:type>Document sonore</dc:type><dc:creator>Capitol K</dc:creator><dc:source>1DTOUCH</dc:source><dc:publisher /></oai_dc:dc></metadata></record><record><header><identifier>CG62_0856eef7ca0440685bd51ac04d5258ab</identifier><datestamp>2016-12-23T08:42:33Z</datestamp></header><metadata><oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:identifier>Url : http://music.1dtouch.com/users/auth/assa?dest=albums/121552&bibid=CG62</dc:identifier><dc:identifier>Vignette : http://play-assets-production.1dtouch.com/cargo/medium_3614970852384.jpg</dc:identifier><dc:title>Tunos de Compostela</dc:title><dc:type>Document sonore</dc:type><dc:creator>Tunos De Compostela</dc:creator><dc:source>1DTOUCH</dc:source><dc:publisher /></oai_dc:dc></metadata></record><record><header><identifier>CG62_432ebd04ac7e70f70ecb65a34ad86a79</identifier><datestamp>2016-12-23T08:42:33Z</datestamp></header><metadata><oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:identifier>Url : http://music.1dtouch.com/users/auth/assa?dest=albums/20206&bibid=CG62</dc:identifier><dc:identifier>Vignette : http://play-assets-production.1dtouch.com/cargo/medium_3700738801098.jpg</dc:identifier><dc:title>Fantasy Classic, No. 1: Atmosphere Synthetic Harpsichord</dc:title><dc:type>Document sonore</dc:type><dc:creator>Christian Levitan</dc:creator><dc:source>1DTOUCH</dc:source><dc:publisher>LEVITAN</dc:publisher></oai_dc:dc></metadata></record><record><header><identifier>CG62_0925032</identifier><datestamp>2017-02-09T07:44:56Z</datestamp></header><metadata><oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:identifier>Url : http://media.citedelamusique.fr/medias/logon/62-pasdecalais-md?backUrl=http://media.citedelamusique.fr/medias/doc/EXTRANET/CIMU/0925032/DETAIL</dc:identifier><dc:identifier>Vignette : http://media.citedelamusique.fr/images/DocThumbs/CMVI000139300.jpg</dc:identifier><dc:title>We Want Miles. Birth of the Cool Suite</dc:title><dc:type>Document vidéo</dc:type><dc:creator>Joe Lovano</dc:creator><dc:creator>Ralph Lalama</dc:creator><dc:creator>Steve Slagle</dc:creator><dc:creator>Gary Smulyan</dc:creator><dc:creator>Larry Farrell</dc:creator><dc:creator>Barry Ries</dc:creator><dc:creator>James Weidman</dc:creator><dc:creator>Cameron Brown</dc:creator><dc:creator>Lewis Nash</dc:creator><dc:creator>Joe Lovano Nonet</dc:creator><dc:subject>Jazz</dc:subject><dc:source>CIMU</dc:source><dc:publisher>Cité de la musique</dc:publisher></oai_dc:dc></metadata></record><record><header><identifier>CG62_0980101</identifier><datestamp>2017-02-09T07:44:56Z</datestamp></header><metadata><oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:identifier>Url : http://media.citedelamusique.fr/medias/logon/62-pasdecalais-md?backUrl=http://media.citedelamusique.fr/medias/doc/EXTRANET/CIMU/0980101/DETAIL</dc:identifier><dc:identifier>Vignette : http://media.citedelamusique.fr/images/DocThumbs/CMVI000020202_02.jpg</dc:identifier><dc:title>Musiques pour harpes et pluriarc des Fang du Gabon</dc:title><dc:type>Document vidéo</dc:type><dc:subject>Musiques traditionnelles</dc:subject><dc:source>CIMU</dc:source><dc:publisher>Cité de la musique</dc:publisher></oai_dc:dc></metadata></record><record><header><identifier>CG62_0935471</identifier><datestamp>2017-02-09T07:44:56Z</datestamp></header><metadata><oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:identifier>Url : http://media.citedelamusique.fr/medias/logon/62-pasdecalais-md?backUrl=http://media.citedelamusique.fr/medias/doc/EXTRANET/CIMU/0935471/DETAIL</dc:identifier><dc:identifier>Vignette : http://media.citedelamusique.fr/images/DocThumbs/CMVI000144001_02.jpg</dc:identifier><dc:title>Salve Regina, cantate en la majeur pour mezzo-soprano et cordes</dc:title><dc:type>Document vidéo</dc:type><dc:creator>Johann Adolf Hasse</dc:creator><dc:creator>Bernarda Fink</dc:creator><dc:creator>Berliner Barock Solisten</dc:creator><dc:subject>Musique baroque</dc:subject><dc:source>CIMU</dc:source><dc:publisher>Cité de la musique</dc:publisher></oai_dc:dc></metadata></record><record><header><identifier>CG62_804</identifier><datestamp>2017-02-09T07:45:32Z</datestamp></header><metadata><oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:identifier>Url : http://www.mediatheque-numerique.com/films/situation-of-the-street</dc:identifier><dc:identifier>Vignette : http://media.universcine.com/34/3d/343d4726-7c56-11de-85a1-871b2e208cb2.jpg</dc:identifier><dc:title>Situation of the street</dc:title><dc:type>Document vidéo</dc:type><dc:creator>Gogola, Jan (Réalisateur)</dc:creator><dc:contributor>Holubová, Eva (Acteur)</dc:contributor><dc:contributor>Pollert, Lukáš (Acteur)</dc:contributor><dc:contributor>StivÃnová, Zuzana (Acteur)</dc:contributor><dc:contributor>Marek, Petr (Acteur)</dc:contributor><dc:contributor>Saudek, Jan (Acteur)</dc:contributor><dc:contributor>Sobota, LudÄ›k (Acteur)</dc:contributor><dc:contributor>KratochvÃlová, Jana (Acteur)</dc:contributor><dc:contributor>KrejÄÃk, Jiřà (Acteur)</dc:contributor><dc:contributor>DuÅ¡ek, Jaroslav (Acteur)</dc:contributor><dc:subject>Allégorie</dc:subject><dc:subject>Documentaire</dc:subject><dc:subject>Documentaire</dc:subject><dc:subject>Documentaire</dc:subject><dc:subject>Engagé</dc:subject><dc:subject>Etrange</dc:subject><dc:subject>Historique</dc:subject><dc:subject>Politique</dc:subject><dc:subject>Politique</dc:subject><dc:subject>Ville</dc:subject><dc:source>MEDIATHEQUE_NUMERIQUE</dc:source><dc:language>czech</dc:language><dc:description>A travers l'histoire de la célèbre rue Nationale (Národnà tÅ™Ãda), à Prague, un témoignage historique, radical et polémique, capté ici et maintenant, sur la nation Tchèque. Charlot et Hitler en témoins alors qu'une fille nue comme un fantôme fend la foule en courant... Un documentaire mariant une approche expérimentale et le questionnement politique du monde. Sous-titre du film : "La mer Tchèque prise dans 18 tsunamis"</dc:description></oai_dc:dc></metadata></record></ListRecords></OAI-PMH> \ No newline at end of file diff --git a/tests/library/Class/Cosmogramme/Integration/RecordPhaseBibliondemandTest.php b/tests/library/Class/Cosmogramme/Integration/RecordPhaseBibliondemandTest.php new file mode 100644 index 00000000000..f46af819ba1 --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/RecordPhaseBibliondemandTest.php @@ -0,0 +1,299 @@ +<?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 + */ + +require_once('cosmogramme/php/fonctions/variables.php'); +require_once(__DIR__.'/PhaseNoticeTestCase.php'); + +abstract class AbstractRecordPhaseBibliondemandTestCase extends PhaseNoticeTestCase { + protected $_storm_default_to_volatile = true; + + protected function _prepareFixtures() { + parent::_prepareFixtures(); + + Class_TypeDoc::newInstanceWithId(15, + ['label' => 'Film']); + + Class_TypeDoc::newInstanceWithId(16, + ['label' => 'Sonore']); + + $settings = ['format' => Class_IntProfilDonnees::FORMAT_BIBLIONDEMAND, + 'type_fichier' => Class_IntProfilDonnees::FT_RECORDS, + '0_type' => [''], + '0_format' => [''], + '15_type' => ['Document vidéo'], + '15_format' => [''], + '16_type' => ['Document sonore'], + '16_format' => [''],]; + + $serialized_settings = (new Class_ProfileSerializer($settings))->serializeDatas(); + + Class_IntProfilDonnees::find(102) + ->setTypeFichier(Class_IntProfilDonnees::FT_RECORDS) + ->setFormat(Class_IntProfilDonnees::FORMAT_BIBLIONDEMAND) + ->setAttributs($serialized_settings) + ->save(); + + $this->fixture('Class_IntBib', + ['id' => 3, + 'nom_court' => 'Bibliondemand']); + + Class_Cosmogramme_Integration::find(999) + ->setIdBib(3) + ->setFichier('http://oai.bibliondemand.com/oaiserver.ashx?verb=ListRecords&metadataPrefix=oai_dc&set=CG62') + ->save(); + + $xml = file_get_contents(__DIR__.'/Bibliondemand.xml'); + $webclient = $this->mock(); + $webclient->whenCalled('open_url') + ->with('http://oai.bibliondemand.com/oaiserver.ashx?verb=ListRecords&metadataPrefix=oai_dc&set=CG62') + ->answers($xml) + ->beStrict(); + + Class_WebService_OAI::setDefaultHttpClient($webclient); + } + + + public function tearDown() { + Class_WebService_OAI::setDefaultHttpClient(null); + parent::tearDown(); + } +} + + + +class RecordPhaseBibliondemandSimpleTest extends AbstractRecordPhaseBibliondemandTestCase { + /** @test */ + public function logShouldNotContainsError() { + $this->assertNotLogContains('Erreur'); + } + + + /** @test */ + public function totalNumberOfRecordsFromOAIShouldBeEight() { + $this->assertEquals(8, Class_Notice::count()); + } + + + /** + * @test + * @depends totalNumberOfRecordsFromOAIShouldBeNine + */ + public function firstRecordTitleShoudBeCittaFortezzeIisole() { + $this->assertContains('Citta, fortezze, isole', Class_Notice::find(1)->getTitrePrincipal()); + } + + + /** + * @test + * @depends totalNumberOfRecordsFromOAIShouldBeNine + */ + public function firstRecordAuthorShouldBeCoronelli() { + $this->assertEquals('Coronelli, Vincenzo Maria (1650-1718). Cartographe', + Class_Notice::find(1)->getAuteurPrincipal()); + } + + + /** + * @test + * @depends totalNumberOfRecordsFromOAIShouldBeNine + */ + public function firstRecordShouldHave5Notes() { + $this->assertCount(5, Class_Notice::find(1)->getNotes()); + } + + + /** + * @test + * @depends totalNumberOfRecordsFromOAIShouldBeNine + */ + public function firstRecordShouldHaveOneItem() { + $this->assertCount(1, Class_Notice::find(1)->getExemplaires()); + } + + + /** + * @test + * @depends totalNumberOfRecordsFromOAIShouldBeNine + */ + public function firstRecordDocTypeShouldBeShouldPlan() { + $this->assertEquals('plan', Class_Notice::find(1)->getTypeDocLabel()); + } + + + /** + * @test + * @depends totalNumberOfRecordsFromOAIShouldBeNine + */ + public function firstRecordItemBarcodeShouldBeAnMD5SumOfUrl() { + $item = Class_Notice::find(1)->getExemplaires()[0]; + $this->assertEquals('db0b7eded86da6efa8ee0c980b9d081a', $item->getCodeBarres()); + } + + + /** + * @test + * @depends totalNumberOfRecordsFromOAIShouldBeNine + */ + public function firstRecordItemLibraryShouldBeBNFGallicaAtlas() { + $item = Class_Notice::find(1)->getExemplaires()[0]; + $this->assertEquals('BNF Gallica Atlas', $item->getIntBib()->getNomCourt()); + } + + + /** + * @test + * @depends totalNumberOfRecordsFromOAIShouldBeNine + */ + public function lastRecordDocTypeShouldBeShouldAtlas() { + $this->assertEquals('atlas', Class_Notice::find(9)->getTypeDocLabel()); + } + + + /** + * @test + * @depends totalNumberOfRecordsFromOAIShouldBeNine + */ + public function firstRecordResumeShoudContainsEchellesDiverses() { + $this->assertContains('[Échelles diverses]', Class_Notice::find(1)->getResume()); + } + + + /** + * @test + * @depends totalNumberOfRecordsFromOAIShouldBeNine + */ + public function unimarcWithItemsShouldContainsDoctype() { + $item = Class_Notice::find(1)->getExemplaires()[0]; + $this->assertContains('s:1:"r";s:6:"valeur";s:74:"cartographic resource;document cartographique;image fixe;image;still image";', $item->getZone995()); + } + + + /** + * @test + * @depends totalNumberOfRecordsFromOAIShouldBeNine + */ + public function firstRecordItemUrlShouldBeGallicaArcOai() { + $item = Class_Notice::find(1)->getExemplaires()[0]; + $this->assertEquals('http://gallica.bnf.fr/ark:/12148/btv1b55006135m', $item->getUrl()); + } + + + /** + * @test + * @depends totalNumberOfRecordsFromOAIShouldBeNine + */ + public function recordWithAtlasPlanDoctypeShouldBePresent() { + $this->assertNotNull(Class_Notice::findFirstBy(['type_doc' => 25])); + } +} + + + + +class PhaseNoticeDublinCoreUpdateTest extends AbstractRecordPhaseBibliondemandTestCase { + public function _prepareFixtures() { + parent::_prepareFixtures(); + + Class_Cosmogramme_Integration::find(999) + ->beIncrementImport() + ->save(); + + $record = $this->fixture('Class_Notice', + ['id' => 1, + 'type_doc' => 15, + 'alpha_titre' => 'CITTA FORTEZZE ISOLE E PORTI PRINCIPALI DELL EUROPA IN PLANTA ET IN ELEVATIONE DESCRITTE E PUBLICATE AD USO DELL ACCADEMIA COSMOGRAFICA DEGLI ARGONAUTI DAL PADRE MAESTRO CORONELLI', + 'facettes' => 'T15', + 'clef_alpha' => 'CITTAFORTEZZEISOLEEPORTIPRINCIPALIDELLEUROPAINPLANTAETINELEVATIONEDESCRIT-----1689-15', + 'clef_oeuvre' => 'CITTAFORTEZZEISOLEEPORTIPRINCIPALIDELLEUROPAINPLANTAETINELEVATIONEDESCRIT---', + 'annee' => '1689', + 'unimarc' => '', + 'qualite' => 0, + 'exportable' => true, + 'date_maj' => '2016-04-25 14:39:58', + 'url_vignette' => 'http://gallica.bnf.fr/ark:/12148/btv1b55006135m.thumbnail', + 'url_image' => 'http://gallica.bnf.fr/ark:/12148/btv1b55006135m/f1.highres', + 'exemplaires' => [ + $this->fixture('Class_Exemplaire', + ['id' => 1, + 'activite' => 'peut être prêté', + 'zone995' => 'a:2:{i:0;a:2:{s:4:"code";s:1:"f";s:6:"valeur";s:32:"db0b7eded86da6efa8ee0c980b9d081a";}i:1;a:2:{s:4:"code";s:1:"r";s:6:"valeur";s:44:"document cartographique manuscrit;image fixe";}}', + 'code_barres' => 'db0b7eded86da6efa8ee0c980b9d081a', + 'id_bib' => 3, + 'id_int_bib' => 3]) + ]]); + } + + + public function setUp() { + parent::setUp(); + $this->_record = Class_Notice::find(1); + } + + + /** @test */ + public function recordShouldNotBeDeleted() { + $this->assertNotEmpty($this->_record); + } + + + /** @test */ + public function typeDocShouldStay15() { + $this->assertEquals(15, $this->_record->getTypeDoc()); + } + + + /** @test */ + public function recordShouldHaveOnlyOneItem() { + $this->assertEquals(1, count(Class_Exemplaire::findAllBy(['id_notice' => 1]))); + } +} + + + +class PhaseNoticeDublinCoreDedupeTest extends AbstractRecordPhaseBibliondemandTestCase { + protected function _prepareFixtures() { + parent::_prepareFixtures(); + + Class_CosmoVar::newInstanceWithId('mode_doublon', + ['valeur' => 1]); + + $xml = file_get_contents(__DIR__. '/dublinCoreDedup.xml'); + $webclient = $this->mock(); + $webclient->whenCalled('open_url') + ->with('http://oai.bnf.fr/oai2/OAIHandler?verb=ListRecords&metadataPrefix=oai_dc&set=gallica%3Atypedoc%3Acartes%3Aatlas') + ->answers($xml) + ->beStrict(); + + Class_WebService_OAI::setDefaultHttpClient($webclient); + } + + + /** @test */ + public function logShouldNotContainsError() { + $this->assertNotLogContains('Erreur'); + } + + + /** @test */ + public function twoRecordsShouldBeInDB() { + $this->assertCount(2, Class_Notice::findAll()); + } +} \ No newline at end of file -- GitLab