Skip to content

Commit

Permalink
Implement tests for recordInfo element
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed Apr 11, 2024
1 parent 06859e4 commit a283dbe
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 26 deletions.
106 changes: 86 additions & 20 deletions tests/Mods/ModsReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,22 @@ public function testGetRecordInfosForBookDocument()
self::assertNotEmpty($recordInfos);
self::assertEquals(1, count($recordInfos));
self::assertNotEmpty($recordInfos[0]->getValue());
//self::assertEquals('', $recordInfos[0]->getRecordIdentifier());
//self::assertNotEmpty($recordInfos[0]->getRecordOrigin());
//self::assertNotEmpty($recordInfos[0]->getLanguageOfCataloging());

// TODO: implement reading of elements
self::assertNotEmpty($recordInfos[0]->getDescriptionStandards());
self::assertEquals('aacr', $recordInfos[0]->getDescriptionStandards()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordContentSources());
self::assertEquals('marcorg', $recordInfos[0]->getRecordContentSources()[0]->getAuthority());
self::assertEquals('DLC', $recordInfos[0]->getRecordContentSources()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordCreationDates());
self::assertEquals('marc', $recordInfos[0]->getRecordCreationDates()[0]->getEncoding());
self::assertEquals('990730', $recordInfos[0]->getRecordCreationDates()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordChangeDates());
self::assertEquals('iso8601', $recordInfos[0]->getRecordChangeDates()[0]->getEncoding());
self::assertEquals('20060801143536.0', $recordInfos[0]->getRecordChangeDates()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordIdentifiers());
self::assertEquals('DE-14', $recordInfos[0]->getRecordIdentifiers()[0]->getSource());
self::assertEquals('11761548', $recordInfos[0]->getRecordIdentifiers()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordOrigins());
self::assertStringContainsString('Converted from MARCXML to MODS', $recordInfos[0]->getRecordOrigins()[0]->getValue());
}

public function testGetRecordInfosByQueryForBookDocument()
Expand All @@ -846,11 +857,22 @@ public function testGetRecordInfosByQueryForBookDocument()
self::assertNotEmpty($recordInfos);
self::assertEquals(1, count($recordInfos));
self::assertNotEmpty($recordInfos[0]->getValue());
//self::assertEquals('', $recordInfos[0]->getRecordIdentifier());
//self::assertNotEmpty($recordInfos[0]->getRecordOrigin());
//self::assertNotEmpty($recordInfos[0]->getLanguageOfCataloging());

// TODO: implement reading of elements
self::assertNotEmpty($recordInfos[0]->getDescriptionStandards());
self::assertEquals('aacr', $recordInfos[0]->getDescriptionStandards()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordContentSources());
self::assertEquals('marcorg', $recordInfos[0]->getRecordContentSources()[0]->getAuthority());
self::assertEquals('DLC', $recordInfos[0]->getRecordContentSources()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordCreationDates());
self::assertEquals('marc', $recordInfos[0]->getRecordCreationDates()[0]->getEncoding());
self::assertEquals('990730', $recordInfos[0]->getRecordCreationDates()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordChangeDates());
self::assertEquals('iso8601', $recordInfos[0]->getRecordChangeDates()[0]->getEncoding());
self::assertEquals('20060801143536.0', $recordInfos[0]->getRecordChangeDates()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordIdentifiers());
self::assertEquals('DE-14', $recordInfos[0]->getRecordIdentifiers()[0]->getSource());
self::assertEquals('11761548', $recordInfos[0]->getRecordIdentifiers()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordOrigins());
self::assertStringContainsString('Converted from MARCXML to MODS', $recordInfos[0]->getRecordOrigins()[0]->getValue());
}

public function testGetNoRecordInfosByQueryForBookDocument()
Expand All @@ -865,11 +887,33 @@ public function testGetRecordInfosForSerialDocument()
self::assertNotEmpty($recordInfos);
self::assertEquals(1, count($recordInfos));
self::assertNotEmpty($recordInfos[0]->getValue());
//self::assertEquals('', $recordInfos[0]->getRecordIdentifier());
//self::assertNotEmpty($recordInfos[0]->getRecordOrigin());
//self::assertNotEmpty($recordInfos[0]->getLanguageOfCataloging());

// TODO: implement reading of elements
self::assertNotEmpty($recordInfos[0]->getDescriptionStandards());
self::assertEquals('aacr', $recordInfos[0]->getDescriptionStandards()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordContentSources());
self::assertEquals('marcorg', $recordInfos[0]->getRecordContentSources()[0]->getAuthority());
self::assertEquals('NLC', $recordInfos[0]->getRecordContentSources()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordCreationDates());
self::assertEquals('marc', $recordInfos[0]->getRecordCreationDates()[0]->getEncoding());
self::assertEquals('021127', $recordInfos[0]->getRecordCreationDates()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordChangeDates());
self::assertEquals('iso8601', $recordInfos[0]->getRecordChangeDates()[0]->getEncoding());
self::assertEquals('20080910160139.0', $recordInfos[0]->getRecordChangeDates()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordIdentifiers());
self::assertEquals('15446420', $recordInfos[0]->getRecordIdentifiers()[0]->getValue());
self::assertStringContainsString('Converted from MARCXML to MODS', $recordInfos[0]->getRecordOrigins()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordInfoNotes());
self::assertEquals(2, count($recordInfos[0]->getRecordInfoNotes()));
self::assertEquals('Some info', $recordInfos[0]->getRecordInfoNotes()[1]->getValue());
$languages = $recordInfos[0]->getLanguageOfCatalogings();
self::assertNotEmpty($languages);
self::assertNotNull($languages[0]->getLanguageTerm());
self::assertEquals('code', $languages[0]->getLanguageTerm()->getType());
self::assertEquals('iso639-2b', $languages[0]->getLanguageTerm()->getAuthority());
self::assertEquals('eng', $languages[0]->getLanguageTerm()->getValue());
self::assertNotNull($languages[0]->getScriptTerm());
self::assertEquals('code', $languages[0]->getScriptTerm()->getType());
self::assertEquals('iso15924', $languages[0]->getScriptTerm()->getAuthority());
self::assertEquals('Latn', $languages[0]->getScriptTerm()->getValue());
}

