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

Properly handle record w/o local record fields

* src/HAB/Pica/Record/TitleRecord.php (setFields): Properly handle
  record w/o local record fields.
parent 53f5b07d
No related branches found
Tags v1.0.1
No related merge requests found
...@@ -75,7 +75,13 @@ class TitleRecord extends NestedRecord ...@@ -75,7 +75,13 @@ class TitleRecord extends NestedRecord
$this->addLocalRecord($localRecord); $this->addLocalRecord($localRecord);
} else { } else {
$records = $this->getLocalRecords(); $records = $this->getLocalRecords();
$localRecord = end($records); // Handle malformed Pica record w/ missing local record field
if (empty($records)) {
$localRecord = new LocalRecord();
$this->addLocalRecord($localRecord);
} else {
$localRecord = end($records);
}
if ($level === 1) { if ($level === 1) {
$localRecord->append($field); $localRecord->append($field);
} else { } else {
......
...@@ -121,4 +121,14 @@ class TitleRecordTest extends PHPUnit_FrameWork_TestCase ...@@ -121,4 +121,14 @@ class TitleRecordTest extends PHPUnit_FrameWork_TestCase
$r->addLocalRecord($l); $r->addLocalRecord($l);
$this->assertTrue($r->containsLocalRecord($l)); $this->assertTrue($r->containsLocalRecord($l));
} }
public function testTitleRecordWithNoLocalRecordIndicator ()
{
$record = new TitleRecord();
$fields = array();
$fields []= new Field('003@', 0);
$fields []= new Field('200@', 0);
$record->setFields($fields);
$this->assertNotEmpty($record->getLocalRecords());
}
} }
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