From 1fde3efc116315bc01fa823e9db4fd258de43379 Mon Sep 17 00:00:00 2001 From: Patrick Barroca <pbarroca@afi-sa.fr> Date: Tue, 20 Nov 2018 15:47:22 +0100 Subject: [PATCH] hotline #82087 : fix encoding detection of kinds in standards --- VERSIONS_HOTLINE/82087 | 1 + .../Class/Cosmogramme/Generator/KindsTask.php | 3 +-- .../PhasePrepareIntegrationsTest.php | 25 +++++++++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 VERSIONS_HOTLINE/82087 diff --git a/VERSIONS_HOTLINE/82087 b/VERSIONS_HOTLINE/82087 new file mode 100644 index 00000000000..158a9069514 --- /dev/null +++ b/VERSIONS_HOTLINE/82087 @@ -0,0 +1 @@ + - ticket #82087 : Cosmogramme : Meilleure prise en charge de l'encodage de cararcères de l'étalon Nanook \ No newline at end of file diff --git a/library/Class/Cosmogramme/Generator/KindsTask.php b/library/Class/Cosmogramme/Generator/KindsTask.php index 416ddd21d3d..7e7790a9c19 100644 --- a/library/Class/Cosmogramme/Generator/KindsTask.php +++ b/library/Class/Cosmogramme/Generator/KindsTask.php @@ -37,8 +37,7 @@ class Class_Cosmogramme_Generator_KindsTask extends Class_Cosmogramme_Generator_ protected function _prepareOne($data) { - $data = utf8_encode($data); - $elems = explode('|', $data); + $elems = $this->_extract($data); if ('BIB_' == substr($elems[0], 0, 4) || !trim($elems[1])) return ''; diff --git a/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php b/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php index c6192da2af5..bd09b098b83 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php @@ -394,7 +394,8 @@ class PhasePrepareIntegrationsNanookStandardTest ->whenCalled('getKindsOf')->with('foo') ->answers(['BIB_GENRES|SUPPORT|CODE|LIBELLE|DOC', - '0|1|Music|f']) + '0|1|Music|f', + '0|2|Bande dessinée|f']) ->beStrict(); @@ -462,7 +463,7 @@ class PhasePrepareIntegrationsNanookStandardTest ->with('delete from ' . $table . ' where date_maj != "' . $now->dateYmd() . '"') ->willDo(function() use ($model_class, $now) { - $model_class::deleteBy(['date_maj not' => $now->dateDayAndHours()]); + $model_class::deleteBy(['date_maj not' => $now->dateYmd()]); }) ->whenCalled('query') @@ -670,6 +671,26 @@ class PhasePrepareIntegrationsNanookStandardTest } + /** @test */ + public function kindsCountShouldBe2() { + $this->assertEquals(2, Class_CodifGenre::count()); + } + + + /** @test */ + public function firstKindLabelShouldBeMusic() { + $this->assertNotNull($kind = Class_CodifGenre::findFirstBy(['regles' => '995$7=1'])); + $this->assertEquals('Music', $kind->getLibelle()); + } + + + /** @test */ + public function secondKindLabelShouldBeBandeDessinée() { + $this->assertNotNull($kind = Class_CodifGenre::findFirstBy(['regles' => '995$7=2'])); + $this->assertEquals('Bande dessinée', $kind->getLibelle()); + } + + /** @test */ public function plannedIntegrationsOfRemovedLibraryShouldBeDeleted() { $this->assertEmpty(Class_IntMajAuto::findAllBy(['id_bib' => 3])); -- GitLab