Skip to content
Snippets Groups Projects
Commit 2e0658fb authored by David Maus's avatar David Maus
Browse files

Allow empty subfield values (031N)

parent c0504b7d
No related branches found
No related tags found
No related merge requests found
project.name=PicaRecord project.name=PicaRecord
project.channel=hab20.hab.de/service/pear project.channel=hab20.hab.de/service/pear
project.majorVersion=0 project.majorVersion=0
project.minorVersion=3 project.minorVersion=4
project.patchLevel=1 project.patchLevel=0
project.snapshot=false project.snapshot=false
component.type=php-library component.type=php-library
......
...@@ -56,6 +56,36 @@ ...@@ -56,6 +56,36 @@
</dependencies> </dependencies>
<phprelease /> <phprelease />
<changelog> <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> <release>
<version> <version>
<release>0.3.1</release> <release>0.3.1</release>
......
...@@ -48,16 +48,6 @@ class Subfield { ...@@ -48,16 +48,6 @@ class Subfield {
return (bool)preg_match('/^[a-z0-9]$/Di', $arg); 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. * Return a new subfield based on its array representation.
* *
...@@ -97,7 +87,7 @@ class Subfield { ...@@ -97,7 +87,7 @@ class Subfield {
/** /**
* Constructor. * Constructor.
* *
* @throws \InvalidArgumentException Invalid subfield code or value * @throws \InvalidArgumentException Invalid subfield code
* @param string $code Subfield code * @param string $code Subfield code
* @param string $value Subfield value * @param string $value Subfield value
* @return void * @return void
...@@ -113,14 +103,10 @@ class Subfield { ...@@ -113,14 +103,10 @@ class Subfield {
/** /**
* Set the subfield value. * Set the subfield value.
* *
* @throws \InvalidArgumentException Invalid subfield value
* @param string $value Subfield value * @param string $value Subfield value
* @return void * @return void
*/ */
public function setValue ($value) { public function setValue ($value) {
if (!self::isValidSubfieldValue($value)) {
throw new \InvalidArgumentException("Invalid subfield value: {$value}");
}
$this->_value = $value; $this->_value = $value;
} }
......
...@@ -36,10 +36,6 @@ class SubfieldTest extends \PHPUnit_FrameWork_TestCase { ...@@ -36,10 +36,6 @@ class SubfieldTest extends \PHPUnit_FrameWork_TestCase {
$this->assertFalse(Subfield::isValidSubfieldCode("a\n")); $this->assertFalse(Subfield::isValidSubfieldCode("a\n"));
} }
public function testValidSubfieldValueSingleSpace () {
$this->assertTrue(Subfield::isValidSubfieldValue(' '));
}
public function testFactory () { public function testFactory () {
$s = Subfield::factory(array('code' => 'a', 'value' => 'valid')); $s = Subfield::factory(array('code' => 'a', 'value' => 'valid'));
$this->assertInstanceOf('HAB\Pica\Record\Subfield', $s); $this->assertInstanceOf('HAB\Pica\Record\Subfield', $s);
...@@ -83,13 +79,6 @@ class SubfieldTest extends \PHPUnit_FrameWork_TestCase { ...@@ -83,13 +79,6 @@ class SubfieldTest extends \PHPUnit_FrameWork_TestCase {
new Subfield(null, 'valid'); new Subfield(null, 'valid');
} }
/**
* @expectedException \InvalidArgumentException
*/
public function testConstructorThrowsExceptionOnInvalidValue () {
new Subfield('a', null);
}
/** /**
* @expectedException \InvalidArgumentException * @expectedException \InvalidArgumentException
*/ */
...@@ -104,12 +93,4 @@ class SubfieldTest extends \PHPUnit_FrameWork_TestCase { ...@@ -104,12 +93,4 @@ class SubfieldTest extends \PHPUnit_FrameWork_TestCase {
Subfield::factory(array('code' => 'a')); Subfield::factory(array('code' => 'a'));
} }
/**
* @expectedException \InvalidArgumentException
*/
public function testSetValueThrowsExceptionOnInvalidValue () {
$s = new Subfield('a', 'valid');
$s->setValue(null);
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment