Skip to content

Commit 5964342

Browse files
rudolfbykerdanmichaelo
authored andcommitted
Add explicit tests for getRecord and getField.
1 parent 0cda813 commit 5964342

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/FieldsTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Tests;
44

5+
use File_MARC_Field;
6+
use Scriptotek\Marc\Fields\Field;
57
use Scriptotek\Marc\Record;
68

79
class IsbnFieldTest extends TestCase
@@ -107,4 +109,17 @@ public function testAsLineMarc()
107109
$field->delete();
108110
$this->assertNull($field->asLineMarc());
109111
}
112+
113+
/**
114+
* Test the getField method.
115+
*/
116+
public function testGetField()
117+
{
118+
$wrapped_field = new File_MARC_Field('020', '$q h. $c Nkr 98.00');
119+
$wrapper = new Field($wrapped_field);
120+
121+
// Make sure that the exact same wrapped field object is returned
122+
// by the getter.
123+
$this->assertSame($wrapped_field, $wrapper->getField());
124+
}
110125
}

tests/RecordTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Tests;
44

5+
use File_MARC;
6+
use File_MARC_Record;
57
use Scriptotek\Marc\AuthorityRecord;
68
use Scriptotek\Marc\BibliographicRecord;
79
use Scriptotek\Marc\Fields\Field;
@@ -101,4 +103,23 @@ public function testRecordTypeDescriptiveCatalogingForm()
101103
$record = Record::fromString($source);
102104
$this->assertEquals(Marc21::ISBD_PUNCTUATION_OMITTED, $record->catalogingForm);
103105
}
106+
107+
/**
108+
* Test the getRecord method.
109+
*
110+
* @throws \File_MARC_Exception
111+
*/
112+
public function testGetRecord()
113+
{
114+
$source = '<?xml version="1.0" encoding="UTF-8" ?>
115+
<record>
116+
<leader>99999cam a2299999 c 4500</leader>
117+
</record>';
118+
$wrapped_record = new File_MARC_Record(new File_MARC($source, File_MARC::SOURCE_STRING));
119+
$wrapper = new Record($wrapped_record);
120+
121+
// Make sure that the exact same wrapped record object is returned
122+
// by the getter.
123+
$this->assertSame($wrapped_record, $wrapper->getRecord());
124+
}
104125
}

0 commit comments

Comments
 (0)