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
......@@ -75,7 +75,13 @@ class TitleRecord extends NestedRecord
$this->addLocalRecord($localRecord);
} else {
$records = $this->getLocalRecords();
// 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) {
$localRecord->append($field);
} else {
......
......@@ -121,4 +121,14 @@ class TitleRecordTest extends PHPUnit_FrameWork_TestCase
$r->addLocalRecord($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());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment