Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for getting repeated subfields of a repeated field #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/File_MARC_Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ private function interpreteSpec()
if ($this->field instanceof File_MARC_Data_Field) {
foreach ($this->spec['subfields'] as $currentSubfieldSpec) {
if ($_subfields = $this->referenceSubfields($currentSubfieldSpec)) {
$currentSubfieldSpec = clone $currentSubfieldSpec;
foreach ($_subfields as $subfieldIndex => $subfield) {
$currentSubfieldSpec->setIndexStartEnd($subfieldIndex, $subfieldIndex);
/*
Expand Down
23 changes: 23 additions & 0 deletions test/ReferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class File_MARC_ReferenceTest extends TestCase
{
protected $record;
protected $record2;

protected function setUp()
{
Expand All @@ -26,6 +27,14 @@ protected function setUp()
// Iterate through the retrieved records
$this->record = $records->next();
}

if (false === ($this->record2 instanceof \File_MARC_Record)) {
// Retrieve a set of MARC records from a file
$records = new \File_MARC('test/example2.mrc');

// Iterate through the retrieved records
$this->record2 = $records->next();
}
}

public function testInstanciateFile_MARC_Record()
Expand Down Expand Up @@ -150,6 +159,20 @@ public function testGetSubfieldsOfRepeatedField()
$this->assertSame($_contents, $Reference->content);
}

public function testGetRepeatedSubfieldsOfRepeatedField()
{
$_contents = [
'(DE-588)4067488-5',
'(DE-627)10454466X',
'(DE-576)20917000X',
'(DE-588)4143389-0',
'(DE-627)105605913',
'(DE-576)209725893'
];
$Reference = new File_MARC_Reference('655$0', $this->record2);
$this->assertSame($_contents, $Reference->content);
}

public function testGetSubfieldByIndex()
{
$newSubfield = new \File_MARC_Subfield('a', 'a test');
Expand Down
1 change: 1 addition & 0 deletions test/example2.mrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
01671cas a2200433 4500001001000000003000700010005001700017007000300034008004100037016002200078016001900100022001400119030001000133035002200143035002200165035002200187035002100209035002100230040003100251044001000282082001600292084003800308210001700346245005100363264004400414336002600458337004600484338002500530362004300555363001200598363001200610591012900622655008600751655009100837689007600928689001101004936021501015951000701230129090085DE-62720201120103247.0tu931114d19701976xxkz| p| 0 |0und c7 a0100839442DE-1017 a6241-82DE-600 a0071-1438 aESPHA a(DE-627)129090085 a(DE-576)014425092 a(DE-599)ZDB6241-8 a(OCoLC)263589873 a(OCoLC)263589873 aDE-627bgercDE-627erakwb cXA-GB04a530qDE-600 aUD 75662rvk0(DE-625)rvk/145540:10aEssays Phys.10aEssays in physicsced. by G. K. T. Conn [u.a.]31aLondon [u.a.]bAcadem. Pressc1970-1976 aTextbtxt2rdacontent aohne Hilfsmittel zu benutzenbn2rdamedia aBandbnc2rdacarrier0 a1.1970 - 6.1976; damit Ersch. eingest.00a1i197010a6i1976 aSortierzählung bei Bänden maschinell geändert (GBV). - C!188!zs-Änderung(15-05-03) (SWB). - C!188!zs-Änderung(15-05-03) 7aZeitschrift0(DE-588)4067488-50(DE-627)10454466X0(DE-576)20917000X2gnd-content 7aAufgabensammlung0(DE-588)4143389-00(DE-627)1056059130(DE-576)2097258932gnd-content00Ds0(DE-588)4045956-10(DE-627)1061999000(DE-576)209067276aPhysik2gnd0 5DE-101rvaUD 7566bEssays in PhysicskPhysikkKongresse, Sommerschulen, geschlossen aufgestellte SerienkGeschlossen aufgestellte ReihenwerkekEssays in Physics0(DE-627)12718207650(DE-625)rvk/145540:0(DE-576)201820765 aJT