diff --git a/VERSIONS_HOTLINE/86991 b/VERSIONS_HOTLINE/86991 new file mode 100644 index 0000000000000000000000000000000000000000..1a62c8d04a84ac9ebc8e7e874351273e830de5a3 --- /dev/null +++ b/VERSIONS_HOTLINE/86991 @@ -0,0 +1 @@ + - ticket #86991 : Integration cosmogramme : correction de l'import OAI-PMH en HTTPS \ No newline at end of file diff --git a/library/Class/Cosmogramme/Integration.php b/library/Class/Cosmogramme/Integration.php index aa763e6c208b06a48100a4bfbe652b58cea3bd2d..bffe00258e3c1327becdb2b0291fb9559917ec52 100644 --- a/library/Class/Cosmogramme/Integration.php +++ b/library/Class/Cosmogramme/Integration.php @@ -79,7 +79,7 @@ class Class_Cosmogramme_Integration extends Storm_Model_Abstract { public function isSourceHTTP() { - return (false !== strpos($this->getFichier(), 'http://')); + return preg_match('"^http[s]?://"', $this->getFichier()); } diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeDublinCoreTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeDublinCoreTest.php index f9d3106b56ee894528a88f41127b1e9dda47c68c..cc1885ee152432163caacfea9de95e02631472da 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeDublinCoreTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeDublinCoreTest.php @@ -309,4 +309,57 @@ class PhaseNoticeDublinCoreDedupeTest extends AbstractPhaseNoticeDublinCoreTestC public function twoRecordsShouldBeInDB() { $this->assertCount(2, Class_Notice::findAll()); } +} + + +class phaseNoticeDublinCoreHttpsTestCase extends PhaseNoticeTestCase { + + protected function _prepareFixtures() { + parent::_prepareFixtures(); + + $settings = ['format' => Class_IntProfilDonnees::FORMAT_DUBLIN_CORE, + 'type_fichier' => Class_IntProfilDonnees::FT_RECORDS, + '0_type' => [''], + '0_format' => [''], + '15_type' => ['document cartographique'], + '15_format' => ['image/jpeg', + 'image/png'], + '16_type' => ['atlas', + 'carte postale', + 'carte'], + '16_format' => ['image/jpeg', + 'image/png'], + '25_type' => ['atlas'], + '25_format' => ['plan']]; + + $serialized_settings = (new Class_ProfileSerializer($settings))->serializeDatas(); + + Class_IntProfilDonnees::find(102) + ->setTypeFichier(Class_IntProfilDonnees::FT_RECORDS) + ->setFormat(Class_IntProfilDonnees::FORMAT_DUBLIN_CORE) + ->setAttributs($serialized_settings) + ->save(); + + $this->fixture('Class_IntBib', + ['id' => 3, + 'nom_court' => 'BNF Gallica Atlas']); + + Class_Cosmogramme_Integration::find(999) + ->setIdBib(3) + ->setFichier('https://www.lempreinte.valenceromansagglo.fr/oai/oai2.php?verb=ListRecords&metadataPrefix=oai_dc') + ->save(); + + $webclient = $this->mock(); + $webclient->whenCalled('open_url') + ->with('https://www.lempreinte.valenceromansagglo.fr/oai/oai2.php?verb=ListRecords&metadataPrefix=oai_dc') + ->answers(null)->beStrict(); + + Class_WebService_OAI::setDefaultHttpClient($webclient); + } + + + /** @test */ + public function methodOpenUrlShouldHaveBeenCalledWithHttpsLEmpreinte() { + $this->assertTrue(Class_WebService_OAI::getHttpClient()->methodHasBeenCalledWithParams('open_url',['https://www.lempreinte.valenceromansagglo.fr/oai/oai2.php?verb=ListRecords&metadataPrefix=oai_dc'])); + } } \ No newline at end of file