diff --git a/library/Class/Cosmogramme/Generator/AbstractTask.php b/library/Class/Cosmogramme/Generator/AbstractTask.php index 79fd9f58aa71a6645871b17f98ee04d5df0b33ec..1d7c57a8cfa5db3672cd14240df83e41400ec14d 100644 --- a/library/Class/Cosmogramme/Generator/AbstractTask.php +++ b/library/Class/Cosmogramme/Generator/AbstractTask.php @@ -82,8 +82,10 @@ abstract class Class_Cosmogramme_Generator_AbstractTask { protected function _extract($data) { - $data = utf8_encode($data); - return explode('|', $data); + return explode('|', + mb_detect_encoding($data, 'UTF-8', true) + ? $data + : utf8_encode($data)); } diff --git a/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php b/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php index 77df3e6b1277e16eefcb2b4ff06d76ad61cacb91..c6dac7b3f683e5732d165f280dff6457abfce45c 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php @@ -348,7 +348,9 @@ class PhasePrepareIntegrationsNanookStandardTest ->whenCalled('getLibrariesOf')->with('foo') ->answers(['BIB_SPS_UTT|ID_SITE|LIBELLE', - '2|My library']) + '2|Ma library', + '6|Ma bibliothèque', + '8|' . iconv('UTF-8', 'ISO-8859-1', 'Ma médiathèque')]) ->whenCalled('getSectionsOf')->with('foo') ->answers(['BIB_C_SECTION|CODE|LIBELLE', @@ -624,6 +626,18 @@ class PhasePrepareIntegrationsNanookStandardTest } + /** @test */ + public function libraryIdSixLabelShouldBeMaBibliothèque() { + $this->assertEquals('Ma bibliothèque', Class_Cosmogramme_Generator_FixedIdBib::find(6)->getLibelle()); + } + + + /** @test */ + public function libraryIdEigthLabelShouldBeMaMédiathèque() { + $this->assertEquals('Ma médiathèque', Class_Cosmogramme_Generator_FixedIdBib::find(8)->getLibelle()); + } + + /** @test */ public function plannedIntegrationsOfRemovedLibraryShouldBeDeleted() { $this->assertEmpty(Class_IntMajAuto::findAllBy(['id_bib' => 3]));