Commit 08a39731 authored by David Maus's avatar David Maus
Browse files

New functions: Check if concrete nested records contain a record

* php/HAB/Pica/Record/LocalRecord.php (containsCopyRecord): New
function. Return true if local record contains a copy record.
* php/HAB/Pica/Record/TitleRecord.php (containsLocalRecord): New
function. Return true if title record contains a local record.
parent 1013b819
......@@ -121,6 +121,16 @@ class LocalRecord extends NestedRecord {
return null;
}
/**
* Return true if local record contains the copy record.
*
* @param \HAB\Pica\Record\CopyRecord $record Copy record
* @return boolean
*/
public function containsCopyRecord (\HAB\Pica\Record\CopyRecord $record) {
return $this->containsRecord($record);
}
/**
* Compare two copy records.
*
......
......@@ -178,6 +178,16 @@ class TitleRecord extends NestedRecord {
}
}
/**
* Return true if title record contains the local record.
*
* @param \HAB\Pica\Record\LocalRecord $record Local record
* @return boolean
*/
public function containsLocalRecord (\HAB\Pica\Record\LocalRecord $record) {
return $this->containsRecord($record);
}
/**
* Compare two local records.
*
......@@ -192,4 +202,5 @@ class TitleRecord extends NestedRecord {
protected function compareRecords (\HAB\Pica\Record\Record $a, \HAB\Pica\Record\Record $b) {
return $a->getILN() - $b->getILN();
}
}
\ No newline at end of file
......@@ -103,6 +103,14 @@ class LocalRecordTest extends \PHPUnit_FrameWork_TestCase {
$this->assertEquals(10, $r->getMaximumOccurrenceOf('144Z'));
}
public function testContainsCopyRecord () {
$r = new LocalRecord();
$c = new CopyRecord();
$this->assertFalse($r->containsCopyRecord($c));
$r->addCopyRecord($c);
$this->assertTrue($r->containsCopyRecord($c));
}
///
/**
......
......@@ -101,4 +101,12 @@ class TitleRecordTest extends \PHPUnit_FrameWork_TestCase {
$r->setPPN('something else');
$this->assertEquals('something else', $r->getPPN());
}
public function testContainsLocalRecord () {
$r = new TitleRecord();
$l = new LocalRecord();
$this->assertFalse($r->containsLocalRecord($l));
$r->addLocalRecord($l);
$this->assertTrue($r->containsLocalRecord($l));
}
}
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