From 2e0658fb5425aae612f34fa52852d23612a08a0c Mon Sep 17 00:00:00 2001
From: David Maus <maus@hab.de>
Date: Thu, 10 Jan 2013 16:19:52 +0100
Subject: [PATCH] Allow empty subfield values (031N)

---
 build.properties                              |  4 +--
 package.xml                                   | 30 +++++++++++++++++++
 src/php/HAB/Pica/Record/Subfield.php          | 16 +---------
 .../php/HAB/Pica/Record/SubfieldTest.php      | 19 ------------
 4 files changed, 33 insertions(+), 36 deletions(-)

diff --git a/build.properties b/build.properties
index e556c7b..7385fab 100644
--- a/build.properties
+++ b/build.properties
@@ -1,8 +1,8 @@
 project.name=PicaRecord
 project.channel=hab20.hab.de/service/pear
 project.majorVersion=0
-project.minorVersion=3
-project.patchLevel=1
+project.minorVersion=4
+project.patchLevel=0
 project.snapshot=false
 
 component.type=php-library
diff --git a/package.xml b/package.xml
index 07dba16..8e8d98e 100644
--- a/package.xml
+++ b/package.xml
@@ -56,6 +56,36 @@
   </dependencies>
   <phprelease />
   <changelog>
+    <release>
+      <version>
+	<release>0.4.0</release>
+	<api>0.4</api>
+      </version>
+      <stability>
+	<release>stable</release>
+	<api>stable</api>
+      </stability>
+      <date>2013-01-10</date>
+      <license>GNU General Public License v3</license>
+      <notes>
+	* allow empty subfield values (031N $6)
+      </notes>
+    </release>
+    <release>
+      <version>
+	<release>0.3.2</release>
+	<api>0.3</api>
+      </version>
+      <stability>
+	<release>stable</release>
+	<api>stable</api>
+      </stability>
+      <date>2013-01-10</date>
+      <license>GNU General Public License v3</license>
+      <notes>
+	* remove hard dependency to Autoloader
+      </notes>
+    </release>
     <release>
       <version>
 	<release>0.3.1</release>
diff --git a/src/php/HAB/Pica/Record/Subfield.php b/src/php/HAB/Pica/Record/Subfield.php
index 368f82c..1d2889e 100644
--- a/src/php/HAB/Pica/Record/Subfield.php
+++ b/src/php/HAB/Pica/Record/Subfield.php
@@ -48,16 +48,6 @@ class Subfield {
     return (bool)preg_match('/^[a-z0-9]$/Di', $arg);
   }
 
-  /**
-   * Return TRUE if argument is a valid subfield value.
-   *
-   * @param  mixed $arg Variable to check
-   * @return boolean TRUE if argument is a valid subfield value
-   */
-  public static function isValidSubfieldValue ($arg) {
-    return $arg != '';
-  }
-
   /**
    * Return a new subfield based on its array representation.
    *
@@ -97,7 +87,7 @@ class Subfield {
   /**
    * Constructor.
    *
-   * @throws \InvalidArgumentException Invalid subfield code or value
+   * @throws \InvalidArgumentException Invalid subfield code
    * @param  string $code Subfield code
    * @param  string $value Subfield value
    * @return void
@@ -113,14 +103,10 @@ class Subfield {
   /**
    * Set the subfield value.
    *
-   * @throws \InvalidArgumentException Invalid subfield value
    * @param  string $value Subfield value
    * @return void
    */
   public function setValue ($value) {
-    if (!self::isValidSubfieldValue($value)) {
-      throw new \InvalidArgumentException("Invalid subfield value: {$value}");
-    }
     $this->_value = $value;
   }
 
diff --git a/src/tests/unit-tests/php/HAB/Pica/Record/SubfieldTest.php b/src/tests/unit-tests/php/HAB/Pica/Record/SubfieldTest.php
index 65096ce..461eb09 100644
--- a/src/tests/unit-tests/php/HAB/Pica/Record/SubfieldTest.php
+++ b/src/tests/unit-tests/php/HAB/Pica/Record/SubfieldTest.php
@@ -36,10 +36,6 @@ class SubfieldTest extends \PHPUnit_FrameWork_TestCase {
     $this->assertFalse(Subfield::isValidSubfieldCode("a\n"));
   }
 
-  public function testValidSubfieldValueSingleSpace () {
-    $this->assertTrue(Subfield::isValidSubfieldValue(' '));
-  }
-
   public function testFactory () {
     $s = Subfield::factory(array('code' => 'a', 'value' => 'valid'));
     $this->assertInstanceOf('HAB\Pica\Record\Subfield', $s);
@@ -83,13 +79,6 @@ class SubfieldTest extends \PHPUnit_FrameWork_TestCase {
     new Subfield(null, 'valid');
   }
 
-  /**
-   * @expectedException \InvalidArgumentException
-   */
-  public function testConstructorThrowsExceptionOnInvalidValue () {
-    new Subfield('a', null);
-  }
-
   /**
    * @expectedException \InvalidArgumentException
    */
@@ -104,12 +93,4 @@ class SubfieldTest extends \PHPUnit_FrameWork_TestCase {
     Subfield::factory(array('code' => 'a'));
   }
 
-  /**
-   * @expectedException \InvalidArgumentException
-   */
-  public function testSetValueThrowsExceptionOnInvalidValue () {
-    $s = new Subfield('a', 'valid');
-    $s->setValue(null);
-  }
-
 }
\ No newline at end of file
-- 
GitLab