From 9d0ceddc22cef4311fc127d958f69ffdc470a636 Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-loas.afi-sa.net>
Date: Mon, 2 Jun 2014 15:50:27 +0200
Subject: [PATCH] hotline #14019 adding enf_field char to directory string +
 test

---
 library/Class/NoticeUnimarc/Writer.php |  2 +-
 tests/library/Class/NoticeTest.php     | 23 ++++++++++++++++++-----
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/library/Class/NoticeUnimarc/Writer.php b/library/Class/NoticeUnimarc/Writer.php
index 8fa4fa9f018..7fb188c52c2 100644
--- a/library/Class/NoticeUnimarc/Writer.php
+++ b/library/Class/NoticeUnimarc/Writer.php
@@ -604,7 +604,7 @@ class Class_NoticeUnimarc_Writer extends Class_NoticeUnimarc {
 		.$pos23;
 		
 		// constitution du nouvel enregistrement
-		return $guide.$directory.$data;
+		return $guide.$directory.$this->field_end.$data;
 	}
 
 	public function ISO_encode($chaine) {
diff --git a/tests/library/Class/NoticeTest.php b/tests/library/Class/NoticeTest.php
index c86ea381e68..243464844d9 100644
--- a/tests/library/Class/NoticeTest.php
+++ b/tests/library/Class/NoticeTest.php
@@ -349,7 +349,7 @@ class NoticeGamTest extends NoticeThirdPartyTracksTestCase {
 
 
 class NoticeStromaeTest extends Storm_Test_ModelTestCase {
-	protected $_tracks;
+	protected $_tracks, $_output, $_temp_file, $_direcrectory_definition_length;
 
 	public function setUp() {
 		parent::setUp();
@@ -371,12 +371,19 @@ class NoticeStromaeTest extends Storm_Test_ModelTestCase {
 		$this->_tracks = $stromae->getMorceaux()['morceaux'];
 
 		$unimarc = Class_Exemplaire::find(234)->toUnimarcIso2709();
-		$temp_file = tempnam('/tmp', 'UNIMARC');
+		$this->_temp_file = tempnam('/tmp', 'UNIMARC');
 
-		file_put_contents($temp_file, $unimarc);
-		exec('yaz-marcdump ' . $temp_file, $output);
+		file_put_contents($this->_temp_file, $unimarc);
+		exec('yaz-marcdump ' . $this->_temp_file, $this->output);
 		
-		$this->_995s = $this->getFieldsFromMarcDump('995', $output);
+		$this->_995s = $this->getFieldsFromMarcDump('995', $this->output);
+		$this->_direcrectory_definition_length = 3 + 4  + 5;
+	}
+
+
+	/** @test */
+	public function directoryLenghShouldBeAmoduloOf12() {
+		$this->assertEquals(0 , $this->getDirectoryLength() % $this->_direcrectory_definition_length);
 	}
 
 
@@ -428,6 +435,12 @@ class NoticeStromaeTest extends Storm_Test_ModelTestCase {
 				return substr($part, strlen($field_name) + 1);
 		}
 	}
+
+	protected function getDirectoryLength() {
+		$directory_with_first_data = substr_replace(explode(' ', file_get_contents($this->_temp_file))[4], "", -2);
+		$directory = explode('', file_get_contents($this->_temp_file))[0];
+		return strlen($directory);
+	}
 }
 
 ?>
\ No newline at end of file
-- 
GitLab