public function testGetRecordInfosByQueryForSerialDocument()
Expand All @@ -878,11 +922,33 @@ public function testGetRecordInfosByQueryForSerialDocument()
self::assertNotEmpty($recordInfos);
self::assertEquals(1, count($recordInfos));
self::assertNotEmpty($recordInfos[0]->getValue());
//self::assertEquals('', $recordInfos[0]->getRecordIdentifier());
//self::assertNotEmpty($recordInfos[0]->getRecordOrigin());
//self::assertNotEmpty($recordInfos[0]->getLanguageOfCataloging());

// TODO: implement reading of elements
self::assertNotEmpty($recordInfos[0]->getDescriptionStandards());
self::assertEquals('aacr', $recordInfos[0]->getDescriptionStandards()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordContentSources());
self::assertEquals('marcorg', $recordInfos[0]->getRecordContentSources()[0]->getAuthority());
self::assertEquals('NLC', $recordInfos[0]->getRecordContentSources()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordCreationDates());
self::assertEquals('marc', $recordInfos[0]->getRecordCreationDates()[0]->getEncoding());
self::assertEquals('021127', $recordInfos[0]->getRecordCreationDates()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordChangeDates());
self::assertEquals('iso8601', $recordInfos[0]->getRecordChangeDates()[0]->getEncoding());
self::assertEquals('20080910160139.0', $recordInfos[0]->getRecordChangeDates()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordIdentifiers());
self::assertEquals('15446420', $recordInfos[0]->getRecordIdentifiers()[0]->getValue());
self::assertStringContainsString('Converted from MARCXML to MODS', $recordInfos[0]->getRecordOrigins()[0]->getValue());
self::assertNotEmpty($recordInfos[0]->getRecordInfoNotes());
self::assertEquals(2, count($recordInfos[0]->getRecordInfoNotes()));
self::assertEquals('Some info', $recordInfos[0]->getRecordInfoNotes()[1]->getValue());
$languages = $recordInfos[0]->getLanguageOfCatalogings();
self::assertNotEmpty($languages);
self::assertNotNull($languages[0]->getLanguageTerm());
self::assertEquals('code', $languages[0]->getLanguageTerm()->getType());
self::assertEquals('iso639-2b', $languages[0]->getLanguageTerm()->getAuthority());
self::assertEquals('eng', $languages[0]->getLanguageTerm()->getValue());
self::assertNotNull($languages[0]->getScriptTerm());
self::assertEquals('code', $languages[0]->getScriptTerm()->getType());
self::assertEquals('iso15924', $languages[0]->getScriptTerm()->getAuthority());
self::assertEquals('Latn', $languages[0]->getScriptTerm()->getValue());
}

public function testGetNoRecordInfosByQueryForSerialDocument()
Expand Down
5 changes: 2 additions & 3 deletions tests/resources/mods_book.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@
<recordContentSource authority="marcorg">DLC</recordContentSource>
<recordCreationDate encoding="marc">990730</recordCreationDate>
<recordChangeDate encoding="iso8601">20060801143536.0</recordChangeDate>
<recordIdentifier>11761548</recordIdentifier>
<recordOrigin>Converted from MARCXML to MODS version 3.8 using MARC21slim2MODS3-8_XSLT1-0.xsl
(Revision 1.172 20230208)</recordOrigin>
<recordIdentifier source="DE-14">11761548</recordIdentifier>
<recordOrigin>Converted from MARCXML to MODS version 3.8 using MARC21slim2MODS3-8_XSLT1-0.xsl (Revision 1.172 20230208)</recordOrigin>
</recordInfo>
</mods>
8 changes: 5 additions & 3 deletions tests/resources/mods_serial.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@
<recordCreationDate encoding="marc">021127</recordCreationDate>
<recordChangeDate encoding="iso8601">20080910160139.0</recordChangeDate>
<recordIdentifier>15446420</recordIdentifier>
<recordOrigin>Converted from MARCXML to MODS version 3.8 using MARC21slim2MODS3-8_XSLT1-0.xsl
(Revision 1.172 20230208)</recordOrigin>
<recordOrigin>Converted from MARCXML to MODS version 3.8 using MARC21slim2MODS3-8_XSLT1-0.xsl (Revision 1.172 20230208)</recordOrigin>
<recordInfoNote>Random note</recordInfoNote>
<recordInfoNote>Some info</recordInfoNote>
<languageOfCataloging>
<languageTerm authority="iso639-2b" type="code">eng</languageTerm>
<languageTerm type="code" authority="iso639-2b">eng</languageTerm>
<scriptTerm type="code" authority="iso15924">Latn</scriptTerm>
</languageOfCataloging>
</recordInfo>
</mods>

0 comments on commit a283dbe

Please sign in to comment.