From 01e02d6cf4f83b670881a606682f55ef8ad1dd06 Mon Sep 17 00:00:00 2001
From: pbarroca <pbarroca@afi-sa.fr>
Date: Tue, 21 Oct 2014 17:35:54 +0200
Subject: [PATCH] fix #15989 : locations field is case sensitive as all other
 item fields

---
 cosmogramme/php/classes/classe_unimarc.php    |   2 +-
 .../php/classes/NoticeIntegrationTest.php     |  46 +++++++
 library/Class/IntProfilDonnees.php            | 113 +++++++++++-------
 3 files changed, 119 insertions(+), 42 deletions(-)

diff --git a/cosmogramme/php/classes/classe_unimarc.php b/cosmogramme/php/classes/classe_unimarc.php
index ef5a20530f8..020c9cb3f7a 100644
--- a/cosmogramme/php/classes/classe_unimarc.php
+++ b/cosmogramme/php/classes/classe_unimarc.php
@@ -366,7 +366,7 @@ class notice_unimarc extends iso2709_record {
 							$ex['ignore_exemplaire'] = true;
 					}
 
-					if ($champ_emplacement and strtolower($champ['code']) == $champ_emplacement) {
+					if ($champ_emplacement and $champ['code'] == $champ_emplacement) {
 						$ex['emplacement'] = $this->getIdCodeExemplaire('emplacement', '995', $champ_emplacement, $champ['valeur']);
 
 						if (trim($ex['emplacement'])
diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php
index 6da4db60441..7a8071c8d7f 100644
--- a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php
+++ b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php
@@ -1821,4 +1821,50 @@ class NoticeIntegration11septembre2001Test extends NoticeIntegrationTestCase {
 		$notice = Class_Notice::find(1);
 		$this->assertEquals(21, $notice->getTypeDoc());
 	}
+}
+
+
+
+/** @see http://forge.afi-sa.fr/issues/15989 */
+class NoticeIntegrationMarioCartWiiTest extends NoticeIntegrationTestCase {
+	public function getProfilDonnees() {
+		$profil = Class_IntProfilDonnees::forAstrolab()->setIdProfil(110);
+		return $profil->getRawAttributes();
+	}
+
+
+	public function setUp() {
+		parent::setUp();
+		$this->fixture('Class_CodifEmplacement',
+									 ['id' => 3, 'libelle' => 'Art', 'regles' => '995$u=ART']);
+		$this->fixture('Class_CodifEmplacement',
+									 ['id' => 8, 'libelle' => 'Enfance', 'regles' => '995$u=ENF']);
+
+		$this->loadNotice('unimarc_mario_kart');
+		$this->items = Class_Notice::findFirstBy([])->getExemplaires();
+	}
+
+
+	/** @test */
+	public function firstItemLocationShouldBeSet() {
+		$this->assertItemLocation($this->items[0], 3);
+	}
+
+
+	/** @test */
+	public function secondItemLocationShouldBeSet() {
+		$this->assertItemLocation($this->items[1], 8);
+	}
+
+
+	/** @test */
+	public function thirdItemLocationShouldBeSet() {
+		$this->assertItemLocation($this->items[2], 3);
+	}
+
+
+	protected function assertItemLocation($item, $location) {
+		$this->assertEquals($location, $item->getEmplacement(),
+												json_encode($item->getRawAttributes()));
+	}
 }
\ No newline at end of file
diff --git a/library/Class/IntProfilDonnees.php b/library/Class/IntProfilDonnees.php
index 7c2d4de4004..f93040ba033 100644
--- a/library/Class/IntProfilDonnees.php
+++ b/library/Class/IntProfilDonnees.php
@@ -95,49 +95,98 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract {
 
 
 	public static function forALOES() {
-		return self::newInstance(
-														 ['libelle' => 'Unimarc Aloes',
+		$type_doc = [['code' => '0', 'label' => '', 'zone_995' => ''],
+								 ['code' => '1', 'label' => 'am;na', 'zone_995' => 'LIV;MS;az'],
+								 ['code' => '2', 'label' => 'as', 'zone_995' => 'PER;uu'],
+								 ['code' => '3', 'label' => 'i;j', 'zone_995' => 'CD;LIVCD;LIVK7;K7'],
+								 ['code' => '4', 'label' => 'g','zone_995' => 'DIAPO;DVD;VHS;VHD;VD;ge'],
+								 ['code' => '5', 'label' => 'l;m', 'zone_995' => 'CDR;le'],
+								 ['code' => '6', 'label' => '', 'zone_995' => 'LCD'],
+								 ['code' => '7', 'label' => '', 'zone_995' => 'CAR'],
+								 ['code' => '8', 'label' => '', 'zone_995' => 'PAD'],
+								 ['code' => '9', 'label' => '', 'zone_995' => 'WEB;MF'],
+								 ['code' => '10', 'label' => '', 'zone_995' => 'BRD'],
+								 ['code' => '11', 'label' => '', 'zone_995' => 'PAR']];
+
+		return self::newInstance(['libelle' => 'Unimarc Aloes',
 															'accents' => self::ENCODING_ISO2709,
 															'rejet_periodiques' =>  '1',
 															'id_article_periodique' => self::SERIAL_FORMAT_ALOES_INDEXPRESS,
 															'type_fichier' => self::FT_RECORDS,
 															'format' => self::FORMAT_UNIMARC,
 															'attributs' => [
-																							['type_doc' =>  [
-																															 [ 'code' => '0', 'label' => '', 'zone_995' => '' ],
-																															 [ 'code' => '1', 'label' => 'am;na', 'zone_995' => 'LIV;MS;az' ],
-																															 [ 'code' => '2', 'label' => 'as', 'zone_995' => 'PER;uu'],
-																															 [ 'code' => '3', 'label' => 'i;j', 'zone_995' => 'CD;LIVCD;LIVK7;K7'],
-																															 [ 'code' => '4', 'label' => 'g','zone_995' => 'DIAPO;DVD;VHS;VHD;VD;ge'],
-																															 [ 'code' => '5', 'label' => 'l;m', 'zone_995' => 'CDR;le'],
-																															 [ 'code' => '6', 'label' => '', 'zone_995' => 'LCD' ],
-																															 [ 'code' => '7', 'label' => '', 'zone_995' => 'CAR' ],
-																															 [ 'code' => '8', 'label' => '', 'zone_995' => 'PAD'],
-																															 [ 'code' => '9', 'label' => '', 'zone_995' => 'WEB;MF'],
-																															 [ 'code' => '10', 'label' => '', 'zone_995' => 'BRD'],
-																															 [ 'code' => '11', 'label' => '', 'zone_995' => 'PAR']
-																								],
+																							['type_doc' => $type_doc,
 																							 'champ_code_barres' => 'f',
 																							 'champ_cote' => 'k',
 																							 'champ_type_doc' => '',
 																							 'champ_genre' => '',
 																							 'champ_section' => 'q',
 																							 'champ_emplacement' => 'l',
-																							 'champ_annexe' => 'b'
-																							],
+																							 'champ_annexe' => 'b'],
 																							['zone' => '995',
 																							 'champ' => 'v',
 																							 'format' => self::NOVELTY_DATE_FORMAT_VALUES,
 																							 'jours' => '',
-																							 'valeurs' => 'nouveaute']
-															]
-														 ]
-		);
+																							 'valeurs' => 'nouveaute']]]);
 	}
 
 
+	public static function forAstrolab() {
+		$type_doc = [['code' => '0', 'label' => '', 'zone_995' => ''],
+								 ['code' => '1', 'label' => 'am', 'zone_995' => 'LIV;MS'],
+								 ['code' => '2', 'label' => 'as', 'zone_995' => 'PER'],
+								 ['code' => '3', 'label' => 'i;j;jm;im', 'zone_995' => 'CD;LIVCD;LIVK7;K7;CDL'],
+								 ['code' => '4', 'label' => 'g','zone_995' => 'DIAPO;DVD;VHS;VHD;VD;BRD'],
+								 ['code' => '5', 'label' => 'l;m;', 'zone_995' => 'CDR;'],
+								 ['code' => '6', 'label' => 'c;d', 'zone_995' => 'PAR' ],
+								 ['code' => '7', 'label' => 'f;k;em', 'zone_995' => 'PHOTO;EST;EKTA;CPL;CP' ],
+								 ['code' => '8', 'label' => 'aa', 'zone_995' => 'DOS'],
+								 ['code' => '11', 'label' => '', 'zone_995' => 'WEB'],
+								 ['code' => '12', 'label' => '', 'zone_995' => 'JV'],
+								 ['code' => '13', 'label' => '', 'zone_995' => 'MM']];
+
+		return self::newInstance(['libelle' => 'Unimarc Aloes',
+															'accents' => self::ENCODING_ISO2709,
+															'rejet_periodiques' =>  '1',
+															'id_article_periodique' => self::SERIAL_FORMAT_ALOES_INDEXPRESS,
+															'type_fichier' => self::FT_RECORDS,
+															'format' => self::FORMAT_UNIMARC,
+															'attributs' => [
+																							['type_doc' => $type_doc,
+																							 'champ_code_barres' => 'f',
+																							 'champ_cote' => 'k',
+																							 'champ_type_doc' => 'r',
+																							 'champ_genre' => '',
+																							 'champ_section' => 'q',
+																							 'champ_emplacement' => 'u',
+																							 'champ_annexe' => 'a'],
+																							['zone' => '922',
+																							 'champ' => 'c',
+																							 'format' => self::NOVELTY_DATE_FORMAT_SLASHED_JMAAAA,
+																							 'jours' => '',
+																							 'valeurs' => '']]]);
+	}
+
 
 	public static function forKoha() {
+		$type_doc = [['code' => '0',  'label' => '',       'zone_995' => 'IND' ],
+								 ['code' => '1',  'label' => 'am;na',  'zone_995' => 'LIV;LIVJ;LIVA;DOC;MANUEL' ],
+								 ['code' => '2',  'label' => 'as',     'zone_995' => 'REV;REVA;REVJ;'],
+								 ['code' => '3',  'label' => 'i;j',    'zone_995' => 'CD'],
+								 ['code' => '4',  'label' => 'g',      'zone_995' => 'DVD;JDVD;DVDA;DVDJ;VID'],
+								 ['code' => '5',  'label' => 'l;m',    'zone_995' => 'CDROM;CDR'],
+								 ['code' => '6',  'label' => '',       'zone_995' => 'LCD' ],
+								 ['code' => '7',  'label' => '',       'zone_995' => 'PAR;JPAR;' ],
+								 ['code' => '8',  'label' => '',       'zone_995' => ''],
+								 ['code' => '9',  'label' => '',       'zone_995' => ''],
+								 ['code' => '10', 'label' => ' ',      'zone_995' => ''],
+								 ['code' => '11', 'label' => '',       'zone_995' => 'JVID'],
+								 ['code' => '12', 'label' => '',       'zone_995' => 'MAT'],
+								 ['code' => '13', 'label' => 'km',     'zone_995' => 'EST'],
+								 ['code' => '14', 'label' => '',       'zone_995' => 'TLU'],
+								 ['code' => '15', 'label' => '',       'zone_995' => 'CAR'],
+								 ['code' => '16', 'label' => '',       'zone_995' => 'DIS']];
+
 		return self::newInstance(
 														 ['libelle' => 'Unimarc Koha',
 															'accents' => self::ENCODING_UTF8,
@@ -146,25 +195,7 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract {
 															'type_fichier' => self::FT_RECORDS,
 															'format' => self::FORMAT_UNIMARC,
 															'attributs' => [
-																							['type_doc' =>  [
-																															 [ 'code' => '0',  'label' => '',       'zone_995' => 'IND' ],
-																															 [ 'code' => '1',  'label' => 'am;na',  'zone_995' => 'LIV;LIVJ;LIVA;DOC;MANUEL' ],
-																															 [ 'code' => '2',  'label' => 'as',     'zone_995' => 'REV;REVA;REVJ;'],
-																															 [ 'code' => '3',  'label' => 'i;j',    'zone_995' => 'CD'],
-																															 [ 'code' => '4',  'label' => 'g',      'zone_995' => 'DVD;JDVD;DVDA;DVDJ;VID'],
-																															 [ 'code' => '5',  'label' => 'l;m',    'zone_995' => 'CDROM;CDR'],
-																															 [ 'code' => '6',  'label' => '',       'zone_995' => 'LCD' ],
-																															 [ 'code' => '7',  'label' => '',       'zone_995' => 'PAR;JPAR;' ],
-																															 [ 'code' => '8',  'label' => '',       'zone_995' => ''],
-																															 [ 'code' => '9',  'label' => '',       'zone_995' => ''],
-																															 [ 'code' => '10', 'label' => ' ',      'zone_995' => ''],
-																															 [ 'code' => '11', 'label' => '',       'zone_995' => 'JVID'],
-																															 [ 'code' => '12', 'label' => '',       'zone_995' => 'MAT'],
-																															 [ 'code' => '13', 'label' => 'km',     'zone_995' => 'EST'],
-																															 [ 'code' => '14', 'label' => '',       'zone_995' => 'TLU'],
-																															 [ 'code' => '15', 'label' => '',       'zone_995' => 'CAR'],
-																															 [ 'code' => '16', 'label' => '',       'zone_995' => 'DIS']
-																								],
+																							['type_doc' => $type_doc,
 																							 'champ_code_barres' => 'f',
 																							 'champ_cote' => 'k',
 																							 'champ_type_doc' => 'r',
-- 
GitLab