From 659700e9edf75e37e4760e0832c9f739772e9b41 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Wed, 19 Jun 2024 16:02:23 +0200 Subject: [PATCH] Split and add tests for reader --- tests/Mods/ModsReaderTest.php | 1478 +---------------- tests/Mods/Reader/AbstractReaderTest.php | 94 ++ .../Mods/Reader/AccessConditionReaderTest.php | 179 ++ .../Mods/Reader/ClassificationReaderTest.php | 174 ++ tests/Mods/Reader/ExtensionReaderTest.php | 40 + tests/Mods/Reader/GenreReaderTest.php | 222 +++ tests/Mods/Reader/IdentifierReaderTest.php | 313 ++++ tests/Mods/Reader/LanguageReaderTest.php | 220 +++ tests/Mods/Reader/LocationReaderTest.php | 214 +++ tests/Mods/Reader/NameReaderTest.php | 221 +++ tests/Mods/Reader/NoteReaderTest.php | 232 +++ tests/Mods/Reader/OriginInfoReaderTest.php | 234 +++ tests/Mods/Reader/PartReaderTest.php | 172 ++ .../Reader/PhysicalDescriptionReaderTest.php | 173 ++ tests/Mods/Reader/RecordInfoReaderTest.php | 196 +++ tests/Mods/Reader/RelatedItemReaderTest.php | 136 ++ tests/Mods/Reader/SubjectReaderTest.php | 254 +++ .../Mods/Reader/TableOfContentsReaderTest.php | 154 ++ tests/Mods/Reader/TitleInfoReader.php | 77 + tests/Mods/Reader/TypeOfResourceTest.php | 80 + 20 files changed, 3389 insertions(+), 1474 deletions(-) create mode 100644 tests/Mods/Reader/AbstractReaderTest.php create mode 100644 tests/Mods/Reader/AccessConditionReaderTest.php create mode 100644 tests/Mods/Reader/ClassificationReaderTest.php create mode 100644 tests/Mods/Reader/ExtensionReaderTest.php create mode 100644 tests/Mods/Reader/GenreReaderTest.php create mode 100644 tests/Mods/Reader/IdentifierReaderTest.php create mode 100644 tests/Mods/Reader/LanguageReaderTest.php create mode 100644 tests/Mods/Reader/LocationReaderTest.php create mode 100644 tests/Mods/Reader/NameReaderTest.php create mode 100644 tests/Mods/Reader/NoteReaderTest.php create mode 100644 tests/Mods/Reader/OriginInfoReaderTest.php create mode 100644 tests/Mods/Reader/PartReaderTest.php create mode 100644 tests/Mods/Reader/PhysicalDescriptionReaderTest.php create mode 100644 tests/Mods/Reader/RecordInfoReaderTest.php create mode 100644 tests/Mods/Reader/RelatedItemReaderTest.php create mode 100644 tests/Mods/Reader/SubjectReaderTest.php create mode 100644 tests/Mods/Reader/TableOfContentsReaderTest.php create mode 100644 tests/Mods/Reader/TitleInfoReader.php create mode 100644 tests/Mods/Reader/TypeOfResourceTest.php diff --git a/tests/Mods/ModsReaderTest.php b/tests/Mods/ModsReaderTest.php index 38e5231..d9aa29a 100644 --- a/tests/Mods/ModsReaderTest.php +++ b/tests/Mods/ModsReaderTest.php @@ -18,16 +18,16 @@ class ModsReaderTest extends TestCase { /** - * @access private + * @access protected * @var ModsReader The MODS metadata reader for book document **/ - private $bookReader; + protected $bookReader; /** - * @access private + * @access protected * @var ModsReader The MODS metadata reader for serial document **/ - private $serialReader; + protected $serialReader; /** * This method is called before each test. @@ -47,1474 +47,4 @@ protected function setUp(): void protected function tearDown(): void { } - - public function testGetAbstractForBookDocument() - { - $abstract = $this->bookReader->getAbstract(); - self::assertNotNull($abstract); - self::assertNotEmpty($abstract->getDisplayLabel()); - self::assertEquals('Content description', $abstract->getDisplayLabel()); - self::assertNotEmpty($abstract->getValue()); - self::assertEquals('Test description for document which contains display label.', $abstract->getValue()); - self::assertTrue($abstract->isShareable()); - } - - public function testGetAbstractByQueryForBookDocument() - { - $abstract = $this->bookReader->getAbstract('[@displayLabel="Content description"]'); - self::assertNotNull($abstract); - self::assertNotEmpty($abstract->getDisplayLabel()); - self::assertEquals('Content description', $abstract->getDisplayLabel()); - self::assertNotEmpty($abstract->getValue()); - self::assertEquals('Test description for document which contains display label.', $abstract->getValue()); - self::assertTrue($abstract->isShareable()); - } - - public function testGetNoAbstractByQueryForBookDocument() - { - $abstract = $this->bookReader->getAbstract('[@displayLabel="Random"]'); - self::assertNull($abstract); - } - - public function testGetAbstractForSerialDocument() - { - $abstract = $this->serialReader->getAbstract(); - self::assertNotNull($abstract); - self::assertEmpty($abstract->getDisplayLabel()); - self::assertNotEmpty($abstract->getValue()); - self::assertEquals('Test description for non shareable document.', $abstract->getValue()); - self::assertFalse($abstract->isShareable()); - } - - public function testGetAbstractByQueryForSerialDocument() - { - $abstract = $this->serialReader->getAbstract('[@shareable="no"]'); - self::assertNotNull($abstract); - self::assertEmpty($abstract->getDisplayLabel()); - self::assertNotEmpty($abstract->getValue()); - self::assertEquals('Test description for non shareable document.', $abstract->getValue()); - self::assertFalse($abstract->isShareable()); - } - - public function testGetNoAbstractByQueryForSerialDocument() - { - $abstract = $this->serialReader->getAbstract('[@shareable="yes"]'); - self::assertNull($abstract); - } - - public function testGetAccessConditionsForBookDocument() - { - $accessConditions = $this->bookReader->getAccessConditions(); - self::assertNotEmpty($accessConditions); - self::assertEquals(1, count($accessConditions)); - self::assertNotEmpty($accessConditions[0]->getValue()); - self::assertEquals('Use of this public-domain resource is unrestricted.', $accessConditions[0]->getValue()); - self::assertNotEmpty($accessConditions[0]->getType()); - self::assertEquals('use and reproduction', $accessConditions[0]->getType()); - self::assertEmpty($accessConditions[0]->getDisplayLabel()); - self::assertEmpty($accessConditions[0]->getXlinkHref()); - } - - public function testGetAccessConditionsByQueryForBookDocument() - { - $accessConditions = $this->bookReader->getAccessConditions('[@type="use and reproduction"]'); - self::assertNotEmpty($accessConditions); - self::assertEquals(1, count($accessConditions)); - self::assertNotEmpty($accessConditions[0]->getValue()); - self::assertEquals('Use of this public-domain resource is unrestricted.', $accessConditions[0]->getValue()); - self::assertNotEmpty($accessConditions[0]->getType()); - self::assertEquals('use and reproduction', $accessConditions[0]->getType()); - self::assertEmpty($accessConditions[0]->getDisplayLabel()); - self::assertEmpty($accessConditions[0]->getXlinkHref()); - - $firstAccessCondition = $this->bookReader->getFirstAccessCondition('[@type="use and reproduction"]'); - self::assertEquals($accessConditions[0], $firstAccessCondition); - - $lastAccessCondition = $this->bookReader->getLastAccessCondition('[@type="use and reproduction"]'); - self::assertEquals($accessConditions[0], $lastAccessCondition); - } - - public function testGetNoAccessConditionsByQueryForBookDocument() - { - $accessConditions = $this->bookReader->getAccessConditions('[@type="restriction on access"]'); - self::assertEmpty($accessConditions); - - $firstAccessCondition = $this->bookReader->getFirstAccessCondition('[@type="restriction on access"]'); - self::assertNull($firstAccessCondition); - - $lastAccessCondition = $this->bookReader->getLastAccessCondition('[@type="restriction on access"]'); - self::assertNull($lastAccessCondition); - } - - public function testGetAccessConditionsForSerialDocument() - { - $accessConditions = $this->serialReader->getAccessConditions(); - self::assertNotEmpty($accessConditions); - self::assertEquals(1, count($accessConditions)); - self::assertNotEmpty($accessConditions[0]->getValue()); - self::assertEquals('Open Access', $accessConditions[0]->getValue()); - self::assertNotEmpty($accessConditions[0]->getType()); - self::assertEquals('restriction on access', $accessConditions[0]->getType()); - self::assertNotEmpty($accessConditions[0]->getDisplayLabel()); - self::assertEquals('Access Status', $accessConditions[0]->getDisplayLabel()); - // TODO: check out xlink - //self::assertEquals('http://purl.org/eprint/accessRights/OpenAccess', $accessConditions[0]->getXlinkHref()); - } - - public function testGetAccessConditionsByQueryForSerialDocument() - { - $accessConditions = $this->serialReader->getAccessConditions('[@type="restriction on access"]'); - self::assertNotEmpty($accessConditions); - self::assertEquals(1, count($accessConditions)); - self::assertNotEmpty($accessConditions[0]->getValue()); - self::assertEquals('Open Access', $accessConditions[0]->getValue()); - self::assertNotEmpty($accessConditions[0]->getType()); - self::assertEquals('restriction on access', $accessConditions[0]->getType()); - self::assertNotEmpty($accessConditions[0]->getDisplayLabel()); - self::assertEquals('Access Status', $accessConditions[0]->getDisplayLabel()); - // TODO: check out xlink - //self::assertEquals('http://purl.org/eprint/accessRights/OpenAccess', $accessConditions[0]->getXlinkHref()); - } - - public function testGetNoAccessConditionsByQueryForSerialDocument() - { - $accessConditions = $this->serialReader->getAccessConditions('[@type="use and reproduction"]'); - self::assertEmpty($accessConditions); - } - - public function testGetClassificationsForBookDocument() - { - $classifications = $this->bookReader->getClassifications(); - self::assertNotEmpty($classifications); - self::assertEquals(2, count($classifications)); - self::assertNotEmpty($classifications[0]->getValue()); - self::assertEquals('PN4888.P6 A48 1999', $classifications[0]->getValue()); - self::assertNotEmpty($classifications[0]->getAuthority()); - self::assertEquals('lcc', $classifications[0]->getAuthority()); - self::assertEmpty($classifications[0]->getId()); - self::assertEmpty($classifications[0]->getUsage()); - - $firstClassification = $this->bookReader->getFirstClassification(); - self::assertEquals($classifications[0], $firstClassification); - - $lastClassification = $this->bookReader->getLastClassification(); - self::assertEquals($classifications[1], $lastClassification); - } - - public function testGetClassificationsByQueryForBookDocument() - { - $classifications = $this->bookReader->getClassifications('[@authority="ddc"]'); - self::assertNotEmpty($classifications); - self::assertEquals(1, count($classifications)); - self::assertNotEmpty($classifications[0]->getValue()); - self::assertEquals('071/.3', $classifications[0]->getValue()); - self::assertNotEmpty($classifications[0]->getEdition()); - self::assertEquals('21', $classifications[0]->getEdition()); - self::assertEmpty($classifications[0]->getDisplayLabel()); - self::assertEmpty($classifications[0]->getGenerator()); - } - - public function testGetNoClassificationsByQueryForBookDocument() - { - $classifications = $this->bookReader->getClassifications('[@generator="xyz"]'); - self::assertEmpty($classifications); - - $firstClassification = $this->bookReader->getFirstClassification('[@generator="xyz"]'); - self::assertNull($firstClassification); - - $lastClassification = $this->bookReader->getLastClassification('[@generator="xyz"]'); - self::assertNull($lastClassification); - } - - public function testGetClassificationsForSerialDocument() - { - $classifications = $this->serialReader->getClassifications(); - self::assertNotEmpty($classifications); - self::assertEquals(1, count($classifications)); - self::assertNotEmpty($classifications[0]->getValue()); - self::assertEquals('027.7/05', $classifications[0]->getValue()); - self::assertNotEmpty($classifications[0]->getAuthority()); - self::assertEquals('ddc', $classifications[0]->getAuthority()); - self::assertNotEmpty($classifications[0]->getEdition()); - self::assertEquals('21', $classifications[0]->getEdition()); - self::assertEmpty($classifications[0]->getDisplayLabel()); - self::assertEmpty($classifications[0]->getGenerator()); - } - - public function testGetClassificationsByQueryForSerialDocument() - { - $classifications = $this->serialReader->getClassifications('[@authority="ddc"]'); - self::assertNotEmpty($classifications); - self::assertEquals(1, count($classifications)); - self::assertNotEmpty($classifications[0]->getValue()); - self::assertEquals('027.7/05', $classifications[0]->getValue()); - self::assertNotEmpty($classifications[0]->getAuthority()); - self::assertEquals('ddc', $classifications[0]->getAuthority()); - self::assertNotEmpty($classifications[0]->getEdition()); - self::assertEquals('21', $classifications[0]->getEdition()); - self::assertEmpty($classifications[0]->getDisplayLabel()); - self::assertEmpty($classifications[0]->getGenerator()); - } - - public function testGetNoClassificationsByQueryForSerialDocument() - { - $classifications = $this->serialReader->getClassifications('[@edition="22"]'); - self::assertEmpty($classifications); - } - - public function testGetExtensionsForBookDocument() - { - $extensions = $this->bookReader->getExtensions(); - - $this->assertTrue(true, 'WIP'); - } - - public function testGetExtensionsForSerialDocument() - { - $extensions = $this->serialReader->getExtensions(); - - $this->assertTrue(true, 'WIP'); - } - - public function testGetGenresForBookDocument() - { - $genres = $this->bookReader->getGenres(); - self::assertNotEmpty($genres); - self::assertEquals(1, count($genres)); - self::assertNotEmpty($genres[0]->getValue()); - self::assertEquals('bibliography', $genres[0]->getValue()); - self::assertNotEmpty($genres[0]->getAuthority()); - self::assertEquals('marcgt', $genres[0]->getAuthority()); - self::assertEmpty($genres[0]->getLang()); - self::assertEmpty($genres[0]->getScript()); - } - - public function testGetGenresByQueryForBookDocument() - { - $genres = $this->bookReader->getGenres('[@authority="marcgt"]'); - self::assertNotEmpty($genres); - self::assertEquals(1, count($genres)); - self::assertNotEmpty($genres[0]->getValue()); - self::assertEquals('bibliography', $genres[0]->getValue()); - self::assertNotEmpty($genres[0]->getAuthority()); - self::assertEquals('marcgt', $genres[0]->getAuthority()); - self::assertEmpty($genres[0]->getLang()); - self::assertEmpty($genres[0]->getScript()); - } - - public function testGetNoGenresByQueryForBookDocument() - { - $genres = $this->bookReader->getGenres('[@authority="merc"]'); - self::assertEmpty($genres); - - $firstGenre = $this->bookReader->getFirstGenre('[@authority="merc"]'); - self::assertNull($firstGenre); - - $lastGenre = $this->bookReader->getLastGenre('[@authority="merc"]'); - self::assertNull($lastGenre); - } - - public function testGetGenresForSerialDocument() - { - $genres = $this->serialReader->getGenres(); - self::assertNotEmpty($genres); - self::assertEquals(2, count($genres)); - self::assertNotEmpty($genres[0]->getValue()); - self::assertEquals('periodical', $genres[0]->getValue()); - self::assertNotEmpty($genres[0]->getUsage()); - self::assertEquals('primary', $genres[0]->getUsage()); - self::assertEmpty($genres[0]->getDisplayLabel()); - self::assertEmpty($genres[0]->getTransliteration()); - - $firstGenre = $this->serialReader->getFirstGenre(); - self::assertEquals($genres[0], $firstGenre); - - $lastGenre = $this->serialReader->getLastGenre(); - self::assertEquals($genres[1], $lastGenre); - } - - public function testGetGenresByQueryForSerialDocument() - { - $genres = $this->serialReader->getGenres('[@usage="primary"]'); - self::assertNotEmpty($genres); - self::assertEquals(1, count($genres)); - self::assertNotEmpty($genres[0]->getValue()); - self::assertEquals('periodical', $genres[0]->getValue()); - self::assertNotEmpty($genres[0]->getUsage()); - self::assertEquals('primary', $genres[0]->getUsage()); - self::assertEmpty($genres[0]->getDisplayLabel()); - self::assertEmpty($genres[0]->getTransliteration()); - } - - public function testGetNoGenresByQueryForSerialDocument() - { - $genres = $this->serialReader->getGenres('[@type="xyz"]'); - self::assertEmpty($genres); - } - - public function testGetIdentifiersForBookDocument() - { - $identifiers = $this->bookReader->getIdentifiers(); - self::assertNotEmpty($identifiers); - self::assertEquals(2, count($identifiers)); - self::assertNotEmpty($identifiers[0]->getValue()); - self::assertEquals('0801486394 (pbk. : acid-free, recycled paper)', $identifiers[0]->getValue()); - self::assertNotEmpty($identifiers[0]->getType()); - self::assertEquals('isbn', $identifiers[0]->getType()); - self::assertEmpty($identifiers[0]->getLang()); - self::assertFalse($identifiers[0]->isInvalid()); - - $firstIdentifier = $this->bookReader->getFirstIdentifier(); - self::assertEquals($identifiers[0], $firstIdentifier); - - $lastIdentifier = $this->bookReader->getLastIdentifier(); - self::assertEquals($identifiers[1], $lastIdentifier); - } - - public function testGetIdentifiersByQueryForBookDocument() - { - $identifiers = $this->bookReader->getIdentifiers('[@type="lccn"]'); - self::assertNotEmpty($identifiers); - self::assertEquals(1, count($identifiers)); - self::assertNotEmpty($identifiers[0]->getValue()); - self::assertEquals('99042030', $identifiers[0]->getValue()); - self::assertNotEmpty($identifiers[0]->getType()); - self::assertEquals('lccn', $identifiers[0]->getType()); - self::assertEmpty($identifiers[0]->getLang()); - self::assertFalse($identifiers[0]->isInvalid()); - } - - public function testGetNoIdentifiersByQueryForBookDocument() - { - $identifiers = $this->bookReader->getIdentifiers('[@type="xyz"]'); - self::assertEmpty($identifiers); - - $firstIdentifier = $this->bookReader->getFirstIdentifier('[@type="xyz"]'); - self::assertNull($firstIdentifier); - - $lastIdentifier = $this->bookReader->getLastIdentifier('[@type="xyz"]'); - self::assertNull($lastIdentifier); - } - - public function testGetIdentifiersForSerialDocument() - { - $identifiers = $this->serialReader->getIdentifiers(); - self::assertNotEmpty($identifiers); - self::assertEquals(4, count($identifiers)); - self::assertNotEmpty($identifiers[0]->getValue()); - self::assertEquals('1704-8532', $identifiers[0]->getValue()); - self::assertNotEmpty($identifiers[0]->getType()); - self::assertEquals('issn', $identifiers[0]->getType()); - self::assertEmpty($identifiers[0]->getDisplayLabel()); - self::assertFalse($identifiers[0]->isInvalid()); - } - - public function testGetIdentifiersByQueryForSerialDocument() - { - $identifiers = $this->serialReader->getIdentifiers('[@type="issn"]'); - self::assertNotEmpty($identifiers); - self::assertEquals(2, count($identifiers)); - self::assertNotEmpty($identifiers[1]->getValue()); - self::assertEquals('1525-321X', $identifiers[1]->getValue()); - self::assertNotEmpty($identifiers[0]->getType()); - self::assertEquals('issn', $identifiers[1]->getType()); - self::assertEmpty($identifiers[1]->getDisplayLabel()); - self::assertTrue($identifiers[1]->isInvalid()); - } - - public function testGetNoIdentifiersByQueryForSerialDocument() - { - $identifiers = $this->serialReader->getIdentifiers('[@type="xyz"]'); - self::assertEmpty($identifiers); - } - - public function testGetLanguagesForBookDocument() - { - $languages = $this->bookReader->getLanguages(); - self::assertNotEmpty($languages); - self::assertEquals(2, count($languages)); - self::assertEmpty($languages[0]->getObjectPart()); - self::assertNotEmpty($languages[0]->getValue()); - self::assertNotEmpty($languages[0]->getLanguageTerms()); - self::assertNotEmpty($languages[0]->getLanguageTerms()[0]->getValue()); - self::assertEquals('code', $languages[0]->getLanguageTerms()[0]->getType()); - self::assertEquals('iso639-2b', $languages[0]->getLanguageTerms()[0]->getAuthority()); - self::assertEquals('eng', $languages[0]->getLanguageTerms()[0]->getValue()); - self::assertNotEmpty($languages[0]->getScriptTerms()); - self::assertEquals('code', $languages[0]->getScriptTerms()[0]->getType()); - self::assertEquals('iso15924', $languages[0]->getScriptTerms()[0]->getAuthority()); - self::assertEquals('Latn', $languages[0]->getScriptTerms()[0]->getValue()); - - $firstLanguage = $this->bookReader->getFirstLanguage(); - self::assertEquals($languages[0], $firstLanguage); - - $lastLanguage = $this->bookReader->getLastLanguage(); - self::assertEquals($languages[1], $lastLanguage); - } - - public function testGetLanguagesByQueryForBookDocument() - { - $languages = $this->bookReader->getLanguages('[@objectPart="summary"]'); - self::assertNotEmpty($languages); - self::assertEquals(1, count($languages)); - self::assertNotEmpty($languages[0]->getObjectPart()); - self::assertEquals('summary', $languages[0]->getObjectPart()); - self::assertNotEmpty($languages[0]->getValue()); - self::assertNotEmpty($languages[0]->getLanguageTerms()); - self::assertNotEmpty($languages[0]->getLanguageTerms()[0]->getValue()); - self::assertEquals('code', $languages[0]->getLanguageTerms()[0]->getType()); - self::assertEquals('iso639-2b', $languages[0]->getLanguageTerms()[0]->getAuthority()); - self::assertEquals('spa', $languages[0]->getLanguageTerms()[0]->getValue()); - self::assertNotEmpty($languages[0]->getScriptTerms()); - self::assertEquals('code', $languages[0]->getScriptTerms()[0]->getType()); - self::assertEquals('iso15924', $languages[0]->getScriptTerms()[0]->getAuthority()); - self::assertEquals('Latn', $languages[0]->getScriptTerms()[0]->getValue()); - } - - public function testGetNoLanguagesByQueryForBookDocument() - { - $languages = $this->bookReader->getLanguages('[@objectPart="abstract"]'); - self::assertEmpty($languages); - - $firstLanguage = $this->bookReader->getFirstLanguage('[@objectPart="abstract"]'); - self::assertNull($firstLanguage); - - $lastLanguage = $this->bookReader->getLastLanguage('[@objectPart="abstract"]'); - self::assertNull($lastLanguage); - } - - public function testGetLanguagesForSerialDocument() - { - $languages = $this->serialReader->getLanguages(); - self::assertNotEmpty($languages); - self::assertEquals(1, count($languages)); - self::assertEmpty($languages[0]->getObjectPart()); - self::assertNotEmpty($languages[0]->getValue()); - self::assertNotEmpty($languages[0]->getLanguageTerms()); - self::assertNotEmpty($languages[0]->getLanguageTerms()[0]->getValue()); - self::assertEquals('code', $languages[0]->getLanguageTerms()[0]->getType()); - self::assertEquals('iso639-2b', $languages[0]->getLanguageTerms()[0]->getAuthority()); - self::assertEquals('eng', $languages[0]->getLanguageTerms()[0]->getValue()); - self::assertEmpty($languages[0]->getScriptTerms()); - } - - public function testGetLanguagesByQueryForSerialDocument() - { - $languages = $this->serialReader->getLanguages('[./mods:languageTerm[@type="code"]]'); - self::assertNotEmpty($languages); - self::assertEquals(1, count($languages)); - self::assertEmpty($languages[0]->getObjectPart()); - self::assertNotEmpty($languages[0]->getValue()); - self::assertNotEmpty($languages[0]->getLanguageTerms()); - self::assertNotEmpty($languages[0]->getLanguageTerms()[0]->getValue()); - self::assertEquals('code', $languages[0]->getLanguageTerms()[0]->getType()); - self::assertEquals('iso639-2b', $languages[0]->getLanguageTerms()[0]->getAuthority()); - self::assertEquals('eng', $languages[0]->getLanguageTerms()[0]->getValue()); - self::assertEmpty($languages[0]->getScriptTerms()); - } - - public function testGetNoLanguagesByQueryForSerialDocument() - { - $languages = $this->serialReader->getLanguages('[@objectPart="summary"]'); - self::assertEmpty($languages); - } - - public function testGetLocationsForBookDocument() - { - $locations = $this->bookReader->getLocations(); - self::assertNotEmpty($locations); - self::assertEquals(2, count($locations)); - self::assertNotEmpty($locations[0]->getValue()); - - $physicalLocations = $locations[0]->getPhysicalLocations(); - self::assertNotEmpty($physicalLocations); - self::assertEquals('marcorg', $physicalLocations[0]->getAuthority()); - self::assertEquals('MnRM', $physicalLocations[0]->getValue()); - - $holdingSimple = $locations[0]->getHoldingSimple(); - self::assertNotNull($holdingSimple); - - $copyInformation = $holdingSimple->getCopyInformation(); - self::assertNotEmpty($copyInformation); - self::assertNotEmpty($copyInformation[0]->getSubLocations()); - self::assertEquals('Reading room', $copyInformation[0]->getSubLocations()[0]->getValue()); - self::assertNotEmpty($copyInformation[0]->getShelfLocators()); - self::assertEquals('QH511.A1J68', $copyInformation[0]->getShelfLocators()[0]->getValue()); - self::assertEquals('1', $copyInformation[0]->getEnumerationAndChronologies()[0]->getUnitType()); - self::assertEquals('v.1-v.2 1999-2002', $copyInformation[0]->getEnumerationAndChronologies()[0]->getValue()); - - $firstLocation = $this->bookReader->getFirstLocation(); - self::assertEquals($locations[0], $firstLocation); - - $lastLocation = $this->bookReader->getLastLocation(); - self::assertEquals($locations[1], $lastLocation); - } - - public function testGetLocationsByQueryForBookDocument() - { - $locations = $this->bookReader->getLocations('[@displayLabel="links"]'); - self::assertNotEmpty($locations); - self::assertEquals(1, count($locations)); - self::assertNotEmpty($locations[0]->getValue()); - - $urls = $locations[0]->getUrls(); - self::assertNotEmpty($urls); - self::assertEquals(4, count($urls)); - self::assertEquals('2024-01-27', $urls[0]->getDateLastAccessed()); - self::assertEquals('http://www.slub-dresden.de/some-url', $urls[0]->getValue()); - self::assertEquals('preview', $urls[1]->getAccess()); - self::assertEquals('http://www.slub-dresden.de/some-url/SLO-0000', $urls[1]->getValue()); - - $this->expectException(IncorrectValueInAttributeException::class); - $urls[3]->getAccess(); - } - - public function testGetNoLocationsByQueryForBookDocument() - { - $locations = $this->bookReader->getLocations('[@displayLabel="random"]'); - self::assertEmpty($locations); - - $firstLocation = $this->bookReader->getFirstLocation('[@displayLabel="random"]'); - self::assertNull($firstLocation); - - $lastLocation = $this->bookReader->getLastLocation('[@displayLabel="random"]'); - self::assertNull($lastLocation); - } - - public function testGetLocationsForSerialDocument() - { - $locations = $this->serialReader->getLocations(); - self::assertNotEmpty($locations); - self::assertEquals(2, count($locations)); - self::assertNotEmpty($locations[0]->getUrls()); - self::assertEquals('electronic resource', $locations[0]->getUrls()[0]->getDisplayLabel()); - self::assertEquals('primaryDisplay', $locations[0]->getUrls()[0]->getUsage()); - self::assertEquals('http://bibpurl.oclc.org/web/7085', $locations[0]->getUrls()[0]->getValue()); - } - - public function testGetLocationsByQueryForSerialDocument() - { - $locations = $this->serialReader->getLocations('[./mods:url[@usage="primaryDisplay"]]'); - self::assertNotEmpty($locations); - self::assertEquals(1, count($locations)); - self::assertNotEmpty($locations[0]->getUrls()); - self::assertEquals('electronic resource', $locations[0]->getUrls()[0]->getDisplayLabel()); - self::assertEquals('primaryDisplay', $locations[0]->getUrls()[0]->getUsage()); - self::assertEquals('http://bibpurl.oclc.org/web/7085', $locations[0]->getUrls()[0]->getValue()); - } - - public function testNoGetLocationsByQueryForSerialDocument() - { - $locations = $this->serialReader->getLocations('[@usage="rad"]'); - self::assertEmpty($locations); - } - - public function testGetNamesForBookDocument() - { - $names = $this->bookReader->getNames(); - self::assertNotEmpty($names); - self::assertEquals(2, count($names)); - self::assertNotEmpty($names[0]->getType()); - self::assertEquals('personal', $names[0]->getType()); - self::assertNotEmpty($names[0]->getUsage()); - self::assertEquals('primary', $names[0]->getUsage()); - self::assertNotEmpty($names[0]->getValue()); - self::assertNotEmpty($names[0]->getNameParts()); - self::assertEquals('Alterman, Eric.', $names[0]->getNameParts()[0]->getValue()); - - $roles = $names[0]->getRoles(); - self::assertNotEmpty($roles); - self::assertNotEmpty($roles[0]->getRoleTerms()); - self::assertEquals('text', $roles[0]->getRoleTerms()[0]->getType()); - self::assertEquals('marcrelator', $roles[0]->getRoleTerms()[0]->getAuthority()); - self::assertEquals('creator', $roles[0]->getRoleTerms()[0]->getValue()); - - $firstName = $this->bookReader->getFirstName(); - self::assertEquals($names[0], $firstName); - - $lastName = $this->bookReader->getLastName(); - self::assertEquals($names[1], $lastName); - } - - public function testGetNamesByQueryForBookDocument() - { - $names = $this->bookReader->getNames('[@type="personal" and not(@usage="primary")]'); - self::assertNotEmpty($names); - self::assertEquals(1, count($names)); - self::assertNotEmpty($names[0]->getType()); - self::assertEquals('personal', $names[0]->getType()); - self::assertEmpty($names[0]->getUsage()); - self::assertNotEmpty($names[0]->getValue()); - self::assertNotEmpty($names[0]->getNameParts()); - self::assertEquals(2, count($names[0]->getNameParts())); - self::assertEquals('given', $names[0]->getNameParts()[0]->getType()); - self::assertEquals('Aron', $names[0]->getNameParts()[0]->getValue()); - - $roles = $names[0]->getRoles(); - self::assertNotEmpty($roles); - self::assertNotEmpty($roles[0]->getRoleTerms()); - self::assertEquals('text', $roles[0]->getRoleTerms()[0]->getType()); - self::assertEquals('marcrelator', $roles[0]->getRoleTerms()[0]->getAuthority()); - self::assertEquals('author', $roles[0]->getRoleTerms()[0]->getValue()); - } - - public function testGetNoNamesByQueryForBookDocument() - { - $names = $this->bookReader->getNames('[@type="corporate"]'); - self::assertEmpty($names); - - $firstName = $this->bookReader->getFirstName('[@type="corporate"]'); - self::assertNull($firstName); - - $lastName = $this->bookReader->getLastName('[@type="corporate"]'); - self::assertNull($lastName); - } - - public function testGetNamesForSerialDocument() - { - $names = $this->serialReader->getNames(); - self::assertNotEmpty($names); - self::assertEquals(1, count($names)); - self::assertNotEmpty($names[0]->getValue()); - self::assertNotEmpty($names[0]->getNameParts()); - self::assertEquals(1, count($names[0]->getNameParts())); - self::assertEquals('International Consortium for the Advancement of Academic Publication.', $names[0]->getNameParts()[0]->getValue()); - } - - public function testGetNamesByQueryForSerialDocument() - { - $names = $this->serialReader->getNames('[@type="corporate"]'); - self::assertNotEmpty($names); - self::assertEquals(1, count($names)); - self::assertNotEmpty($names[0]->getValue()); - self::assertNotEmpty($names[0]->getNameParts()); - self::assertEquals(1, count($names[0]->getNameParts())); - self::assertEquals('International Consortium for the Advancement of Academic Publication.', $names[0]->getNameParts()[0]->getValue()); - } - - public function testGetNoNamesByQueryForSerialDocument() - { - $names = $this->serialReader->getNames('[@type="personal"]'); - self::assertEmpty($names); - } - - public function testGetNotesForBookDocument() - { - $notes = $this->bookReader->getNotes(); - self::assertNotEmpty($notes); - self::assertEquals(2, count($notes)); - self::assertNotEmpty($notes[0]->getValue()); - self::assertEquals('Eric Alterman.', $notes[0]->getValue()); - self::assertNotEmpty($notes[0]->getType()); - self::assertEquals('statement of responsibility', $notes[0]->getType()); - - $firstNote = $this->bookReader->getFirstNote(); - self::assertEquals($notes[0], $firstNote); - - $lastNote = $this->bookReader->getLastNote(); - self::assertEquals($notes[1], $lastNote); - } - - public function testGetNotesByQueryForBookDocument() - { - $notes = $this->bookReader->getNotes('[@type="bibliography"]'); - self::assertNotEmpty($notes); - self::assertEquals(1, count($notes)); - self::assertNotEmpty($notes[0]->getValue()); - self::assertEquals('Includes bibliographical references (p. 291-312) and index.', $notes[0]->getValue()); - self::assertNotEmpty($notes[0]->getType()); - self::assertEquals('bibliography', $notes[0]->getType()); - } - - public function testGetNoNotesByQueryForBookDocument() - { - $notes = $this->bookReader->getNotes('[@type="xyz"]'); - self::assertEmpty($notes); - - $firstNote = $this->bookReader->getFirstNote('[@type="xyz"]'); - self::assertNull($firstNote); - - $lastNote = $this->bookReader->getLastNote('[@type="xyz"]'); - self::assertNull($lastNote); - } - - public function testGetNotesForSerialDocument() - { - $notes = $this->serialReader->getNotes(); - self::assertNotEmpty($notes); - self::assertEquals(6, count($notes)); - self::assertNotEmpty($notes[0]->getValue()); - self::assertEquals('V. 3, no. 1/2 (winter 2002)-', $notes[0]->getValue()); - self::assertNotEmpty($notes[0]->getType()); - self::assertEquals('date/sequential designation', $notes[0]->getType()); - } - - public function testGetNotesByQueryForSerialDocument() - { - $notes = $this->serialReader->getNotes('[@type="system details"]'); - self::assertNotEmpty($notes); - self::assertEquals(1, count($notes)); - self::assertNotEmpty($notes[0]->getValue()); - self::assertEquals('Mode of access: World Wide Web.', $notes[0]->getValue()); - self::assertNotEmpty($notes[0]->getType()); - self::assertEquals('system details', $notes[0]->getType()); - } - - public function testGetNoNotesByQueryForSerialDocument() - { - $notes = $this->serialReader->getNotes('[@type="xyz"]'); - self::assertEmpty($notes); - } - - public function testGetOriginInfosForBookDocument() - { - $originInfos = $this->bookReader->getOriginInfos(); - self::assertNotEmpty($originInfos); - self::assertEquals(2, count($originInfos)); - self::assertNotEmpty($originInfos[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getEventType()); - self::assertEquals('publication', $originInfos[0]->getEventType()); - self::assertNotEmpty($originInfos[0]->getPlaces()); - self::assertEquals(2, count($originInfos[0]->getPlaces())); - - $placeTerms = $originInfos[0]->getPlaces()[0]->getPlaceTerms(); - self::assertNotEmpty($placeTerms); - self::assertEquals('marccountry', $placeTerms[0]->getAuthority()); - self::assertEquals('code', $placeTerms[0]->getType()); - self::assertEquals('nyu', $placeTerms[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getIssuedDates()); - self::assertEquals(2, count($originInfos[0]->getIssuedDates())); - self::assertEquals('marc', $originInfos[0]->getIssuedDates()[0]->getEncoding()); - self::assertEquals('2000', $originInfos[0]->getIssuedDates()[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getIssuances()); - self::assertEquals('monographic', $originInfos[0]->getIssuances()[0]->getValue()); - - $firstOriginInfo = $this->bookReader->getFirstOriginInfo(); - self::assertEquals($originInfos[0], $firstOriginInfo); - - $lastOriginInfo = $this->bookReader->getLastOriginInfo(); - self::assertEquals($originInfos[1], $lastOriginInfo); - } - - public function testGetOriginInfosByQueryForBookDocument() - { - $originInfos = $this->bookReader->getOriginInfos('[@eventType="redaction"]'); - self::assertNotEmpty($originInfos); - self::assertEquals(1, count($originInfos)); - self::assertNotEmpty($originInfos[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getEventType()); - self::assertEquals('redaction', $originInfos[0]->getEventType()); - self::assertNotEmpty($originInfos[0]->getPlaces()); - self::assertEquals(2, count($originInfos[0]->getPlaces())); - $placeTerms = $originInfos[0]->getPlaces()[1]->getPlaceTerms(); - self::assertNotEmpty($placeTerms); - self::assertEquals('text', $placeTerms[0]->getType()); - self::assertEquals('Ithaca, N.Y', $placeTerms[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getIssuedDates()); - self::assertEquals(2, count($originInfos[0]->getIssuedDates())); - self::assertEquals('marc', $originInfos[0]->getIssuedDates()[0]->getEncoding()); - self::assertEquals('1999', $originInfos[0]->getIssuedDates()[0]->getValue()); - self::assertEmpty($originInfos[0]->getIssuances()); - } - - public function testGetNoOriginInfosByQueryForBookDocument() - { - $originInfos = $this->bookReader->getOriginInfos('[@eventType="xyz"]'); - self::assertEmpty($originInfos); - - $firstOriginInfo = $this->bookReader->getFirstOriginInfo('[@eventType="xyz"]'); - self::assertNull($firstOriginInfo); - - $lastOriginInfo = $this->bookReader->getLastOriginInfo('[@eventType="xyz"]'); - self::assertNull($lastOriginInfo); - } - - public function testGetOriginInfosForSerialDocument() - { - $originInfos = $this->serialReader->getOriginInfos(); - self::assertNotEmpty($originInfos); - self::assertEquals(1, count($originInfos)); - self::assertNotEmpty($originInfos[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getEventType()); - self::assertEquals('publication', $originInfos[0]->getEventType()); - self::assertNotEmpty($originInfos[0]->getPlaces()); - self::assertEquals(2, count($originInfos[0]->getPlaces())); - - $placeTerms = $originInfos[0]->getPlaces()[0]->getPlaceTerms(); - self::assertNotEmpty($placeTerms); - self::assertEquals('marccountry', $placeTerms[0]->getAuthority()); - self::assertEquals('code', $placeTerms[0]->getType()); - self::assertEquals('abc', $placeTerms[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getIssuedDates()); - self::assertEquals(3, count($originInfos[0]->getIssuedDates())); - self::assertEquals('marc', $originInfos[0]->getIssuedDates()[0]->getEncoding()); - self::assertEquals('start', $originInfos[0]->getIssuedDates()[0]->getPoint()); - self::assertEquals('2002', $originInfos[0]->getIssuedDates()[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getIssuances()); - self::assertEquals('serial', $originInfos[0]->getIssuances()[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getFrequencies()); - self::assertEquals(2, count($originInfos[0]->getFrequencies())); - self::assertEquals('Three times a year', $originInfos[0]->getFrequencies()[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getAgents()); - //self::assertNotEmpty($originInfos[0]->getAgents()[0]->getNamePart()); - } - - public function testGetOriginInfosByQueryForSerialDocument() - { - $originInfos = $this->serialReader->getOriginInfos('[@eventType="publication"]'); - self::assertNotEmpty($originInfos); - self::assertEquals(1, count($originInfos)); - self::assertNotEmpty($originInfos[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getEventType()); - self::assertEquals('publication', $originInfos[0]->getEventType()); - self::assertNotEmpty($originInfos[0]->getPlaces()); - self::assertEquals(2, count($originInfos[0]->getPlaces())); - - $placeTerms = $originInfos[0]->getPlaces()[0]->getPlaceTerms(); - self::assertNotEmpty($placeTerms); - self::assertEquals('marccountry', $placeTerms[0]->getAuthority()); - self::assertEquals('code', $placeTerms[0]->getType()); - self::assertEquals('abc', $placeTerms[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getIssuedDates()); - self::assertEquals(3, count($originInfos[0]->getIssuedDates())); - self::assertEquals('marc', $originInfos[0]->getIssuedDates()[0]->getEncoding()); - self::assertEquals('start', $originInfos[0]->getIssuedDates()[0]->getPoint()); - self::assertEquals('2002', $originInfos[0]->getIssuedDates()[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getIssuances()); - self::assertEquals('serial', $originInfos[0]->getIssuances()[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getFrequencies()); - self::assertEquals(2, count($originInfos[0]->getFrequencies())); - self::assertEquals('Three times a year', $originInfos[0]->getFrequencies()[0]->getValue()); - self::assertNotEmpty($originInfos[0]->getAgents()); - //self::assertNotEmpty($originInfos[0]->getAgents()[0]->getNamePart()); - } - - public function testGetNoOriginInfosByQueryForSerialDocument() - { - $originInfos = $this->serialReader->getOriginInfos('[@eventType="xyz"]'); - self::assertEmpty($originInfos); - } - - public function testGetPartsForBookDocument() - { - $parts = $this->bookReader->getParts(); - self::assertNotEmpty($parts); - self::assertEquals(2, count($parts)); - self::assertNotEmpty($parts[0]->getValue()); - self::assertNotEmpty($parts[0]->getType()); - self::assertEquals('poem', $parts[0]->getType()); - self::assertNotEmpty($parts[0]->getOrder()); - self::assertEquals(1, $parts[0]->getOrder()); - self::assertNotEmpty($parts[0]->getDetails()); - self::assertNotEmpty($parts[0]->getDetails()[0]->getTitles()); - self::assertEquals('Wayfarers', $parts[0]->getDetails()[0]->getTitles()[0]->getValue()); - self::assertNotEmpty($parts[0]->getExtents()); - self::assertEquals('pages', $parts[0]->getExtents()[0]->getUnit()); - self::assertEquals('97', $parts[0]->getExtents()[0]->getStart()->getValue()); - self::assertEquals('98', $parts[0]->getExtents()[0]->getEnd()->getValue()); - self::assertNotEmpty($parts[0]->getDates()); - self::assertEquals('marc', $parts[0]->getDates()[0]->getEncoding()); - self::assertEquals('1989', $parts[0]->getDates()[0]->getValue()); - self::assertNotEmpty($parts[0]->getTexts()); - self::assertEquals('Some random text', $parts[0]->getTexts()[0]->getValue()); - - $firstPart = $this->bookReader->getFirstPart(); - self::assertEquals($parts[0], $firstPart); - - $lastPart = $this->bookReader->getLastPart(); - self::assertEquals($parts[1], $lastPart); - } - - public function testGetPartsByQueryForBookDocument() - { - $parts = $this->bookReader->getParts('[@order="2"]'); - self::assertNotEmpty($parts); - self::assertEquals(1, count($parts)); - self::assertNotEmpty($parts[0]->getValue()); - self::assertNotEmpty($parts[0]->getType()); - self::assertEquals('poem', $parts[0]->getType()); - self::assertNotEmpty($parts[0]->getOrder()); - self::assertEquals(2, $parts[0]->getOrder()); - $details = $parts[0]->getDetails(); - self::assertNotEmpty($details); - self::assertEquals(2, count($details)); - self::assertEquals('begin', $details[0]->getType()); - self::assertEquals(1, $details[0]->getLevel()); - self::assertNotEmpty($details[0]->getTitles()); - self::assertEquals('Vagabonds', $details[0]->getTitles()[0]->getValue()); - self::assertNotEmpty($parts[0]->getExtents()); - self::assertEquals('pages', $parts[0]->getExtents()[0]->getUnit()); - self::assertEquals('99', $parts[0]->getExtents()[0]->getStart()->getValue()); - self::assertEquals('100', $parts[0]->getExtents()[0]->getEnd()->getValue()); - self::assertEquals(2, $parts[0]->getExtents()[0]->getTotal()); - } - - public function testGetNoPartsByQueryForBookDocument() - { - $parts = $this->bookReader->getParts('[@order="3"]'); - self::assertEmpty($parts); - - $firstPart = $this->bookReader->getFirstPart('[@order="3"]'); - self::assertNull($firstPart); - - $lastPart = $this->bookReader->getLastPart('[@order="3"]'); - self::assertNull($lastPart); - } - - public function testGetNoPartsForSerialDocument() - { - $parts = $this->serialReader->getParts(); - self::assertEmpty($parts); - } - - public function testGetPhysicalDescriptionsForBookDocument() - { - $physicalDescriptions = $this->bookReader->getPhysicalDescriptions(); - self::assertNotEmpty($physicalDescriptions); - self::assertEquals(1, count($physicalDescriptions)); - self::assertNotEmpty($physicalDescriptions[0]->getValue()); - self::assertNotEmpty($physicalDescriptions[0]->getForms()); - self::assertEquals('marcform', $physicalDescriptions[0]->getForms()[0]->getAuthority()); - self::assertEquals('print', $physicalDescriptions[0]->getForms()[0]->getValue()); - self::assertNotEmpty($physicalDescriptions[0]->getExtents()); - self::assertEquals('vii, 322 p. ; 23 cm.', $physicalDescriptions[0]->getExtents()[0]->getValue()); - self::assertNotEmpty($physicalDescriptions[0]->getReformattingQualities()); - self::assertEquals('replacement', $physicalDescriptions[0]->getReformattingQualities()[0]); - self::assertNotEmpty($physicalDescriptions[0]->getDigitalOrigins()); - self::assertEquals('born digital', $physicalDescriptions[0]->getDigitalOrigins()[0]); - self::assertEmpty($physicalDescriptions[0]->getNotes()); - - $firstPhysicalDescription = $this->bookReader->getFirstPhysicalDescription(); - self::assertEquals($physicalDescriptions[0], $firstPhysicalDescription); - - $lastPhysicalDescription = $this->bookReader->getLastPhysicalDescription(); - self::assertEquals($physicalDescriptions[0], $lastPhysicalDescription); - } - - public function testGetPhysicalDescriptionsByQueryForBookDocument() - { - $physicalDescriptions = $this->bookReader->getPhysicalDescriptions('[./mods:form[@authority="marcform"]="print"]'); - self::assertNotEmpty($physicalDescriptions); - self::assertEquals(1, count($physicalDescriptions)); - self::assertNotEmpty($physicalDescriptions[0]->getValue()); - self::assertNotEmpty($physicalDescriptions[0]->getForms()); - self::assertEquals('marcform', $physicalDescriptions[0]->getForms()[0]->getAuthority()); - self::assertEquals('print', $physicalDescriptions[0]->getForms()[0]->getValue()); - self::assertNotEmpty($physicalDescriptions[0]->getExtents()); - self::assertEquals('vii, 322 p. ; 23 cm.', $physicalDescriptions[0]->getExtents()[0]->getValue()); - self::assertNotEmpty($physicalDescriptions[0]->getReformattingQualities()); - self::assertEquals('replacement', $physicalDescriptions[0]->getReformattingQualities()[0]); - self::assertNotEmpty($physicalDescriptions[0]->getDigitalOrigins()); - self::assertEquals('born digital', $physicalDescriptions[0]->getDigitalOrigins()[0]); - self::assertEmpty($physicalDescriptions[0]->getNotes()); - } - - public function testGetNoPhysicalDescriptionsByQueryForBookDocument() - { - $physicalDescriptions = $this->bookReader->getPhysicalDescriptions('[./mods:form[@authority="marcform"]="electronic"]'); - self::assertEmpty($physicalDescriptions); - - $firstPhysicalDescription = $this->bookReader->getFirstPhysicalDescription('[./mods:form[@authority="marcform"]="electronic"]'); - self::assertNull($firstPhysicalDescription); - - $lastPhysicalDescription = $this->bookReader->getLastPhysicalDescription('[./mods:form[@authority="marcform"]="electronic"]'); - self::assertNull($lastPhysicalDescription); - } - - public function testGetPhysicalDescriptionsForSerialDocument() - { - $physicalDescriptions = $this->serialReader->getPhysicalDescriptions(); - self::assertNotEmpty($physicalDescriptions); - self::assertEquals(1, count($physicalDescriptions)); - self::assertNotEmpty($physicalDescriptions[0]->getValue()); - self::assertNotEmpty($physicalDescriptions[0]->getForms()); - self::assertEquals(2, count($physicalDescriptions[0]->getForms())); - self::assertEquals('gmd', $physicalDescriptions[0]->getForms()[1]->getAuthority()); - self::assertEquals('electronic resource', $physicalDescriptions[0]->getForms()[1]->getValue()); - self::assertNotEmpty($physicalDescriptions[0]->getInternetMediaTypes()); - self::assertEquals('text/html', $physicalDescriptions[0]->getInternetMediaTypes()[0]->getValue()); - self::assertEmpty($physicalDescriptions[0]->getExtents()); - self::assertEmpty($physicalDescriptions[0]->getReformattingQualities()); - self::assertEmpty($physicalDescriptions[0]->getDigitalOrigins()); - self::assertEmpty($physicalDescriptions[0]->getNotes()); - } - - public function testGetPhysicalDescriptionsByQueryForSerialDocument() - { - $physicalDescriptions = $this->serialReader->getPhysicalDescriptions('[./mods:form[@authority="marcform"]="electronic"]'); - self::assertNotEmpty($physicalDescriptions); - self::assertEquals(1, count($physicalDescriptions)); - self::assertNotEmpty($physicalDescriptions[0]->getValue()); - self::assertNotEmpty($physicalDescriptions[0]->getForms()); - self::assertEquals(2, count($physicalDescriptions[0]->getForms())); - self::assertEquals('gmd', $physicalDescriptions[0]->getForms()[1]->getAuthority()); - self::assertEquals('electronic resource', $physicalDescriptions[0]->getForms()[1]->getValue()); - self::assertNotEmpty($physicalDescriptions[0]->getInternetMediaTypes()); - self::assertEquals('text/html', $physicalDescriptions[0]->getInternetMediaTypes()[0]->getValue()); - self::assertEmpty($physicalDescriptions[0]->getExtents()); - self::assertEmpty($physicalDescriptions[0]->getReformattingQualities()); - self::assertEmpty($physicalDescriptions[0]->getDigitalOrigins()); - self::assertEmpty($physicalDescriptions[0]->getNotes()); - } - - public function testGetNoPhysicalDescriptionsByQueryForSerialDocument() - { - $physicalDescriptions = $this->serialReader->getPhysicalDescriptions('[./mods:form[@authority="marcform"]="print"]'); - self::assertEmpty($physicalDescriptions); - } - - public function testGetRecordInfosForBookDocument() - { - $recordInfos = $this->bookReader->getRecordInfos(); - self::assertNotEmpty($recordInfos); - self::assertEquals(1, count($recordInfos)); - self::assertNotEmpty($recordInfos[0]->getValue()); - 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()); - - $firstRecordInfo = $this->bookReader->getFirstRecordInfo(); - self::assertEquals($recordInfos[0], $firstRecordInfo); - - $lastRecordInfo = $this->bookReader->getLastRecordInfo(); - self::assertEquals($recordInfos[0], $lastRecordInfo); - } - - public function testGetRecordInfosByQueryForBookDocument() - { - $recordInfos = $this->bookReader->getRecordInfos('[./mods:descriptionStandard="aacr"]'); - self::assertNotEmpty($recordInfos); - self::assertEquals(1, count($recordInfos)); - self::assertNotEmpty($recordInfos[0]->getValue()); - 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() - { - $recordInfos = $this->bookReader->getRecordInfos('[./mods:descriptionStandard="xyz"]'); - self::assertEmpty($recordInfos); - - $firstRecordInfo = $this->bookReader->getFirstRecordInfo('[./mods:descriptionStandard="xyz"]'); - self::assertNull($firstRecordInfo); - - $lastRecordInfo = $this->bookReader->getLastRecordInfo('[./mods:descriptionStandard="xyz"]'); - self::assertNull($lastRecordInfo); - } - - public function testGetRecordInfosForSerialDocument() - { - $recordInfos = $this->serialReader->getRecordInfos(); - self::assertNotEmpty($recordInfos); - self::assertEquals(1, count($recordInfos)); - self::assertNotEmpty($recordInfos[0]->getValue()); - 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()); - - $this->expectException(IncorrectValueInAttributeException::class); - $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() - { - $recordInfos = $this->serialReader->getRecordInfos('[./mods:descriptionStandard="aacr"]'); - self::assertNotEmpty($recordInfos); - self::assertEquals(1, count($recordInfos)); - self::assertNotEmpty($recordInfos[0]->getValue()); - 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()); - - $this->expectException(IncorrectValueInAttributeException::class); - $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() - { - $recordInfos = $this->serialReader->getRecordInfos('[./mods:descriptionStandard="xyz"]'); - self::assertEmpty($recordInfos); - } - - public function testGetNoRelatedItemsForBookDocument() - { - $relatedItems = $this->bookReader->getRelatedItems(); - self::assertEmpty($relatedItems); - - $firstRelatedItem = $this->bookReader->getFirstRelatedItem(); - self::assertNull($firstRelatedItem); - - $lastRelatedItem = $this->bookReader->getLastRelatedItem(); - self::assertNull($lastRelatedItem); - } - - public function testGetRelatedItemsForSerialDocument() - { - $relatedItems = $this->serialReader->getRelatedItems(); - self::assertNotEmpty($relatedItems); - self::assertEquals(1, count($relatedItems)); - - $relatedItem = $relatedItems[0]; - self::assertNotEmpty($relatedItem->getType()); - self::assertEquals('preceding', $relatedItem->getType()); - self::assertNotEmpty($relatedItem->getTitleInfos()); - self::assertEquals('Journal of southern academic and special librarianship', $relatedItem->getTitleInfos()[0]->getTitle()->getValue()); - self::assertNotEmpty($relatedItem->getOriginInfos()); - //TODO: implement back compatibility for 'publisher' element - //self::assertEquals('Journal of southern academic and special librarianship', $relatedItem->getOriginInfos()[0]->getPublisher()); - self::assertNotEmpty($relatedItem->getIdentifiers()); - self::assertEquals(4, count($relatedItem->getIdentifiers())); - self::assertEquals('1525-321X', $relatedItem->getIdentifiers()[0]->getValue()); - - $localIdentifiers = $relatedItem->getIdentifiers('[@type="local"]'); - self::assertNotEmpty($localIdentifiers); - self::assertEquals(3, count($localIdentifiers)); - self::assertEquals('(OCoLC)41477508', $localIdentifiers[0]->getValue()); - - $firstRelatedItem = $this->serialReader->getFirstRelatedItem(); - self::assertEquals($relatedItem, $firstRelatedItem); - - $lastRelatedItem = $this->serialReader->getLastRelatedItem(); - self::assertEquals($relatedItem, $lastRelatedItem); - } - - public function testGetRelatedItemsByQueryForSerialDocument() - { - $relatedItems = $this->serialReader->getRelatedItems('[./mods:identifier="1525-321X"]'); - self::assertNotEmpty($relatedItems); - self::assertEquals(1, count($relatedItems)); - - $relatedItem = $relatedItems[0]; - self::assertNotEmpty($relatedItem->getType()); - self::assertEquals('preceding', $relatedItem->getType()); - self::assertNotEmpty($relatedItem->getTitleInfos()); - self::assertEquals('Journal of southern academic and special librarianship', $relatedItem->getTitleInfos()[0]->getTitle()->getValue()); - self::assertNotEmpty($relatedItem->getOriginInfos()); - //TODO: implement back compatibility for 'publisher' element - //self::assertEquals('Journal of southern academic and special librarianship', $relatedItem->getOriginInfos()[0]->getPublisher()); - self::assertNotEmpty($relatedItem->getIdentifiers()); - self::assertEquals(4, count($relatedItem->getIdentifiers())); - self::assertEquals('1525-321X', $relatedItem->getIdentifiers()[0]->getValue()); - - $localIdentifiers = $relatedItem->getIdentifiers('[@type="local"]'); - self::assertNotEmpty($localIdentifiers); - self::assertEquals(3, count($localIdentifiers)); - self::assertEquals('(OCoLC)41477508', $localIdentifiers[0]->getValue()); - } - - public function testGetNoRelatedItemsByQueryForSerialDocument() - { - $relatedItems = $this->serialReader->getRelatedItems('[./mods:identifier="15-32"]'); - self::assertEmpty($relatedItems); - } - - public function testGetSubjectsForBookDocument() - { - $subjects = $this->bookReader->getSubjects(); - self::assertNotEmpty($subjects); - self::assertEquals(8, count($subjects)); - self::assertNotEmpty($subjects[0]->getValue()); - $hierarchicalGeographics = $subjects[0]->getHierarchicalGeographics(); - self::assertNotEmpty($hierarchicalGeographics); - self::assertNotEmpty($hierarchicalGeographics[0]->getCountries()); - self::assertEquals(2, count($hierarchicalGeographics[0]->getCountries())); - self::assertEquals(1, $hierarchicalGeographics[0]->getCountries()[0]->getLevel()); - self::assertEquals('United Kingdom', $hierarchicalGeographics[0]->getCountries()[0]->getValue()); - self::assertNotEmpty($hierarchicalGeographics[0]->getRegions()); - self::assertEquals('North West', $hierarchicalGeographics[0]->getRegions()[0]->getValue()); - self::assertNotEmpty($hierarchicalGeographics[0]->getCounties()); - self::assertEquals('Cumbria', $hierarchicalGeographics[0]->getCounties()[0]->getValue()); - self::assertNotEmpty($hierarchicalGeographics[0]->getCities()); - self::assertEquals('Providence', $hierarchicalGeographics[0]->getCities()[0]->getValue()); - - $citySections = $hierarchicalGeographics[0]->getCitySections(); - self::assertNotEmpty($citySections); - self::assertEquals(2, count($citySections)); - self::assertEquals('neighborhood', $citySections[0]->getType()); - self::assertEquals(1, $citySections[0]->getLevel()); - self::assertEquals('East Side', $citySections[0]->getValue()); - - $areas = $hierarchicalGeographics[0]->getAreas(); - self::assertNotEmpty($areas); - self::assertEquals('national park', $areas[0]->getType()); - self::assertEquals('Lake District', $areas[0]->getValue()); - - $firstSubject = $this->bookReader->getFirstSubject(); - self::assertEquals($subjects[0], $firstSubject); - - $lastSubject = $this->bookReader->getLastSubject(); - self::assertEquals($subjects[7], $lastSubject); - } - - public function testGetSubjectsByQueryForBookDocument() - { - $subjects = $this->bookReader->getSubjects('[./mods:topic="Mass media"]'); - self::assertNotEmpty($subjects); - self::assertEquals(1, count($subjects)); - self::assertNotEmpty($subjects[0]->getAuthority()); - self::assertEquals('lcsh', $subjects[0]->getAuthority()); - self::assertNotEmpty($subjects[0]->getValue()); - self::assertNotEmpty($subjects[0]->getTopics()); - self::assertEquals(2, count($subjects[0]->getTopics())); - self::assertEquals('Political aspects', $subjects[0]->getTopics()[1]->getValue()); - self::assertNotEmpty($subjects[0]->getGeographics()); - self::assertEquals(1, count($subjects[0]->getGeographics())); - self::assertEquals('United States', $subjects[0]->getGeographics()[0]->getValue()); - } - - public function testGetNoSubjectsByQueryForBookDocument() - { - $subjects = $this->bookReader->getSubjects('[./mods:topic="Unknown"]'); - self::assertEmpty($subjects); - - $firstSubject = $this->bookReader->getFirstSubject('[./mods:topic="Unknown"]'); - self::assertNull($firstSubject); - - $lastSubject = $this->bookReader->getLastSubject('[./mods:topic="Unknown"]'); - self::assertNull($lastSubject); - } - - public function testGetSubjectsForSerialDocument() - { - $subjects = $this->serialReader->getSubjects(); - self::assertNotEmpty($subjects); - self::assertEquals(7, count($subjects)); - self::assertNotEmpty($subjects[0]->getValue()); - self::assertNotEmpty($subjects[0]->getCartographics()); - - // TODO: implement reading of cartographics - /*self::assertNotEmpty($subjects[0]->getCartographics()[0]->getCoordinates()); - self::assertEquals('', $subjects[0]->getCartographics()[0]->getCoordinates()[0]->getValue()); - self::assertNotEmpty($subjects[0]->getCartographics()[0]->getScale()); - self::assertNotEmpty($subjects[0]->getCartographics()[0]->getProjection());*/ - } - - public function testGetSubjectsByQueryForSerialDocument() - { - $subjects = $this->serialReader->getSubjects('[./mods:genre="Directories"]'); - self::assertNotEmpty($subjects); - self::assertEquals(1, count($subjects)); - self::assertNotEmpty($subjects[0]->getValue()); - self::assertNotEmpty($subjects[0]->getTopics()); - self::assertEquals('Web sites', $subjects[0]->getTopics()[0]->getValue()); - self::assertNotEmpty($subjects[0]->getGenres()); - self::assertEquals('Directories', $subjects[0]->getGenres()[0]->getValue()); - } - - public function testGetNoSubjectsByQueryForSerialDocument() - { - $subjects = $this->serialReader->getSubjects('[./mods:topic="Unknown"]'); - self::assertEmpty($subjects); - } - - public function testGetTableOfContentsForBookDocument() - { - $tableOfContents = $this->bookReader->getTableOfContents(); - self::assertNotEmpty($tableOfContents); - self::assertEquals(1, count($tableOfContents)); - self::assertNotEmpty($tableOfContents[0]->getValue()); - self::assertEquals('Bluegrass odyssey -- Hills of Tennessee -- Sassafrass -- Muddy river -- Take your shoes off Moses -- Let Smokey Mountain smoke get in your eyes -- Farewell party -- Faded love', $tableOfContents[0]->getValue()); - self::assertNotEmpty($tableOfContents[0]->getDisplayLabel()); - self::assertEquals('Chapters', $tableOfContents[0]->getDisplayLabel()); - - // TODO: implement reading of elements - } - - public function testGetTableOfContentsByQueryForBookDocument() - { - $tableOfContents = $this->bookReader->getTableOfContents('[@displayLabel="Chapters"]'); - self::assertNotEmpty($tableOfContents); - self::assertEquals(1, count($tableOfContents)); - self::assertNotEmpty($tableOfContents[0]->getValue()); - self::assertEquals('Bluegrass odyssey -- Hills of Tennessee -- Sassafrass -- Muddy river -- Take your shoes off Moses -- Let Smokey Mountain smoke get in your eyes -- Farewell party -- Faded love', $tableOfContents[0]->getValue()); - self::assertNotEmpty($tableOfContents[0]->getDisplayLabel()); - self::assertEquals('Chapters', $tableOfContents[0]->getDisplayLabel()); - - // TODO: implement reading of elements - } - - public function testGetNoTableOfContentsByQueryForBookDocument() - { - $tableOfContents = $this->bookReader->getTableOfContents('[@displayLabel="Pages"]'); - self::assertEmpty($tableOfContents); - } - - public function testGetNoTableOfContentsForSerialDocument() - { - $tableOfContents = $this->serialReader->getTableOfContents(); - self::assertEmpty($tableOfContents); - } - - public function testGetTitleInfosForBookDocument() - { - $titleInfos = $this->bookReader->getTitleInfos(); - self::assertNotEmpty($titleInfos); - self::assertEquals(2, count($titleInfos)); - self::assertNotEmpty($titleInfos[0]->getValue()); - self::assertEquals('Sound and fury', $titleInfos[0]->getTitle()->getValue()); - self::assertEquals('the making of the punditocracy', $titleInfos[0]->getSubTitle()->getValue()); - } - - public function testGetTitleInfosByQueryForBookDocument() - { - $titleInfos = $this->bookReader->getTitleInfos('[@xml:lang="fr"]'); - self::assertNotEmpty($titleInfos); - self::assertEquals(1, count($titleInfos)); - self::assertNotEmpty($titleInfos[0]->getValue()); - self::assertNotEmpty($titleInfos[0]->getType()); - self::assertEquals('translated', $titleInfos[0]->getType()); - self::assertNotEmpty($titleInfos[0]->getNonSort()); - self::assertEquals('Le', $titleInfos[0]->getNonSort()->getValue()); - self::assertNotEmpty($titleInfos[0]->getTitle()); - self::assertEquals('bruit et la fureur', $titleInfos[0]->getTitle()->getValue()); - self::assertNotEmpty($titleInfos[0]->getSubTitle()); - self::assertEquals('la création de la punditocratie', $titleInfos[0]->getSubTitle()->getValue()); - } - - public function testGetTitleInfosForSerialDocument() - { - $titleInfos = $this->serialReader->getTitleInfos(); - self::assertNotEmpty($titleInfos); - self::assertEquals(3, count($titleInfos)); - self::assertNotEmpty($titleInfos[0]->getValue()); - self::assertNotEmpty($titleInfos[0]->getTitle()); - self::assertEquals('E-JASL', $titleInfos[0]->getTitle()->getValue()); - self::assertNotEmpty($titleInfos[0]->getSubTitle()); - self::assertEquals('the electronic journal of academic and special librarianship', $titleInfos[0]->getSubTitle()->getValue()); - } - - public function testGetTitleInfosByQueryForSerialDocument() - { - $titleInfos = $this->serialReader->getTitleInfos('[@type="abbreviated"]'); - self::assertNotEmpty($titleInfos); - self::assertEquals(1, count($titleInfos)); - self::assertNotEmpty($titleInfos[0]->getValue()); - self::assertEquals('E-JASL', $titleInfos[0]->getTitle()->getValue()); - self::assertNotEmpty($titleInfos[0]->getSubTitle()); - self::assertEquals('(Athabasca)', $titleInfos[0]->getSubTitle()->getValue()); - } - - public function testGetNoTitleInfosByQueryForSerialDocument() - { - $titleInfos = $this->serialReader->getTitleInfos('[@type="uniform"]'); - self::assertEmpty($titleInfos); - } - - public function testGetTypeOfResourceForBookDocument() - { - $typeOfResource = $this->bookReader->getTypeOfResource(); - self::assertNotNull($typeOfResource); - self::assertNotEmpty($typeOfResource->getDisplayLabel()); - self::assertEquals('format', $typeOfResource->getDisplayLabel()); - self::assertNotEmpty($typeOfResource->getValue()); - self::assertEquals('text', $typeOfResource->getValue()); - } - - public function testGetTypeOfResourceByQueryForBookDocument() - { - $typeOfResource = $this->bookReader->getTypeOfResource('[@displayLabel="format"]'); - self::assertNotNull($typeOfResource); - self::assertNotEmpty($typeOfResource->getDisplayLabel()); - self::assertEquals('format', $typeOfResource->getDisplayLabel()); - self::assertNotEmpty($typeOfResource->getValue()); - self::assertEquals('text', $typeOfResource->getValue()); - } - - public function testGetNoTypeOfResourceByQueryForBookDocument() - { - $typeOfResource = $this->bookReader->getTypeOfResource('[@displayLabel="random"]'); - self::assertNull($typeOfResource); - } - - public function testGetTypeOfResourceForSerialDocument() - { - $typeOfResource = $this->serialReader->getTypeOfResource(); - self::assertNotNull($typeOfResource); - self::assertEmpty($typeOfResource->getDisplayLabel()); - self::assertNotEmpty($typeOfResource->getValue()); - self::assertEquals('text', $typeOfResource->getValue()); - } - - public function testGetNoTypeOfResourceByQueryForSerialDocument() - { - $abstract = $this->serialReader->getAbstract('[@displayForm="format"]'); - self::assertNull($abstract); - } } diff --git a/tests/Mods/Reader/AbstractReaderTest.php b/tests/Mods/Reader/AbstractReaderTest.php new file mode 100644 index 0000000..8ebfd6f --- /dev/null +++ b/tests/Mods/Reader/AbstractReaderTest.php @@ -0,0 +1,94 @@ +bookReader->getAbstract(); + self::assertNotNull($abstract); + self::assertNotEmpty($abstract->getDisplayLabel()); + self::assertEquals('Content description', $abstract->getDisplayLabel()); + self::assertNotEmpty($abstract->getValue()); + self::assertEquals('Test description for document which contains display label.', $abstract->getValue()); + self::assertTrue($abstract->isShareable()); + } + + /** + * @test + */ + public function getAbstractByQueryForBookDocument() + { + $abstract = $this->bookReader->getAbstract('[@displayLabel="Content description"]'); + self::assertNotNull($abstract); + self::assertNotEmpty($abstract->getDisplayLabel()); + self::assertEquals('Content description', $abstract->getDisplayLabel()); + self::assertNotEmpty($abstract->getValue()); + self::assertEquals('Test description for document which contains display label.', $abstract->getValue()); + self::assertTrue($abstract->isShareable()); + } + + /** + * @test + */ + public function getNoAbstractByQueryForBookDocument() + { + $abstract = $this->bookReader->getAbstract('[@displayLabel="Random"]'); + self::assertNull($abstract); + } + + /** + * @test + */ + public function getAbstractForSerialDocument() + { + $abstract = $this->serialReader->getAbstract(); + self::assertNotNull($abstract); + self::assertEmpty($abstract->getDisplayLabel()); + self::assertNotEmpty($abstract->getValue()); + self::assertEquals('Test description for non shareable document.', $abstract->getValue()); + self::assertFalse($abstract->isShareable()); + } + + /** + * @test + */ + public function getAbstractByQueryForSerialDocument() + { + $abstract = $this->serialReader->getAbstract('[@shareable="no"]'); + self::assertNotNull($abstract); + self::assertEmpty($abstract->getDisplayLabel()); + self::assertNotEmpty($abstract->getValue()); + self::assertEquals('Test description for non shareable document.', $abstract->getValue()); + self::assertFalse($abstract->isShareable()); + } + + /** + * @test + */ + public function getNoAbstractByQueryForSerialDocument() + { + $abstract = $this->serialReader->getAbstract('[@shareable="yes"]'); + self::assertNull($abstract); + } +} diff --git a/tests/Mods/Reader/AccessConditionReaderTest.php b/tests/Mods/Reader/AccessConditionReaderTest.php new file mode 100644 index 0000000..10afdbe --- /dev/null +++ b/tests/Mods/Reader/AccessConditionReaderTest.php @@ -0,0 +1,179 @@ +bookReader->getAccessConditions(); + self::assertNotEmpty($accessConditions); + self::assertEquals(1, count($accessConditions)); + self::assertAccessConditionForBookDocument($accessConditions[0]); + } + + /** + * @test + */ + public function getAccessConditionForBookDocument() + { + $accessCondition = $this->bookReader->getAccessCondition(0); + self::assertAccessConditionForBookDocument($accessCondition); + } + + /** + * @test + */ + public function getFirstAccessConditionForBookDocument() + { + $accessCondition = $this->bookReader->getFirstAccessCondition(); + self::assertAccessConditionForBookDocument($accessCondition); + } + + /** + * @test + */ + public function getLastAccessConditionForBookDocument() + { + $accessCondition = $this->bookReader->getLastAccessCondition(); + self::assertAccessConditionForBookDocument($accessCondition); + } + + /** + * @test + */ + public function getAccessConditionsByQueryForBookDocument() + { + $accessConditions = $this->bookReader->getAccessConditions('[@type="use and reproduction"]'); + self::assertNotEmpty($accessConditions); + self::assertEquals(1, count($accessConditions)); + self::assertAccessConditionForBookDocument($accessConditions[0]); + } + + /** + * @test + */ + public function getFirstAccessConditionByQueryForBookDocument() + { + $accessCondition = $this->bookReader->getFirstAccessCondition('[@type="use and reproduction"]'); + self::assertAccessConditionForBookDocument($accessCondition); + } + + /** + * @test + */ + public function getLastAccessConditionByQueryForBookDocument() + { + $accessCondition = $this->bookReader->getLastAccessCondition('[@type="use and reproduction"]'); + self::assertAccessConditionForBookDocument($accessCondition); + } + + /** + * @test + */ + public function getNoAccessConditionsByQueryForBookDocument() + { + $accessConditions = $this->bookReader->getAccessConditions('[@type="restriction on access"]'); + self::assertEmpty($accessConditions); + } + + /** + * @test + */ + public function getNoAccessConditionByQueryForBookDocument() + { + $accessCondition = $this->bookReader->getAccessCondition(1, '[@type="restriction on access"]'); + self::assertNull($accessCondition); + } + + /** + * @test + */ + public function getNoFirstAccessConditionsByQueryForBookDocument() + { + $accessCondition = $this->bookReader->getFirstAccessCondition('[@type="restriction on access"]'); + self::assertNull($accessCondition); + } + + /** + * @test + */ + public function getNoLastAccessConditionsByQueryForBookDocument() + { + $accessCondition = $this->bookReader->getLastAccessCondition('[@type="restriction on access"]'); + self::assertNull($accessCondition); + } + + /** + * @test + */ + public function getAccessConditionsForSerialDocument() + { + $accessConditions = $this->serialReader->getAccessConditions(); + self::assertNotEmpty($accessConditions); + self::assertEquals(1, count($accessConditions)); + self::assertAccessConditionForSerialDocument($accessConditions[0]); + } + + /** + * @test + */ + public function getAccessConditionsByQueryForSerialDocument() + { + $accessConditions = $this->serialReader->getAccessConditions('[@type="restriction on access"]'); + self::assertNotEmpty($accessConditions); + self::assertEquals(1, count($accessConditions)); + self::assertAccessConditionForSerialDocument($accessConditions[0]); + } + + /** + * @test + */ + public function getNoAccessConditionsByQueryForSerialDocument() + { + $accessConditions = $this->serialReader->getAccessConditions('[@type="use and reproduction"]'); + self::assertEmpty($accessConditions); + } + + private static function assertAccessConditionForBookDocument(AccessCondition $accessCondition) + { + self::assertNotEmpty($accessCondition->getValue()); + self::assertEquals('Use of this public-domain resource is unrestricted.', $accessCondition->getValue()); + self::assertNotEmpty($accessCondition->getType()); + self::assertEquals('use and reproduction', $accessCondition->getType()); + self::assertEmpty($accessCondition->getDisplayLabel()); + self::assertEmpty($accessCondition->getXlinkHref()); + } + + private static function assertAccessConditionForSerialDocument(AccessCondition $accessCondition) + { + self::assertNotEmpty($accessCondition->getValue()); + self::assertEquals('Open Access', $accessCondition->getValue()); + self::assertNotEmpty($accessCondition->getType()); + self::assertEquals('restriction on access', $accessCondition->getType()); + self::assertNotEmpty($accessCondition->getDisplayLabel()); + self::assertEquals('Access Status', $accessCondition->getDisplayLabel()); + // TODO: check out xlink + // self::assertEquals('http://purl.org/eprint/accessRights/OpenAccess', $accessCondition->getXlinkHref()); + } +} diff --git a/tests/Mods/Reader/ClassificationReaderTest.php b/tests/Mods/Reader/ClassificationReaderTest.php new file mode 100644 index 0000000..36058f1 --- /dev/null +++ b/tests/Mods/Reader/ClassificationReaderTest.php @@ -0,0 +1,174 @@ +bookReader->getClassifications(); + self::assertNotEmpty($classifications); + self::assertEquals(2, count($classifications)); + self::assertFirstClassificationForBookDocument($classifications[0]); + } + + /** + * @test + */ + public function getClassificationForBookDocument() + { + $classification = $this->bookReader->getClassification(0); + self::assertFirstClassificationForBookDocument($classification); + } + + /** + * @test + */ + public function getFirstClassificationForBookDocument() + { + $classification = $this->bookReader->getFirstClassification(); + self::assertFirstClassificationForBookDocument($classification); + } + + /** + * @test + */ + public function getLastClassificationForBookDocument() + { + $classification = $this->bookReader->getLastClassification(); + self::assertSecondClassificationForBookDocument($classification); + } + + /** + * @test + */ + public function getClassificationsByQueryForBookDocument() + { + $classifications = $this->bookReader->getClassifications('[@authority="ddc"]'); + self::assertNotEmpty($classifications); + self::assertEquals(1, count($classifications)); + self::assertSecondClassificationForBookDocument($classifications[0]); + } + + /** + * @test + */ + public function getNoClassificationsByQueryForBookDocument() + { + $classifications = $this->bookReader->getClassifications('[@generator="xyz"]'); + self::assertEmpty($classifications); + } + + /** + * @test + */ + public function getNoClassificationByQueryForBookDocument() + { + $classification = $this->bookReader->getClassification(1, '[@generator="xyz"]'); + self::assertNull($classification); + } + + /** + * @test + */ + public function getNoFirstClassificationByQueryForBookDocument() + { + $classification = $this->bookReader->getFirstClassification('[@generator="xyz"]'); + self::assertNull($classification); + + $lastClassification = $this->bookReader->getLastClassification('[@generator="xyz"]'); + self::assertNull($lastClassification); + } + + /** + * @test + */ + public function getNoLastClassificationByQueryForBookDocument() + { + $classification = $this->bookReader->getLastClassification('[@generator="xyz"]'); + self::assertNull($classification); + } + + /** + * @test + */ + public function getClassificationsForSerialDocument() + { + $classifications = $this->serialReader->getClassifications(); + self::assertNotEmpty($classifications); + self::assertEquals(1, count($classifications)); + self::assertClassificationForSerialDocument($classifications[0]); + } + + /** + * @test + */ + public function getClassificationsByQueryForSerialDocument() + { + $classifications = $this->serialReader->getClassifications('[@authority="ddc"]'); + self::assertNotEmpty($classifications); + self::assertEquals(1, count($classifications)); + self::assertClassificationForSerialDocument($classifications[0]); + } + + /** + * @test + */ + public function getNoClassificationsByQueryForSerialDocument() + { + $classifications = $this->serialReader->getClassifications('[@edition="22"]'); + self::assertEmpty($classifications); + } + + private static function assertFirstClassificationForBookDocument(Classification $classification) + { + self::assertNotEmpty($classification->getValue()); + self::assertEquals('PN4888.P6 A48 1999', $classification->getValue()); + self::assertNotEmpty($classification->getAuthority()); + self::assertEquals('lcc', $classification->getAuthority()); + self::assertEmpty($classification->getId()); + self::assertEmpty($classification->getUsage()); + } + + private static function assertSecondClassificationForBookDocument(Classification $classification) + { + self::assertNotEmpty($classification->getValue()); + self::assertEquals('071/.3', $classification->getValue()); + self::assertNotEmpty($classification->getEdition()); + self::assertEquals('21', $classification->getEdition()); + self::assertEmpty($classification->getDisplayLabel()); + self::assertEmpty($classification->getGenerator()); + } + + private static function assertClassificationForSerialDocument(Classification $classification) + { + self::assertNotEmpty($classification->getValue()); + self::assertEquals('027.7/05', $classification->getValue()); + self::assertNotEmpty($classification->getAuthority()); + self::assertEquals('ddc', $classification->getAuthority()); + self::assertNotEmpty($classification->getEdition()); + self::assertEquals('21', $classification->getEdition()); + self::assertEmpty($classification->getDisplayLabel()); + self::assertEmpty($classification->getGenerator()); + } +} diff --git a/tests/Mods/Reader/ExtensionReaderTest.php b/tests/Mods/Reader/ExtensionReaderTest.php new file mode 100644 index 0000000..0149773 --- /dev/null +++ b/tests/Mods/Reader/ExtensionReaderTest.php @@ -0,0 +1,40 @@ +bookReader->getExtensions(); + $this->assertTrue(true, 'WIP'); + } + + /** + * @test + */ + public function getExtensionsForSerialDocument() + { + // $extensions = $this->serialReader->getExtensions(); + $this->assertTrue(true, 'WIP'); + } +} diff --git a/tests/Mods/Reader/GenreReaderTest.php b/tests/Mods/Reader/GenreReaderTest.php new file mode 100644 index 0000000..056092b --- /dev/null +++ b/tests/Mods/Reader/GenreReaderTest.php @@ -0,0 +1,222 @@ +bookReader->getGenres(); + self::assertNotEmpty($genres); + self::assertEquals(1, count($genres)); + self::assertGenreForBookDocument($genres[0]); + } + + /** + * @test + */ + public function getGenreForBookDocument() + { + $genre = $this->bookReader->getGenre(0); + self::assertGenreForBookDocument($genre); + } + + /** + * @test + */ + public function getFirstGenreForBookDocument() + { + $genre = $this->bookReader->getFirstGenre(); + self::assertGenreForBookDocument($genre); + } + + /** + * @test + */ + public function getLastGenreForBookDocument() + { + $genre = $this->bookReader->getLastGenre(); + self::assertGenreForBookDocument($genre); + } + + /** + * @test + */ + public function getGenresByQueryForBookDocument() + { + $genres = $this->bookReader->getGenres('[@authority="marcgt"]'); + self::assertNotEmpty($genres); + self::assertEquals(1, count($genres)); + self::assertGenreForBookDocument($genres[0]); + } + + /** + * @test + */ + public function getGenreByQueryForBookDocument() + { + $genre = $this->bookReader->getGenre(0, '[@authority="marcgt"]'); + self::assertGenreForBookDocument($genre); + } + + /** + * @test + */ + public function getFirstGenreByQueryForBookDocument() + { + $genre = $this->bookReader->getFirstGenre('[@authority="marcgt"]'); + self::assertGenreForBookDocument($genre); + } + + /** + * @test + */ + public function getLastGenreByQueryForBookDocument() + { + $genre = $this->bookReader->getLastGenre('[@authority="marcgt"]'); + self::assertGenreForBookDocument($genre); + } + + /** + * @test + */ + public function getNoGenresByQueryForBookDocument() + { + $genres = $this->bookReader->getGenres('[@authority="merc"]'); + self::assertEmpty($genres); + } + + /** + * @test + */ + public function getNoGenreByQueryForBookDocument() + { + $genre = $this->bookReader->getGenre(0, '[@authority="merc"]'); + self::assertNull($genre); + } + + /** + * @test + */ + public function getNoFirstGenreByQueryForBookDocument() + { + $genre = $this->bookReader->getFirstGenre('[@authority="merc"]'); + self::assertNull($genre); + } + + /** + * @test + */ + public function getNoLastGenreByQueryForBookDocument() + { + $genre = $this->bookReader->getLastGenre('[@authority="merc"]'); + self::assertNull($genre); + } + + /** + * @test + */ + public function getGenresForSerialDocument() + { + $genres = $this->serialReader->getGenres(); + self::assertNotEmpty($genres); + self::assertEquals(2, count($genres)); + self::assertFirstGenreForSerialDocument($genres[0]); + } + + /** + * @test + */ + public function getGenreForSerialDocument() + { + $genre = $this->serialReader->getGenre(0); + self::assertFirstGenreForSerialDocument($genre); + } + + /** + * @test + */ + public function getFirstGenreForSerialDocument() + { + $genre = $this->serialReader->getFirstGenre(); + self::assertFirstGenreForSerialDocument($genre); + } + + /** + * @test + */ + public function getLastGenreForSerialDocument() + { + $genre = $this->serialReader->getLastGenre(); + self::assertSecondGenreForSerialDocument($genre); + } + + /** + * @test + */ + public function getGenresByQueryForSerialDocument() + { + $genres = $this->serialReader->getGenres('[@usage="primary"]'); + self::assertNotEmpty($genres); + self::assertEquals(1, count($genres)); + self::assertFirstGenreForSerialDocument($genres[0]); + } + + /** + * @test + */ + public function getNoGenresByQueryForSerialDocument() + { + $genres = $this->serialReader->getGenres('[@type="xyz"]'); + self::assertEmpty($genres); + } + + private static function assertGenreForBookDocument(Genre $genre) + { + self::assertNotEmpty($genre->getValue()); + self::assertEquals('bibliography', $genre->getValue()); + self::assertNotEmpty($genre->getAuthority()); + self::assertEquals('marcgt', $genre->getAuthority()); + self::assertEmpty($genre->getLang()); + self::assertEmpty($genre->getScript()); + } + + private static function assertFirstGenreForSerialDocument(Genre $genre) + { + self::assertNotEmpty($genre->getValue()); + self::assertEquals('periodical', $genre->getValue()); + self::assertNotEmpty($genre->getUsage()); + self::assertEquals('primary', $genre->getUsage()); + self::assertEmpty($genre->getDisplayLabel()); + self::assertEmpty($genre->getTransliteration()); + } + + private static function assertSecondGenreForSerialDocument(Genre $genre) + { + self::assertNotEmpty($genre->getValue()); + self::assertEquals('series', $genre->getValue()); + self::assertEmpty($genre->getUsage()); + self::assertEmpty($genre->getDisplayLabel()); + self::assertEmpty($genre->getTransliteration()); + } +} diff --git a/tests/Mods/Reader/IdentifierReaderTest.php b/tests/Mods/Reader/IdentifierReaderTest.php new file mode 100644 index 0000000..6977cd7 --- /dev/null +++ b/tests/Mods/Reader/IdentifierReaderTest.php @@ -0,0 +1,313 @@ +bookReader->getIdentifiers(); + self::assertNotEmpty($identifiers); + self::assertEquals(2, count($identifiers)); + self::assertFirstIdentifierForBookDocument($identifiers[0]); + } + + /** + * @test + */ + public function getIdentifierForBookDocument() + { + $identifier = $this->bookReader->getIdentifier(0); + self::assertFirstIdentifierForBookDocument($identifier); + } + + /** + * @test + */ + public function getFirstIdentifierForBookDocument() + { + $identifier = $this->bookReader->getFirstIdentifier(); + self::assertFirstIdentifierForBookDocument($identifier); + } + + /** + * @test + */ + public function getLastIdentifierForBookDocument() + { + $identifier = $this->bookReader->getLastIdentifier(); + self::assertSecondIdentifierForBookDocument($identifier); + } + + /** + * @test + */ + public function getIdentifiersByQueryForBookDocument() + { + $identifiers = $this->bookReader->getIdentifiers('[@type="lccn"]'); + self::assertNotEmpty($identifiers); + self::assertEquals(1, count($identifiers)); + self::assertSecondIdentifierForBookDocument($identifiers[0]); + } + + /** + * @test + */ + public function getIdentifierByQueryForBookDocument() + { + $identifier = $this->bookReader->getIdentifier(0, '[@type="lccn"]'); + self::assertSecondIdentifierForBookDocument($identifier); + } + + /** + * @test + */ + public function getFirstIdentifierByQueryForBookDocument() + { + $identifier = $this->bookReader->getFirstIdentifier('[@type="lccn"]'); + self::assertSecondIdentifierForBookDocument($identifier); + } + + /** + * @test + */ + public function getLastIdentifierByQueryForBookDocument() + { + $identifier = $this->bookReader->getLastIdentifier('[@type="lccn"]'); + self::assertSecondIdentifierForBookDocument($identifier); + } + + /** + * @test + */ + public function getNoIdentifiersByQueryForBookDocument() + { + $identifiers = $this->bookReader->getIdentifiers('[@type="xyz"]'); + self::assertEmpty($identifiers); + } + + /** + * @test + */ + public function getNoIdentifierByQueryForBookDocument() + { + $identifier = $this->bookReader->getIdentifier(5, '[@type="lccn"]'); + self::assertNull($identifier); + } + + /** + * @test + */ + public function getNoFirstIdentifierByQueryForBookDocument() + { + $identifier = $this->bookReader->getFirstIdentifier('[@type="xyz"]'); + self::assertNull($identifier); + } + + /** + * @test + */ + public function getNoLastIdentifierByQueryForBookDocument() + { + $identifier = $this->bookReader->getLastIdentifier('[@type="xyz"]'); + self::assertNull($identifier); + } + + /** + * @test + */ + public function getIdentifiersForSerialDocument() + { + $identifiers = $this->serialReader->getIdentifiers(); + self::assertNotEmpty($identifiers); + self::assertEquals(4, count($identifiers)); + self::assertFirstIdentifierForSerialDocument($identifiers[0]); + } + + /** + * @test + */ + public function getIdentifierForSerialDocument() + { + $identifier = $this->serialReader->getIdentifier(2); + self::assertThirdIdentifierForSerialDocument($identifier); + } + + /** + * @test + */ + public function getFirstIdentifierForSerialDocument() + { + $identifier = $this->serialReader->getFirstIdentifier(); + self::assertFirstIdentifierForSerialDocument($identifier); + } + + /** + * @test + */ + public function getLastIdentifierForSerialDocument() + { + $identifier = $this->serialReader->getLastIdentifier(); + self::assertFourthIdentifierForSerialDocument($identifier); + } + + /** + * @test + */ + public function getIdentifiersByQueryForSerialDocument() + { + $identifiers = $this->serialReader->getIdentifiers('[@type="issn"]'); + self::assertNotEmpty($identifiers); + self::assertEquals(2, count($identifiers)); + self::assertSecondIdentifierForSerialDocument($identifiers[1]); + } + + /** + * @test + */ + public function getIdentifierByQueryForSerialDocument() + { + $identifier = $this->serialReader->getIdentifier(0, '[@type="issn"]'); + self::assertFirstIdentifierForSerialDocument($identifier); + } + + /** + * @test + */ + public function getFirstIdentifierByQueryForSerialDocument() + { + $identifier = $this->serialReader->getFirstIdentifier('[@type="lccn"]'); + self::assertThirdIdentifierForSerialDocument($identifier); + } + + /** + * @test + */ + public function getLastIdentifierByQueryForSerialDocument() + { + $identifier = $this->serialReader->getLastIdentifier('[@type="lccn"]'); + self::assertThirdIdentifierForSerialDocument($identifier); + } + + /** + * @test + */ + public function getNoIdentifiersByQueryForSerialDocument() + { + $identifiers = $this->serialReader->getIdentifiers('[@type="xyz"]'); + self::assertEmpty($identifiers); + } + + /** + * @test + */ + public function getNoIdentifierByQueryForSerialDocument() + { + $identifier = $this->serialReader->getIdentifier(2, '[@type="xyz"]'); + self::assertNull($identifier); + } + + /** + * @test + */ + public function getNoFirstIdentifierByQueryForSerialDocument() + { + $identifier = $this->serialReader->getFirstIdentifier('[@type="xyz"]'); + self::assertNull($identifier); + } + + /** + * @test + */ + public function getNoLastIdentifierByQueryForSerialDocument() + { + $identifier = $this->serialReader->getLastIdentifier('[@type="xyz"]'); + self::assertNull($identifier); + } + + private static function assertFirstIdentifierForBookDocument(Identifier $identifier) + { + self::assertNotEmpty($identifier->getValue()); + self::assertEquals('0801486394 (pbk. : acid-free, recycled paper)', $identifier->getValue()); + self::assertNotEmpty($identifier->getType()); + self::assertEquals('isbn', $identifier->getType()); + self::assertEmpty($identifier->getDisplayLabel()); + self::assertEmpty($identifier->getLang()); + self::assertFalse($identifier->isInvalid()); + } + + private static function assertSecondIdentifierForBookDocument(Identifier $identifier) + { + self::assertNotEmpty($identifier->getValue()); + self::assertEquals('99042030', $identifier->getValue()); + self::assertNotEmpty($identifier->getType()); + self::assertEquals('lccn', $identifier->getType()); + self::assertEmpty($identifier->getDisplayLabel()); + self::assertEmpty($identifier->getLang()); + self::assertFalse($identifier->isInvalid()); + } + + private static function assertFirstIdentifierForSerialDocument(Identifier $identifier) + { + self::assertNotEmpty($identifier->getValue()); + self::assertEquals('1704-8532', $identifier->getValue()); + self::assertNotEmpty($identifier->getType()); + self::assertEquals('issn', $identifier->getType()); + self::assertEmpty($identifier->getDisplayLabel()); + self::assertEmpty($identifier->getLang()); + self::assertFalse($identifier->isInvalid()); + } + + private static function assertSecondIdentifierForSerialDocument(Identifier $identifier) + { + self::assertNotEmpty($identifier->getValue()); + self::assertEquals('1525-321X', $identifier->getValue()); + self::assertNotEmpty($identifier->getType()); + self::assertEquals('issn', $identifier->getType()); + self::assertEmpty($identifier->getDisplayLabel()); + self::assertEmpty($identifier->getLang()); + self::assertTrue($identifier->isInvalid()); + } + + private static function assertThirdIdentifierForSerialDocument(Identifier $identifier) + { + self::assertNotEmpty($identifier->getValue()); + self::assertEquals('cn2002301668', $identifier->getValue()); + self::assertNotEmpty($identifier->getType()); + self::assertEquals('lccn', $identifier->getType()); + self::assertEmpty($identifier->getDisplayLabel()); + self::assertEmpty($identifier->getLang()); + self::assertFalse($identifier->isInvalid()); + } + + private static function assertFourthIdentifierForSerialDocument(Identifier $identifier) + { + self::assertNotEmpty($identifier->getValue()); + self::assertEquals('ocm51090366', $identifier->getValue()); + self::assertNotEmpty($identifier->getType()); + self::assertEquals('oclc', $identifier->getType()); + self::assertEmpty($identifier->getDisplayLabel()); + self::assertEmpty($identifier->getLang()); + self::assertFalse($identifier->isInvalid()); + } +} diff --git a/tests/Mods/Reader/LanguageReaderTest.php b/tests/Mods/Reader/LanguageReaderTest.php new file mode 100644 index 0000000..f3dd2c4 --- /dev/null +++ b/tests/Mods/Reader/LanguageReaderTest.php @@ -0,0 +1,220 @@ +bookReader->getLanguages(); + self::assertNotEmpty($languages); + self::assertEquals(2, count($languages)); + self::assertFirstLanguageForBookDocument($languages[0]); + } + + /** + * @test + */ + public function getLanguageForBookDocument() + { + $language = $this->bookReader->getLanguage(0); + self::assertFirstLanguageForBookDocument($language); + } + + /** + * @test + */ + public function getFirstLanguageForBookDocument() + { + $language = $this->bookReader->getFirstLanguage(); + self::assertFirstLanguageForBookDocument($language); + } + + /** + * @test + */ + public function getLastLanguageForBookDocument() + { + $language = $this->bookReader->getLastLanguage(); + self::assertSecondLanguageForBookDocument($language); + } + + /** + * @test + */ + public function getLanguagesByQueryForBookDocument() + { + $languages = $this->bookReader->getLanguages('[@objectPart="summary"]'); + self::assertNotEmpty($languages); + self::assertEquals(1, count($languages)); + self::assertSecondLanguageForBookDocument($languages[0]); + } + + /** + * @test + */ + public function getLanguageByQueryForBookDocument() + { + $language = $this->bookReader->getLanguage(0, '[@objectPart="summary"]'); + self::assertSecondLanguageForBookDocument($language); + } + + /** + * @test + */ + public function getFirstLanguageByQueryForBookDocument() + { + $language = $this->bookReader->getFirstLanguage('[@objectPart="summary"]'); + self::assertSecondLanguageForBookDocument($language); + } + + /** + * @test + */ + public function getLastLanguageByQueryForBookDocument() + { + $language = $this->bookReader->getLastLanguage('[@objectPart="summary"]'); + self::assertSecondLanguageForBookDocument($language); + } + + /** + * @test + */ + public function getNoLanguagesByQueryForBookDocument() + { + $languages = $this->bookReader->getLanguages('[@objectPart="abstract"]'); + self::assertEmpty($languages); + } + + /** + * @test + */ + public function getNoLanguageByQueryForBookDocument() + { + $language = $this->bookReader->getLanguage(0, '[@objectPart="abstract"]'); + self::assertNull($language); + } + + /** + * @test + */ + public function getNoFirstLanguageByQueryForBookDocument() + { + $language = $this->bookReader->getFirstLanguage('[@objectPart="abstract"]'); + self::assertNull($language); + } + + /** + * @test + */ + public function getNoLastLanguageByQueryForBookDocument() + { + $language = $this->bookReader->getLastLanguage('[@objectPart="abstract"]'); + self::assertNull($language); + } + + /** + * @test + */ + public function getLanguagesForSerialDocument() + { + $languages = $this->serialReader->getLanguages(); + self::assertNotEmpty($languages); + self::assertEquals(1, count($languages)); + self::assertLanguageForSerialDocument($languages[0]); + } + + /** + * @test + */ + public function getLanguagesByQueryForSerialDocument() + { + $languages = $this->serialReader->getLanguages('[./mods:languageTerm[@type="code"]]'); + self::assertNotEmpty($languages); + self::assertEquals(1, count($languages)); + self::assertLanguageForSerialDocument($languages[0]); + } + + /** + * @test + */ + public function getNoLanguagesByQueryForSerialDocument() + { + $languages = $this->serialReader->getLanguages('[@objectPart="summary"]'); + self::assertEmpty($languages); + } + + private static function assertFirstLanguageForBookDocument(Language $language) + { + self::assertEmpty($language->getObjectPart()); + self::assertNotEmpty($language->getValue()); + + $languageTerms = $language->getLanguageTerms(); + self::assertNotEmpty($languageTerms); + self::assertNotEmpty($languageTerms[0]->getValue()); + self::assertEquals('code', $languageTerms[0]->getType()); + self::assertEquals('iso639-2b', $languageTerms[0]->getAuthority()); + self::assertEquals('eng', $languageTerms[0]->getValue()); + + $scriptTerms = $language->getScriptTerms(); + self::assertNotEmpty($scriptTerms); + self::assertEquals('code', $scriptTerms[0]->getType()); + self::assertEquals('iso15924', $scriptTerms[0]->getAuthority()); + self::assertEquals('Latn', $scriptTerms[0]->getValue()); + } + + private static function assertSecondLanguageForBookDocument(Language $language) + { + self::assertNotEmpty($language->getObjectPart()); + self::assertEquals('summary', $language->getObjectPart()); + self::assertNotEmpty($language->getValue()); + + $languageTerms = $language->getLanguageTerms(); + self::assertNotEmpty($languageTerms); + self::assertNotEmpty($languageTerms[0]->getValue()); + self::assertEquals('code', $languageTerms[0]->getType()); + self::assertEquals('iso639-2b', $languageTerms[0]->getAuthority()); + self::assertEquals('spa', $languageTerms[0]->getValue()); + + $scriptTerms = $language->getScriptTerms(); + self::assertNotEmpty($language->getScriptTerms()); + self::assertEquals('code', $scriptTerms[0]->getType()); + self::assertEquals('iso15924', $scriptTerms[0]->getAuthority()); + self::assertEquals('Latn', $scriptTerms[0]->getValue()); + } + + private static function assertLanguageForSerialDocument(Language $language) + { + self::assertEmpty($language->getObjectPart()); + self::assertNotEmpty($language->getValue()); + + $languageTerms = $language->getLanguageTerms(); + self::assertNotEmpty($languageTerms); + self::assertNotEmpty($languageTerms[0]->getValue()); + self::assertEquals('code', $languageTerms[0]->getType()); + self::assertEquals('iso639-2b', $languageTerms[0]->getAuthority()); + self::assertEquals('eng', $languageTerms[0]->getValue()); + + self::assertEmpty($language->getScriptTerms()); + } +} diff --git a/tests/Mods/Reader/LocationReaderTest.php b/tests/Mods/Reader/LocationReaderTest.php new file mode 100644 index 0000000..48101a8 --- /dev/null +++ b/tests/Mods/Reader/LocationReaderTest.php @@ -0,0 +1,214 @@ +bookReader->getLocations(); + self::assertNotEmpty($locations); + self::assertEquals(2, count($locations)); + self::assertFirstLocationForBookDocument($locations[0]); + } + + /** + * @test + */ + public function getLocationForBookDocument() + { + $location = $this->bookReader->getLocation(1); + self::assertSecondLocationForBookDocument($location); + } + + /** + * @test + */ + public function getFirstLocationForBookDocument() + { + $location = $this->bookReader->getFirstLocation(); + self::assertFirstLocationForBookDocument($location); + } + + /** + * @test + */ + public function getLastLocationForBookDocument() + { + $location = $this->bookReader->getLastLocation(); + self::assertSecondLocationForBookDocument($location); + } + + /** + * @test + */ + public function getLocationsByQueryForBookDocument() + { + $locations = $this->bookReader->getLocations('[@displayLabel="links"]'); + self::assertNotEmpty($locations); + self::assertEquals(1, count($locations)); + self::assertSecondLocationForBookDocument($locations[0]); + + $this->expectException(IncorrectValueInAttributeException::class); + $locations[0]->getUrls()[3]->getAccess(); + } + + /** + * @test + */ + public function getLocationByQueryForBookDocument() + { + $location = $this->bookReader->getLocation(0, '[@displayLabel="links"]'); + self::assertSecondLocationForBookDocument($location); + } + + /** + * @test + */ + public function testGetFirstLocationByQueryForBookDocument() + { + $location = $this->bookReader->getFirstLocation('[@displayLabel="links"]'); + self::assertSecondLocationForBookDocument($location); + } + + /** + * @test + */ + public function getLastLocationForByQueryBookDocument() + { + $location = $this->bookReader->getLastLocation('[@displayLabel="links"]'); + self::assertSecondLocationForBookDocument($location); + } + + /** + * @test + */ + public function getNoLocationsByQueryForBookDocument() + { + $locations = $this->bookReader->getLocations('[@displayLabel="random"]'); + self::assertEmpty($locations); + } + + /** + * @test + */ + public function getNoLocationByQueryForBookDocument() + { + $location = $this->bookReader->getLocation(6, '[@displayLabel="links"]'); + self::assertNull($location); + } + + /** + * @test + */ + public function getNoFirstLocationByQueryForBookDocument() + { + $location = $this->bookReader->getFirstLocation('[@displayLabel="random"]'); + self::assertNull($location); + } + + /** + * @test + */ + public function getNoLastLocationByQueryForBookDocument() + { + $location = $this->bookReader->getLastLocation('[@displayLabel="random"]'); + self::assertNull($location); + } + + /** + * @test + */ + public function getLocationsForSerialDocument() + { + $locations = $this->serialReader->getLocations(); + self::assertNotEmpty($locations); + self::assertEquals(2, count($locations)); + self::assertLocationForSerialDocument($locations[0]); + } + + /** + * @test + */ + public function getLocationsByQueryForSerialDocument() + { + $locations = $this->serialReader->getLocations('[./mods:url[@usage="primaryDisplay"]]'); + self::assertNotEmpty($locations); + self::assertEquals(1, count($locations)); + self::assertLocationForSerialDocument($locations[0]); + } + + /** + * @test + */ + public function getNoLocationsByQueryForSerialDocument() + { + $locations = $this->serialReader->getLocations('[@usage="rad"]'); + self::assertEmpty($locations); + } + + private static function assertFirstLocationForBookDocument(Location $location) + { + self::assertNotEmpty($location->getValue()); + + $physicalLocations = $location->getPhysicalLocations(); + self::assertNotEmpty($physicalLocations); + self::assertEquals('marcorg', $physicalLocations[0]->getAuthority()); + self::assertEquals('MnRM', $physicalLocations[0]->getValue()); + + $holdingSimple = $location->getHoldingSimple(); + self::assertNotNull($holdingSimple); + + $copyInformation = $holdingSimple->getCopyInformation(); + self::assertNotEmpty($copyInformation); + self::assertNotEmpty($copyInformation[0]->getSubLocations()); + self::assertEquals('Reading room', $copyInformation[0]->getSubLocations()[0]->getValue()); + self::assertNotEmpty($copyInformation[0]->getShelfLocators()); + self::assertEquals('QH511.A1J68', $copyInformation[0]->getShelfLocators()[0]->getValue()); + self::assertEquals('1', $copyInformation[0]->getEnumerationAndChronologies()[0]->getUnitType()); + self::assertEquals('v.1-v.2 1999-2002', $copyInformation[0]->getEnumerationAndChronologies()[0]->getValue()); + } + + private static function assertSecondLocationForBookDocument(Location $location) + { + self::assertNotEmpty($location->getValue()); + + $urls = $location->getUrls(); + self::assertNotEmpty($urls); + self::assertEquals(4, count($urls)); + self::assertEquals('2024-01-27', $urls[0]->getDateLastAccessed()); + self::assertEquals('http://www.slub-dresden.de/some-url', $urls[0]->getValue()); + self::assertEquals('preview', $urls[1]->getAccess()); + self::assertEquals('http://www.slub-dresden.de/some-url/SLO-0000', $urls[1]->getValue()); + } + + private static function assertLocationForSerialDocument(Location $location) + { + $urls = $location->getUrls(); + self::assertNotEmpty($urls); + self::assertEquals('electronic resource', $urls[0]->getDisplayLabel()); + self::assertEquals('primaryDisplay', $urls[0]->getUsage()); + self::assertEquals('http://bibpurl.oclc.org/web/7085', $urls[0]->getValue()); + } +} diff --git a/tests/Mods/Reader/NameReaderTest.php b/tests/Mods/Reader/NameReaderTest.php new file mode 100644 index 0000000..97521e2 --- /dev/null +++ b/tests/Mods/Reader/NameReaderTest.php @@ -0,0 +1,221 @@ +bookReader->getNames(); + self::assertNotEmpty($names); + self::assertEquals(2, count($names)); + self::assertFirstNameForBookDocument($names[0]); + } + + /** + * @test + */ + public function getNameForBookDocument() + { + $name = $this->bookReader->getName(1); + self::assertSecondNameForBookDocument($name); + } + + /** + * @test + */ + public function getFirstNameForBookDocument() + { + $name = $this->bookReader->getFirstName(); + self::assertFirstNameForBookDocument($name); + } + + /** + * @test + */ + public function getLastNameForBookDocument() + { + $name = $this->bookReader->getLastName(); + self::assertSecondNameForBookDocument($name); + } + + /** + * @test + */ + public function getNamesByQueryForBookDocument() + { + $names = $this->bookReader->getNames('[@type="personal" and not(@usage="primary")]'); + self::assertNotEmpty($names); + self::assertEquals(1, count($names)); + self::assertSecondNameForBookDocument($names[0]); + } + + /** + * @test + */ + public function getNameByQueryForBookDocument() + { + $name = $this->bookReader->getName(0, '[@type="personal" and not(@usage="primary")]'); + self::assertSecondNameForBookDocument($name); + } + + /** + * @test + */ + public function getFirstNameByQueryForBookDocument() + { + $name = $this->bookReader->getFirstName('[@type="personal" and not(@usage="primary")]'); + self::assertSecondNameForBookDocument($name); + } + + /** + * @test + */ + public function getLastNameByQueryForBookDocument() + { + $name = $this->bookReader->getLastName('[@type="personal" and not(@usage="primary")]'); + self::assertSecondNameForBookDocument($name); + } + + /** + * @test + */ + public function getNoNamesByQueryForBookDocument() + { + $names = $this->bookReader->getNames('[@type="corporate"]'); + self::assertEmpty($names); + } + + /** + * @test + */ + public function getNoNameByQueryForBookDocument() + { + $name = $this->bookReader->getName(3, '[@type="corporate"]'); + self::assertNull($name); + } + + /** + * @test + */ + public function getNoFirstNameByQueryForBookDocument() + { + $name = $this->bookReader->getFirstName('[@type="corporate"]'); + self::assertNull($name); + } + + /** + * @test + */ + public function getNoLastNameByQueryForBookDocument() + { + $name = $this->bookReader->getLastName('[@type="corporate"]'); + self::assertNull($name); + } + + /** + * @test + */ + public function getNamesForSerialDocument() + { + $names = $this->serialReader->getNames(); + self::assertNotEmpty($names); + self::assertEquals(1, count($names)); + self::assertNameForSerialDocument($names[0]); + } + + /** + * @test + */ + public function getNamesByQueryForSerialDocument() + { + $names = $this->serialReader->getNames('[@type="corporate"]'); + self::assertNotEmpty($names); + self::assertEquals(1, count($names)); + self::assertNameForSerialDocument($names[0]); + } + + /** + * @test + */ + public function getNoNamesByQueryForSerialDocument() + { + $names = $this->serialReader->getNames('[@type="personal"]'); + self::assertEmpty($names); + } + + private static function assertFirstNameForBookDocument(Name $name) + { + self::assertNotEmpty($name->getType()); + self::assertEquals('personal', $name->getType()); + self::assertNotEmpty($name->getUsage()); + self::assertEquals('primary', $name->getUsage()); + self::assertNotEmpty($name->getValue()); + + $nameParts = $name->getNameParts(); + self::assertNotEmpty($nameParts); + self::assertEquals('Alterman, Eric.', $nameParts[0]->getValue()); + + $roles = $name->getRoles(); + self::assertNotEmpty($roles); + + $roleTerms = $roles[0]->getRoleTerms(); + self::assertNotEmpty($roleTerms); + self::assertEquals('text', $roleTerms[0]->getType()); + self::assertEquals('marcrelator', $roleTerms[0]->getAuthority()); + self::assertEquals('creator', $roleTerms[0]->getValue()); + } + + private static function assertSecondNameForBookDocument(Name $name) + { + self::assertNotEmpty($name->getType()); + self::assertEquals('personal', $name->getType()); + self::assertEmpty($name->getUsage()); + self::assertNotEmpty($name->getValue()); + + $nameParts = $name->getNameParts(); + self::assertNotEmpty($name->getNameParts()); + self::assertEquals(2, count($nameParts)); + self::assertEquals('given', $nameParts[0]->getType()); + self::assertEquals('Aron', $nameParts[0]->getValue()); + + $roles = $name->getRoles(); + self::assertNotEmpty($roles); + + $roleTerms = $roles[0]->getRoleTerms(); + self::assertNotEmpty($roleTerms); + self::assertEquals('text', $roleTerms[0]->getType()); + self::assertEquals('marcrelator', $roleTerms[0]->getAuthority()); + self::assertEquals('author', $roleTerms[0]->getValue()); + } + + private static function assertNameForSerialDocument(Name $name) + { + self::assertNotEmpty($name->getValue()); + + $nameParts = $name->getNameParts(); + self::assertNotEmpty($name->getNameParts()); + self::assertEquals(1, count($nameParts)); + self::assertEquals('International Consortium for the Advancement of Academic Publication.', $nameParts[0]->getValue()); + } +} diff --git a/tests/Mods/Reader/NoteReaderTest.php b/tests/Mods/Reader/NoteReaderTest.php new file mode 100644 index 0000000..894bb75 --- /dev/null +++ b/tests/Mods/Reader/NoteReaderTest.php @@ -0,0 +1,232 @@ +bookReader->getNotes(); + self::assertNotEmpty($notes); + self::assertEquals(2, count($notes)); + self::assertFirstNoteForBookDocument($notes[0]); + } + + /** + * @test + */ + public function getNoteForBookDocument() + { + $note = $this->bookReader->getNote(1); + self::assertSecondNoteForBookDocument($note); + } + + /** + * @test + */ + public function getFirstNoteForBookDocument() + { + $note = $this->bookReader->getFirstNote(); + self::assertFirstNoteForBookDocument($note); + } + + /** + * @test + */ + public function getLastNoteForBookDocument() + { + $note = $this->bookReader->getLastNote(); + self::assertSecondNoteForBookDocument($note); + } + + /** + * @test + */ + public function getNotesByQueryForBookDocument() + { + $notes = $this->bookReader->getNotes('[@type="bibliography"]'); + self::assertNotEmpty($notes); + self::assertEquals(1, count($notes)); + self::assertSecondNoteForBookDocument($notes[0]); + } + + /** + * @test + */ + public function getNoteByQueryForBookDocument() + { + $note = $this->bookReader->getNote(0, '[@type="bibliography"]'); + self::assertSecondNoteForBookDocument($note); + } + + /** + * @test + */ + public function getFirstNoteByQueryForBookDocument() + { + $note = $this->bookReader->getFirstNote('[@type="bibliography"]'); + self::assertSecondNoteForBookDocument($note); + } + + /** + * @test + */ + public function getLastNoteByQueryForBookDocument() + { + $note = $this->bookReader->getLastNote('[@type="bibliography"]'); + self::assertSecondNoteForBookDocument($note); + } + + /** + * @test + */ + public function getNoNotesByQueryForBookDocument() + { + $notes = $this->bookReader->getNotes('[@type="xyz"]'); + self::assertEmpty($notes); + } + + /** + * @test + */ + public function getNoNoteByQueryForBookDocument() + { + $note = $this->bookReader->getNote(0, '[@type="xyz"]'); + self::assertNull($note); + } + + /** + * @test + */ + public function getNoFirstNoteByQueryForBookDocument() + { + $note = $this->bookReader->getFirstNote('[@type="xyz"]'); + self::assertNull($note); + } + + /** + * @test + */ + public function getNoLastNoteByQueryForBookDocument() + { + $note = $this->bookReader->getLastNote('[@type="xyz"]'); + self::assertNull($note); + } + + /** + * @test + */ + public function getNotesForSerialDocument() + { + $notes = $this->serialReader->getNotes(); + self::assertNotEmpty($notes); + self::assertEquals(6, count($notes)); + self::assertFirstNoteForSerialDocument($notes[0]); + } + + /** + * @test + */ + public function getNoteForSerialDocument() + { + $note = $this->serialReader->getNote(5); + self::assertSixthNoteForSerialDocument($note); + } + + /** + * @test + */ + public function getFirstNoteForSerialDocument() + { + $note = $this->serialReader->getFirstNote(); + self::assertFirstNoteForSerialDocument($note); + } + + /** + * @test + */ + public function getLastNoteForSerialDocument() + { + $note = $this->serialReader->getLastNote(); + self::assertSixthNoteForSerialDocument($note); + } + + /** + * @test + */ + public function getNotesByQueryForSerialDocument() + { + $notes = $this->serialReader->getNotes('[@type="system details"]'); + self::assertNotEmpty($notes); + self::assertEquals(1, count($notes)); + self::assertFifthNoteForSerialDocument($notes[0]); + } + + /** + * @test + */ + public function getNoNotesByQueryForSerialDocument() + { + $notes = $this->serialReader->getNotes('[@type="xyz"]'); + self::assertEmpty($notes); + } + + private static function assertFirstNoteForBookDocument(Note $note) + { + self::assertNotEmpty($note->getValue()); + self::assertEquals('Eric Alterman.', $note->getValue()); + self::assertNotEmpty($note->getType()); + self::assertEquals('statement of responsibility', $note->getType()); + } + + private static function assertSecondNoteForBookDocument(Note $note) + { + self::assertNotEmpty($note->getValue()); + self::assertEquals('Includes bibliographical references (p. 291-312) and index.', $note->getValue()); + self::assertNotEmpty($note->getType()); + self::assertEquals('bibliography', $note->getType()); + } + + private static function assertFirstNoteForSerialDocument(Note $note) + { + self::assertNotEmpty($note->getValue()); + self::assertEquals('V. 3, no. 1/2 (winter 2002)-', $note->getValue()); + self::assertNotEmpty($note->getType()); + self::assertEquals('date/sequential designation', $note->getType()); + } + + private static function assertFifthNoteForSerialDocument(Note $note) + { + self::assertNotEmpty($note->getValue()); + self::assertEquals('Mode of access: World Wide Web.', $note->getValue()); + self::assertNotEmpty($note->getType()); + self::assertEquals('system details', $note->getType()); + } + + private static function assertSixthNoteForSerialDocument(Note $note) + { + self::assertNotEmpty($note->getValue()); + self::assertEquals('Electronic serial in HTML format.', $note->getValue()); + self::assertEmpty($note->getType()); + } +} diff --git a/tests/Mods/Reader/OriginInfoReaderTest.php b/tests/Mods/Reader/OriginInfoReaderTest.php new file mode 100644 index 0000000..9fa435d --- /dev/null +++ b/tests/Mods/Reader/OriginInfoReaderTest.php @@ -0,0 +1,234 @@ +bookReader->getOriginInfos(); + self::assertNotEmpty($originInfos); + self::assertEquals(2, count($originInfos)); + self::assertFirstOriginInfoForBookDocument($originInfos[0]); + } + + /** + * @test + */ + public function getOriginInfoForBookDocument() + { + $originInfo = $this->bookReader->getOriginInfo(1); + self::assertSecondOriginInfoForBookDocument($originInfo); + } + + /** + * @test + */ + public function getFirstOriginInfoForBookDocument() + { + $originInfo = $this->bookReader->getFirstOriginInfo(); + self::assertFirstOriginInfoForBookDocument($originInfo); + } + + /** + * @test + */ + public function getLastOriginInfoForBookDocument() + { + $originInfo = $this->bookReader->getLastOriginInfo(); + self::assertSecondOriginInfoForBookDocument($originInfo); + } + + /** + * @test + */ + public function getOriginInfosByQueryForBookDocument() + { + $originInfos = $this->bookReader->getOriginInfos('[@eventType="redaction"]'); + self::assertNotEmpty($originInfos); + self::assertEquals(1, count($originInfos)); + self::assertSecondOriginInfoForBookDocument($originInfos[0]); + } + + /** + * @test + */ + public function getNoOriginInfosByQueryForBookDocument() + { + $originInfos = $this->bookReader->getOriginInfos('[@eventType="xyz"]'); + self::assertEmpty($originInfos); + + $firstOriginInfo = $this->bookReader->getFirstOriginInfo('[@eventType="xyz"]'); + self::assertNull($firstOriginInfo); + + $lastOriginInfo = $this->bookReader->getLastOriginInfo('[@eventType="xyz"]'); + self::assertNull($lastOriginInfo); + } + + /** + * @test + */ + public function getNoOriginInfoByQueryForBookDocument() + { + $originInfo = $this->bookReader->getOriginInfo(4, '[@eventType="xyz"]'); + self::assertNull($originInfo); + } + + /** + * @test + */ + public function getNoFirstOriginInfoByQueryForBookDocument() + { + $originInfo = $this->bookReader->getFirstOriginInfo('[@eventType="xyz"]'); + self::assertNull($originInfo); + } + + /** + * @test + */ + public function getNoLastOriginInfoByQueryForBookDocument() + { + $originInfo = $this->bookReader->getLastOriginInfo('[@eventType="xyz"]'); + self::assertNull($originInfo); + } + + /** + * @test + */ + public function getOriginInfosForSerialDocument() + { + $originInfos = $this->serialReader->getOriginInfos(); + self::assertNotEmpty($originInfos); + self::assertEquals(1, count($originInfos)); + self::assertOriginInfoForSerialDocument($originInfos[0]); + } + + /** + * @test + */ + public function getOriginInfosByQueryForSerialDocument() + { + $originInfos = $this->serialReader->getOriginInfos('[@eventType="publication"]'); + self::assertNotEmpty($originInfos); + self::assertEquals(1, count($originInfos)); + self::assertOriginInfoForSerialDocument($originInfos[0]); + } + + /** + * @test + */ + public function getNoOriginInfosByQueryForSerialDocument() + { + $originInfos = $this->serialReader->getOriginInfos('[@eventType="xyz"]'); + self::assertEmpty($originInfos); + } + + private static function assertFirstOriginInfoForBookDocument(OriginInfo $originInfo) + { + self::assertNotEmpty($originInfo->getValue()); + self::assertNotEmpty($originInfo->getEventType()); + self::assertEquals('publication', $originInfo->getEventType()); + + $places = $originInfo->getPlaces(); + self::assertNotEmpty($places); + self::assertEquals(2, count($places)); + + $placeTerms = $places[0]->getPlaceTerms(); + self::assertNotEmpty($placeTerms); + self::assertEquals('marccountry', $placeTerms[0]->getAuthority()); + self::assertEquals('code', $placeTerms[0]->getType()); + self::assertEquals('nyu', $placeTerms[0]->getValue()); + + $issuedDates = $originInfo->getIssuedDates(); + self::assertNotEmpty($issuedDates); + self::assertEquals(2, count($issuedDates)); + self::assertEquals('marc', $issuedDates[0]->getEncoding()); + self::assertEquals('2000', $issuedDates[0]->getValue()); + + $issuances = $originInfo->getIssuances(); + self::assertNotEmpty($issuances); + self::assertEquals('monographic', $issuances[0]->getValue()); + } + + private static function assertSecondOriginInfoForBookDocument(OriginInfo $originInfo) + { + self::assertNotEmpty($originInfo->getValue()); + self::assertNotEmpty($originInfo->getEventType()); + self::assertEquals('redaction', $originInfo->getEventType()); + + $places = $originInfo->getPlaces(); + self::assertNotEmpty($places); + self::assertEquals(2, count($places)); + + $placeTerms = $places[1]->getPlaceTerms(); + self::assertNotEmpty($placeTerms); + self::assertEquals('text', $placeTerms[0]->getType()); + self::assertEquals('Ithaca, N.Y', $placeTerms[0]->getValue()); + + $issuedDates = $originInfo->getIssuedDates(); + self::assertNotEmpty($issuedDates); + self::assertEquals(2, count($issuedDates)); + self::assertEquals('marc', $issuedDates[0]->getEncoding()); + self::assertEquals('1999', $issuedDates[0]->getValue()); + + self::assertEmpty($originInfo->getIssuances()); + } + + private static function assertOriginInfoForSerialDocument(OriginInfo $originInfo) + { + self::assertNotEmpty($originInfo->getValue()); + self::assertNotEmpty($originInfo->getEventType()); + self::assertEquals('publication', $originInfo->getEventType()); + + $places = $originInfo->getPlaces(); + self::assertNotEmpty($places); + self::assertEquals(2, count($places)); + + $placeTerms = $places[0]->getPlaceTerms(); + self::assertNotEmpty($placeTerms); + self::assertEquals('marccountry', $placeTerms[0]->getAuthority()); + self::assertEquals('code', $placeTerms[0]->getType()); + self::assertEquals('abc', $placeTerms[0]->getValue()); + + $issuedDates = $originInfo->getIssuedDates(); + self::assertNotEmpty($issuedDates); + self::assertEquals(3, count($issuedDates)); + self::assertEquals('marc', $issuedDates[0]->getEncoding()); + self::assertEquals('start', $issuedDates[0]->getPoint()); + self::assertEquals('2002', $issuedDates[0]->getValue()); + + $issuances = $originInfo->getIssuances(); + self::assertNotEmpty($issuances); + self::assertEquals('serial', $issuances[0]->getValue()); + + $frequencies = $originInfo->getFrequencies(); + self::assertNotEmpty($frequencies); + self::assertEquals(2, count($frequencies)); + self::assertEquals('Three times a year', $frequencies[0]->getValue()); + + $agents = $originInfo->getAgents(); + self::assertNotEmpty($agents); + // TODO: extend agent with name + //self::assertNotEmpty($agents[0]->getNamePart()); + } +} diff --git a/tests/Mods/Reader/PartReaderTest.php b/tests/Mods/Reader/PartReaderTest.php new file mode 100644 index 0000000..7a00b4f --- /dev/null +++ b/tests/Mods/Reader/PartReaderTest.php @@ -0,0 +1,172 @@ +bookReader->getParts(); + self::assertNotEmpty($parts); + self::assertEquals(2, count($parts)); + self::assertFirstPartForBookDocument($parts[0]); + } + + /** + * @test + */ + public function getPartForBookDocument() + { + $part = $this->bookReader->getPart(1); + self::assertSecondPartForBookDocument($part); + } + + /** + * @test + */ + public function getFirstPartForBookDocument() + { + $part = $this->bookReader->getFirstPart(); + self::assertFirstPartForBookDocument($part); + } + + /** + * @test + */ + public function getLastPartForBookDocument() + { + $part = $this->bookReader->getLastPart(); + self::assertSecondPartForBookDocument($part); + } + + /** + * @test + */ + public function getPartsByQueryForBookDocument() + { + $parts = $this->bookReader->getParts('[@order="2"]'); + self::assertNotEmpty($parts); + self::assertEquals(1, count($parts)); + self::assertSecondPartForBookDocument($parts[0]); + } + + /** + * @test + */ + public function getNoPartsByQueryForBookDocument() + { + $parts = $this->bookReader->getParts('[@order="3"]'); + self::assertEmpty($parts); + } + + /** + * @test + */ + public function getNoPartByQueryForBookDocument() + { + $part = $this->bookReader->getPart(0, '[@order="3"]'); + self::assertNull($part); + } + + /** + * @test + */ + public function getNoFirstPartByQueryForBookDocument() + { + $part = $this->bookReader->getFirstPart('[@order="3"]'); + self::assertNull($part); + } + + /** + * @test + */ + public function getNoLastPartByQueryForBookDocument() + { + $part = $this->bookReader->getLastPart('[@order="3"]'); + self::assertNull($part); + } + + /** + * @test + */ + public function getNoPartsForSerialDocument() + { + $parts = $this->serialReader->getParts(); + self::assertEmpty($parts); + } + + private static function assertFirstPartForBookDocument(Part $part) + { + self::assertNotEmpty($part->getValue()); + self::assertNotEmpty($part->getType()); + self::assertEquals('poem', $part->getType()); + self::assertNotEmpty($part->getOrder()); + self::assertEquals(1, $part->getOrder()); + + $details = $part->getDetails(); + self::assertNotEmpty($details); + + $titles = $details[0]->getTitles(); + self::assertNotEmpty($titles); + self::assertEquals('Wayfarers', $titles[0]->getValue()); + + $extents = $part->getExtents(); + self::assertNotEmpty($extents); + self::assertEquals('pages', $extents[0]->getUnit()); + self::assertEquals('97', $extents[0]->getStart()->getValue()); + self::assertEquals('98', $extents[0]->getEnd()->getValue()); + + $dates = $part->getDates(); + self::assertNotEmpty($dates); + self::assertEquals('marc', $dates[0]->getEncoding()); + self::assertEquals('1989', $dates[0]->getValue()); + + $texts = $part->getTexts(); + self::assertNotEmpty($texts); + self::assertEquals('Some random text', $texts[0]->getValue()); + } + + private static function assertSecondPartForBookDocument(Part $part) + { + self::assertNotEmpty($part->getValue()); + self::assertNotEmpty($part->getType()); + self::assertEquals('poem', $part->getType()); + self::assertNotEmpty($part->getOrder()); + self::assertEquals(2, $part->getOrder()); + + $details = $part->getDetails(); + self::assertNotEmpty($details); + self::assertEquals(2, count($details)); + self::assertEquals('begin', $details[0]->getType()); + self::assertEquals(1, $details[0]->getLevel()); + self::assertNotEmpty($details[0]->getTitles()); + self::assertEquals('Vagabonds', $details[0]->getTitles()[0]->getValue()); + + $extents = $part->getExtents(); + self::assertNotEmpty($extents); + self::assertEquals('pages', $extents[0]->getUnit()); + self::assertEquals('99', $extents[0]->getStart()->getValue()); + self::assertEquals('100', $extents[0]->getEnd()->getValue()); + self::assertEquals(2, $extents[0]->getTotal()); + } +} diff --git a/tests/Mods/Reader/PhysicalDescriptionReaderTest.php b/tests/Mods/Reader/PhysicalDescriptionReaderTest.php new file mode 100644 index 0000000..03ccc31 --- /dev/null +++ b/tests/Mods/Reader/PhysicalDescriptionReaderTest.php @@ -0,0 +1,173 @@ +bookReader->getPhysicalDescriptions(); + self::assertNotEmpty($physicalDescriptions); + self::assertEquals(1, count($physicalDescriptions)); + self::assertPhysicalDescriptionForBookDocument($physicalDescriptions[0]); + } + + /** + * @test + */ + public function getPhysicalDescriptionForBookDocument() + { + $physicalDescription = $this->bookReader->getPhysicalDescription(0); + self::assertPhysicalDescriptionForBookDocument($physicalDescription); + } + + /** + * @test + */ + public function getFirstPhysicalDescriptionForBookDocument() + { + $physicalDescription = $this->bookReader->getFirstPhysicalDescription(); + self::assertPhysicalDescriptionForBookDocument($physicalDescription); + } + + /** + * @test + */ + public function getLastPhysicalDescriptionForBookDocument() + { + $physicalDescription = $this->bookReader->getLastPhysicalDescription(); + self::assertPhysicalDescriptionForBookDocument($physicalDescription); + } + + /** + * @test + */ + public function getPhysicalDescriptionsByQueryForBookDocument() + { + $physicalDescriptions = $this->bookReader->getPhysicalDescriptions('[./mods:form[@authority="marcform"]="print"]'); + self::assertNotEmpty($physicalDescriptions); + self::assertEquals(1, count($physicalDescriptions)); + self::assertPhysicalDescriptionForBookDocument($physicalDescriptions[0]); + } + + /** + * @test + */ + public function getNoPhysicalDescriptionsByQueryForBookDocument() + { + $physicalDescriptions = $this->bookReader->getPhysicalDescriptions('[./mods:form[@authority="marcform"]="electronic"]'); + self::assertEmpty($physicalDescriptions); + } + + /** + * @test + */ + public function getNoPhysicalDescriptionByQueryForBookDocument() + { + $physicalDescription = $this->bookReader->getPhysicalDescription(0, '[./mods:form[@authority="marcform"]="electronic"]'); + self::assertNull($physicalDescription); + } + + /** + * @test + */ + public function getNoFirstPhysicalDescriptionByQueryForBookDocument() + { + $physicalDescription = $this->bookReader->getFirstPhysicalDescription('[./mods:form[@authority="marcform"]="electronic"]'); + self::assertNull($physicalDescription); + } + + /** + * @test + */ + public function getNoLastPhysicalDescriptionByQueryForBookDocument() + { + $physicalDescription = $this->bookReader->getLastPhysicalDescription('[./mods:form[@authority="marcform"]="electronic"]'); + self::assertNull($physicalDescription); + } + + /** + * @test + */ + public function getPhysicalDescriptionsForSerialDocument() + { + $physicalDescriptions = $this->serialReader->getPhysicalDescriptions(); + self::assertNotEmpty($physicalDescriptions); + self::assertEquals(1, count($physicalDescriptions)); + self::assertPhysicalDescriptionForSerialDocument($physicalDescriptions[0]); + } + + /** + * @test + */ + public function getPhysicalDescriptionsByQueryForSerialDocument() + { + $physicalDescriptions = $this->serialReader->getPhysicalDescriptions('[./mods:form[@authority="marcform"]="electronic"]'); + self::assertNotEmpty($physicalDescriptions); + self::assertEquals(1, count($physicalDescriptions)); + self::assertPhysicalDescriptionForSerialDocument($physicalDescriptions[0]); + } + + /** + * @test + */ + public function getNoPhysicalDescriptionsByQueryForSerialDocument() + { + $physicalDescriptions = $this->serialReader->getPhysicalDescriptions('[./mods:form[@authority="marcform"]="print"]'); + self::assertEmpty($physicalDescriptions); + } + + private static function assertPhysicalDescriptionForBookDocument(PhysicalDescription $physicalDescription) + { + self::assertNotEmpty($physicalDescription->getValue()); + + $forms = $physicalDescription->getForms(); + self::assertNotEmpty($forms); + self::assertEquals('marcform', $forms[0]->getAuthority()); + self::assertEquals('print', $forms[0]->getValue()); + self::assertNotEmpty($physicalDescription->getExtents()); + self::assertEquals('vii, 322 p. ; 23 cm.', $physicalDescription->getExtents()[0]->getValue()); + self::assertNotEmpty($physicalDescription->getReformattingQualities()); + self::assertEquals('replacement', $physicalDescription->getReformattingQualities()[0]); + self::assertNotEmpty($physicalDescription->getDigitalOrigins()); + self::assertEquals('born digital', $physicalDescription->getDigitalOrigins()[0]); + self::assertEmpty($physicalDescription->getNotes()); + } + + private static function assertPhysicalDescriptionForSerialDocument(PhysicalDescription $physicalDescription) + { + self::assertNotEmpty($physicalDescription->getValue()); + self::assertNotEmpty($physicalDescription->getForms()); + + $forms = $physicalDescription->getForms(); + self::assertEquals(2, count($forms)); + self::assertEquals('gmd', $forms[1]->getAuthority()); + self::assertEquals('electronic resource', $forms[1]->getValue()); + self::assertNotEmpty($physicalDescription->getInternetMediaTypes()); + self::assertEquals('text/html', $physicalDescription->getInternetMediaTypes()[0]->getValue()); + self::assertEmpty($physicalDescription->getExtents()); + self::assertEmpty($physicalDescription->getReformattingQualities()); + self::assertEmpty($physicalDescription->getDigitalOrigins()); + self::assertEmpty($physicalDescription->getNotes()); + } +} diff --git a/tests/Mods/Reader/RecordInfoReaderTest.php b/tests/Mods/Reader/RecordInfoReaderTest.php new file mode 100644 index 0000000..1db2a2b --- /dev/null +++ b/tests/Mods/Reader/RecordInfoReaderTest.php @@ -0,0 +1,196 @@ +bookReader->getRecordInfos(); + self::assertNotEmpty($recordInfos); + self::assertEquals(1, count($recordInfos)); + self::assertRecordInfoForBookDocument($recordInfos[0]); + } + + public function testGetRecordInfoForBookDocument() + { + $recordInfo = $this->bookReader->getRecordInfo(0); + self::assertRecordInfoForBookDocument($recordInfo); + } + + public function testGetFirstRecordInfoForBookDocument() + { + $recordInfo = $this->bookReader->getFirstRecordInfo(); + self::assertRecordInfoForBookDocument($recordInfo); + } + + public function testGetLastRecordInfoForBookDocument() + { + $recordInfo = $this->bookReader->getLastRecordInfo(); + self::assertRecordInfoForBookDocument($recordInfo); + } + + public function testGetRecordInfosByQueryForBookDocument() + { + $recordInfos = $this->bookReader->getRecordInfos('[./mods:descriptionStandard="aacr"]'); + self::assertNotEmpty($recordInfos); + self::assertEquals(1, count($recordInfos)); + self::assertRecordInfoForBookDocument($recordInfos[0]); + } + + public function testGetRecordInfoByQueryForBookDocument() + { + $recordInfo = $this->bookReader->getRecordInfo(0, '[./mods:descriptionStandard="aacr"]'); + self::assertRecordInfoForBookDocument($recordInfo); + } + + public function testGetFirstRecordInfoByQueryForBookDocument() + { + $recordInfo = $this->bookReader->getFirstRecordInfo('[./mods:descriptionStandard="aacr"]'); + self::assertRecordInfoForBookDocument($recordInfo); + } + + public function testGetLastRecordInfoByQueryForBookDocument() + { + $recordInfo = $this->bookReader->getLastRecordInfo('[./mods:descriptionStandard="aacr"]'); + self::assertRecordInfoForBookDocument($recordInfo); + } + + public function testGetNoRecordInfosByQueryForBookDocument() + { + $recordInfos = $this->bookReader->getRecordInfos('[./mods:descriptionStandard="xyz"]'); + self::assertEmpty($recordInfos); + } + + public function testGetNoRecordInfoByQueryForBookDocument() + { + $recordInfo = $this->bookReader->getRecordInfo(5, '[./mods:descriptionStandard="xyz"]'); + self::assertNull($recordInfo); + + $firstRecordInfo = $this->bookReader->getFirstRecordInfo('[./mods:descriptionStandard="xyz"]'); + self::assertNull($firstRecordInfo); + + $lastRecordInfo = $this->bookReader->getLastRecordInfo('[./mods:descriptionStandard="xyz"]'); + self::assertNull($lastRecordInfo); + } + + public function testGetRecordInfosForSerialDocument() + { + $recordInfos = $this->serialReader->getRecordInfos(); + self::assertNotEmpty($recordInfos); + self::assertEquals(1, count($recordInfos)); + self::assertRecordInfoForSerialDocument($recordInfos[0]); + + $this->expectException(IncorrectValueInAttributeException::class); + $recordInfos[0]->getRecordCreationDates()[0]->getEncoding(); + } + + public function testGetRecordInfosByQueryForSerialDocument() + { + $recordInfos = $this->serialReader->getRecordInfos('[./mods:descriptionStandard="aacr"]'); + self::assertNotEmpty($recordInfos); + self::assertEquals(1, count($recordInfos)); + self::assertRecordInfoForSerialDocument($recordInfos[0]); + + $this->expectException(IncorrectValueInAttributeException::class); + $recordInfos[0]->getRecordCreationDates()[0]->getEncoding(); + } + + public function testGetNoRecordInfosByQueryForSerialDocument() + { + $recordInfos = $this->serialReader->getRecordInfos('[./mods:descriptionStandard="xyz"]'); + self::assertEmpty($recordInfos); + } + + private static function assertRecordInfoForBookDocument(RecordInfo $recordInfo) + { + self::assertNotEmpty($recordInfo->getValue()); + self::assertNotEmpty($recordInfo->getDescriptionStandards()); + self::assertEquals('aacr', $recordInfo->getDescriptionStandards()[0]->getValue()); + + $recordContentSources = $recordInfo->getRecordContentSources(); + self::assertNotEmpty($recordContentSources); + self::assertEquals('marcorg', $recordContentSources[0]->getAuthority()); + self::assertEquals('DLC', $recordContentSources[0]->getValue()); + + $recordCreationDates = $recordInfo->getRecordCreationDates(); + self::assertNotEmpty($recordCreationDates); + self::assertEquals('marc', $recordCreationDates[0]->getEncoding()); + self::assertEquals('990730', $recordCreationDates[0]->getValue()); + + $recordChangeDates = $recordInfo->getRecordChangeDates(); + self::assertNotEmpty($recordChangeDates); + self::assertEquals('iso8601', $recordChangeDates[0]->getEncoding()); + self::assertEquals('20060801143536.0', $recordChangeDates[0]->getValue()); + + $recordIdentifiers = $recordInfo->getRecordIdentifiers(); + self::assertNotEmpty($recordIdentifiers); + self::assertEquals('DE-14', $recordIdentifiers[0]->getSource()); + self::assertEquals('11761548', $recordIdentifiers[0]->getValue()); + self::assertNotEmpty($recordInfo->getRecordOrigins()); + self::assertStringContainsString('Converted from MARCXML to MODS', $recordInfo->getRecordOrigins()[0]->getValue()); + } + + private static function assertRecordInfoForSerialDocument(RecordInfo $recordInfo) + { + self::assertNotEmpty($recordInfo->getValue()); + self::assertNotEmpty($recordInfo->getDescriptionStandards()); + self::assertEquals('aacr', $recordInfo->getDescriptionStandards()[0]->getValue()); + + $recordContentSources = $recordInfo->getRecordContentSources(); + self::assertNotEmpty($recordContentSources); + self::assertEquals('marcorg', $recordContentSources[0]->getAuthority()); + self::assertEquals('NLC', $recordContentSources[0]->getValue()); + + $recordCreationDates = $recordInfo->getRecordCreationDates(); + self::assertNotEmpty($recordCreationDates); + self::assertEquals('021127', $recordCreationDates[0]->getValue()); + + $recordChangeDates = $recordInfo->getRecordChangeDates(); + self::assertNotEmpty($recordChangeDates); + self::assertEquals('iso8601', $recordChangeDates[0]->getEncoding()); + self::assertEquals('20080910160139.0', $recordChangeDates[0]->getValue()); + self::assertNotEmpty($recordInfo->getRecordIdentifiers()); + self::assertEquals('15446420', $recordInfo->getRecordIdentifiers()[0]->getValue()); + self::assertNotEmpty($recordInfo->getRecordOrigins()); + self::assertStringContainsString('Converted from MARCXML to MODS', $recordInfo->getRecordOrigins()[0]->getValue()); + + $recordInfoNotes = $recordInfo->getRecordInfoNotes(); + self::assertNotEmpty($recordInfo->getRecordInfoNotes()); + self::assertEquals(2, count($recordInfoNotes)); + self::assertEquals('Some info', $recordInfoNotes[1]->getValue()); + + $languages = $recordInfo->getLanguageOfCatalogings(); + self::assertNotEmpty($languages); + + $languageTerm = $languages[0]->getLanguageTerm(); + self::assertNotNull($languageTerm); + self::assertEquals('code', $languageTerm->getType()); + self::assertEquals('iso639-2b', $languageTerm->getAuthority()); + self::assertEquals('eng', $languageTerm->getValue()); + + $scriptTerm = $languages[0]->getScriptTerm(); + self::assertNotNull($languages[0]->getScriptTerm()); + self::assertEquals('code', $scriptTerm->getType()); + self::assertEquals('iso15924', $scriptTerm->getAuthority()); + self::assertEquals('Latn', $scriptTerm->getValue()); + } +} diff --git a/tests/Mods/Reader/RelatedItemReaderTest.php b/tests/Mods/Reader/RelatedItemReaderTest.php new file mode 100644 index 0000000..184f0fe --- /dev/null +++ b/tests/Mods/Reader/RelatedItemReaderTest.php @@ -0,0 +1,136 @@ +bookReader->getRelatedItems(); + self::assertEmpty($relatedItems); + } + + /** + * @test + */ + public function getNoRelatedItemForBookDocument() + { + $relatedItem = $this->bookReader->getRelatedItem(0); + self::assertNull($relatedItem); + } + + /** + * @test + */ + public function getNoFirstRelatedItemForBookDocument() + { + $relatedItem = $this->bookReader->getFirstRelatedItem(); + self::assertNull($relatedItem); + } + + /** + * @test + */ + public function getNoLastRelatedItemForBookDocument() + { + $relatedItem = $this->bookReader->getLastRelatedItem(); + self::assertNull($relatedItem); + } + + /** + * @test + */ + public function getRelatedItemsForSerialDocument() + { + $relatedItems = $this->serialReader->getRelatedItems(); + self::assertNotEmpty($relatedItems); + self::assertEquals(1, count($relatedItems)); + self::assertRelatedItemForSerialDocument($relatedItems[0]); + } + + /** + * @test + */ + public function getRelatedItemForSerialDocument() + { + $relatedItem = $this->serialReader->getRelatedItem(0); + self::assertRelatedItemForSerialDocument($relatedItem); + } + + /** + * @test + */ + public function getFirstRelatedItemForSerialDocument() + { + $relatedItem = $this->serialReader->getFirstRelatedItem(); + self::assertRelatedItemForSerialDocument($relatedItem); + } + + /** + * @test + */ + public function getLastRelatedItemForSerialDocument() + { + $relatedItem = $this->serialReader->getLastRelatedItem(); + self::assertRelatedItemForSerialDocument($relatedItem); + } + + /** + * @test + */ + public function getRelatedItemsByQueryForSerialDocument() + { + $relatedItems = $this->serialReader->getRelatedItems('[./mods:identifier="1525-321X"]'); + self::assertNotEmpty($relatedItems); + self::assertEquals(1, count($relatedItems)); + self::assertRelatedItemForSerialDocument($relatedItems[0]); + } + + /** + * @test + */ + public function getNoRelatedItemsByQueryForSerialDocument() + { + $relatedItems = $this->serialReader->getRelatedItems('[./mods:identifier="15-32"]'); + self::assertEmpty($relatedItems); + } + + private static function assertRelatedItemForSerialDocument(RelatedItem $relatedItem) + { + self::assertNotEmpty($relatedItem->getType()); + self::assertEquals('preceding', $relatedItem->getType()); + self::assertNotEmpty($relatedItem->getTitleInfos()); + self::assertEquals('Journal of southern academic and special librarianship', $relatedItem->getTitleInfos()[0]->getTitle()->getValue()); + self::assertNotEmpty($relatedItem->getOriginInfos()); + // TODO: implement back compatibility for 'publisher' element + // self::assertEquals('Journal of southern academic and special librarianship', $relatedItem->getOriginInfos()[0]->getPublisher()); + self::assertNotEmpty($relatedItem->getIdentifiers()); + self::assertEquals(4, count($relatedItem->getIdentifiers())); + self::assertEquals('1525-321X', $relatedItem->getIdentifiers()[0]->getValue()); + + $localIdentifiers = $relatedItem->getIdentifiers('[@type="local"]'); + self::assertNotEmpty($localIdentifiers); + self::assertEquals(3, count($localIdentifiers)); + self::assertEquals('(OCoLC)41477508', $localIdentifiers[0]->getValue()); + } +} diff --git a/tests/Mods/Reader/SubjectReaderTest.php b/tests/Mods/Reader/SubjectReaderTest.php new file mode 100644 index 0000000..90143ec --- /dev/null +++ b/tests/Mods/Reader/SubjectReaderTest.php @@ -0,0 +1,254 @@ +bookReader->getSubjects(); + self::assertNotEmpty($subjects); + self::assertEquals(8, count($subjects)); + self::assertFirstSubjectForBookDocument($subjects[0]); + } + + /** + * @test + */ + public function getSubjectForBookDocument() + { + $subjects = $this->bookReader->getSubject(1); + self::assertSecondSubjectForBookDocument($subjects); + } + + /** + * @test + */ + public function getFirstSubjectForBookDocument() + { + $subjects = $this->bookReader->getFirstSubject(); + self::assertFirstSubjectForBookDocument($subjects); + } + + /** + * @test + */ + public function getLastSubjectForBookDocument() + { + $subjects = $this->bookReader->getLastSubject(); + self::assertEightSubjectForBookDocument($subjects); + } + + /** + * @test + */ + public function getSubjectsByQueryForBookDocument() + { + $subjects = $this->bookReader->getSubjects('[./mods:topic="Mass media"]'); + self::assertNotEmpty($subjects); + self::assertEquals(1, count($subjects)); + self::assertFourthSubjectForBookDocument($subjects[0]); + } + + /** + * @test + */ + public function getSubjectByQueryForBookDocument() + { + $subject = $this->bookReader->getSubject(0, '[./mods:topic="Mass media"]'); + self::assertFourthSubjectForBookDocument($subject); + } + + /** + * @test + */ + public function getFirstSubjectByQueryForBookDocument() + { + $subject = $this->bookReader->getFirstSubject('[./mods:topic="Mass media"]'); + self::assertFourthSubjectForBookDocument($subject); + } + + /** + * @test + */ + public function getLastSubjectByQueryForBookDocument() + { + $subject = $this->bookReader->getLastSubject('[./mods:topic="Mass media"]'); + self::assertFourthSubjectForBookDocument($subject); + } + + /** + * @test + */ + public function getNoSubjectsByQueryForBookDocument() + { + $subjects = $this->bookReader->getSubjects('[./mods:topic="Unknown"]'); + self::assertEmpty($subjects); + } + + /** + * @test + */ + public function getNoSubjectByQueryForBookDocument() + { + $subject = $this->bookReader->getSubject(5, '[./mods:topic="Unknown"]'); + self::assertNull($subject); + } + + /** + * @test + */ + public function getNoFirstSubjectByQueryForBookDocument() + { + $subject = $this->bookReader->getFirstSubject(5, '[./mods:topic="Unknown"]'); + self::assertNull($subject); + } + + /** + * @test + */ + public function getNoLastSubjectByQueryForBookDocument() + { + $subject = $this->bookReader->getLastSubject('[./mods:topic="Unknown"]'); + self::assertNull($subject); + } + + /** + * @test + */ + public function getSubjectsForSerialDocument() + { + $subjects = $this->serialReader->getSubjects(); + self::assertNotEmpty($subjects); + self::assertEquals(7, count($subjects)); + self::assertNotEmpty($subjects[0]->getValue()); + self::assertNotEmpty($subjects[0]->getCartographics()); + + // TODO: implement reading of cartographics + /* + self::assertNotEmpty($subjects[0]->getCartographics()[0]->getCoordinates()); + self::assertEquals('', $subjects[0]->getCartographics()[0]->getCoordinates()[0]->getValue()); + self::assertNotEmpty($subjects[0]->getCartographics()[0]->getScale()); + self::assertNotEmpty($subjects[0]->getCartographics()[0]->getProjection()); + */ + } + + /** + * @test + */ + public function getSubjectsByQueryForSerialDocument() + { + $subjects = $this->serialReader->getSubjects('[./mods:genre="Directories"]'); + self::assertNotEmpty($subjects); + self::assertEquals(1, count($subjects)); + self::assertNotEmpty($subjects[0]->getValue()); + self::assertNotEmpty($subjects[0]->getTopics()); + self::assertEquals('Web sites', $subjects[0]->getTopics()[0]->getValue()); + self::assertNotEmpty($subjects[0]->getGenres()); + self::assertEquals('Directories', $subjects[0]->getGenres()[0]->getValue()); + } + + /** + * @test + */ + public function getNoSubjectsByQueryForSerialDocument() + { + $subjects = $this->serialReader->getSubjects('[./mods:topic="Unknown"]'); + self::assertEmpty($subjects); + } + + private static function assertFirstSubjectForBookDocument(Subject $subject) + { + self::assertNotEmpty($subject->getValue()); + + $hierarchicalGeographics = $subject->getHierarchicalGeographics(); + self::assertNotEmpty($hierarchicalGeographics); + + $countries = $hierarchicalGeographics[0]->getCountries(); + self::assertNotEmpty($countries); + self::assertEquals(2, count($countries)); + self::assertEquals(1, $countries[0]->getLevel()); + self::assertEquals('United Kingdom', $countries[0]->getValue()); + self::assertNotEmpty($hierarchicalGeographics[0]->getRegions()); + self::assertEquals('North West', $hierarchicalGeographics[0]->getRegions()[0]->getValue()); + self::assertNotEmpty($hierarchicalGeographics[0]->getCounties()); + self::assertEquals('Cumbria', $hierarchicalGeographics[0]->getCounties()[0]->getValue()); + self::assertNotEmpty($hierarchicalGeographics[0]->getCities()); + self::assertEquals('Providence', $hierarchicalGeographics[0]->getCities()[0]->getValue()); + + $citySections = $hierarchicalGeographics[0]->getCitySections(); + self::assertNotEmpty($citySections); + self::assertEquals(2, count($citySections)); + self::assertEquals('neighborhood', $citySections[0]->getType()); + self::assertEquals(1, $citySections[0]->getLevel()); + self::assertEquals('East Side', $citySections[0]->getValue()); + + $areas = $hierarchicalGeographics[0]->getAreas(); + self::assertNotEmpty($areas); + self::assertEquals('national park', $areas[0]->getType()); + self::assertEquals('Lake District', $areas[0]->getValue()); + } + + private static function assertSecondSubjectForBookDocument(Subject $subject) + { + self::assertNotEmpty($subject->getValue()); + + $geographicCodes = $subject->getGeographicCodes(); + self::assertNotEmpty($geographicCodes); + self::assertEquals('marcgac', $geographicCodes[0]->getAuthority()); + self::assertEquals('n-us---', $geographicCodes[0]->getValue()); + } + + private static function assertFourthSubjectForBookDocument(Subject $subject) + { + self::assertNotEmpty($subject->getValue()); + self::assertEquals('lcsh', $subject->getAuthority()); + + $topics = $subject->getTopics(); + self::assertNotEmpty($topics); + self::assertEquals('Mass media', $topics[0]->getValue()); + self::assertEquals('Political aspects', $topics[1]->getValue()); + + $geographics = $subject->getGeographics(); + self::assertNotEmpty($geographics); + self::assertEquals('United States', $geographics[0]->getValue()); + } + + private static function assertEightSubjectForBookDocument(Subject $subject) + { + self::assertNotEmpty($subject->getValue()); + self::assertEquals('lcsh', $subject->getAuthority()); + + $geographics = $subject->getGeographics(); + self::assertNotEmpty($geographics); + self::assertEquals('United States', $geographics[0]->getValue()); + + $topics = $subject->getTopics(); + self::assertNotEmpty($topics); + self::assertEquals('Politics and government', $topics[0]->getValue()); + + $temporals = $subject->getTemporals(); + self::assertNotEmpty($temporals); + self::assertEquals('20th century', $temporals[0]->getValue()); + } +} diff --git a/tests/Mods/Reader/TableOfContentsReaderTest.php b/tests/Mods/Reader/TableOfContentsReaderTest.php new file mode 100644 index 0000000..6f1aa74 --- /dev/null +++ b/tests/Mods/Reader/TableOfContentsReaderTest.php @@ -0,0 +1,154 @@ +bookReader->getTablesOfContents(); + self::assertNotEmpty($tablesOfContents); + self::assertEquals(1, count($tablesOfContents)); + self::assertTableOfContentsForBookDocument($tablesOfContents[0]); + } + + /** + * @test + */ + public function getTableOfContentsForBookDocument() + { + $tableOfContents = $this->bookReader->getTableOfContents(0); + self::assertTableOfContentsForBookDocument($tableOfContents); + } + + /** + * @test + */ + public function getFirstTableOfContentsForBookDocument() + { + $tableOfContents = $this->bookReader->getFirstTableOfContents(); + self::assertTableOfContentsForBookDocument($tableOfContents); + } + + /** + * @test + */ + public function getLastTableOfContentsForBookDocument() + { + $tableOfContents = $this->bookReader->getLastTableOfContents(); + self::assertTableOfContentsForBookDocument($tableOfContents); + } + + /** + * @test + */ + public function getTablesOfContentsByQueryForBookDocument() + { + $tablesOfContents = $this->bookReader->getTablesOfContents('[@displayLabel="Chapters"]'); + self::assertNotEmpty($tablesOfContents); + self::assertEquals(1, count($tablesOfContents)); + self::assertTableOfContentsForBookDocument($tablesOfContents[0]); + } + + /** + * @test + */ + public function getTableOfContentsByQueryForBookDocument() + { + $tableOfContents = $this->bookReader->getTableOfContents(0, '[@displayLabel="Chapters"]'); + self::assertTableOfContentsForBookDocument($tableOfContents); + } + + /** + * @test + */ + public function getFirstTableOfContentsByQueryForBookDocument() + { + $tableOfContents = $this->bookReader->getFirstTableOfContents('[@displayLabel="Chapters"]'); + self::assertTableOfContentsForBookDocument($tableOfContents); + } + + /** + * @test + */ + public function getLastTableOfContentsByQueryForBookDocument() + { + $tableOfContents = $this->bookReader->getLastTableOfContents('[@displayLabel="Chapters"]'); + self::assertTableOfContentsForBookDocument($tableOfContents); + } + + /** + * @test + */ + public function getNoTablesOfContentsByQueryForBookDocument() + { + $tablesOfContents = $this->bookReader->getTablesOfContents('[@displayLabel="Pages"]'); + self::assertEmpty($tablesOfContents); + } + + /** + * @test + */ + public function getNoTableOfContentsByQueryForBookDocument() + { + $tableOfContents = $this->bookReader->getTableOfContents(0, '[@displayLabel="Pages"]'); + self::assertNull($tableOfContents); + } + + /** + * @test + */ + public function getNoFirstTableOfContentsByQueryForBookDocument() + { + $tableOfContents = $this->bookReader->getFirstTableOfContents('[@displayLabel="Pages"]'); + self::assertNull($tableOfContents); + } + + /** + * @test + */ + public function getNoLastTableOfContentsByQueryForBookDocument() + { + $tableOfContents = $this->bookReader->getLastTableOfContents('[@displayLabel="Pages"]'); + self::assertNull($tableOfContents); + } + + /** + * @test + */ + public function getNoTablesOfContentsForSerialDocument() + { + $tablesOfContents = $this->serialReader->getTablesOfContents(); + self::assertEmpty($tablesOfContents); + } + + private static function assertTableOfContentsForBookDocument(TableOfContents $tableOfContents) + { + self::assertNotEmpty($tableOfContents->getValue()); + self::assertEquals('Bluegrass odyssey -- Hills of Tennessee -- Sassafrass -- Muddy river -- Take your shoes off Moses -- Let Smokey Mountain smoke get in your eyes -- Farewell party -- Faded love', $tableOfContents->getValue()); + self::assertNotEmpty($tableOfContents->getDisplayLabel()); + self::assertEquals('Chapters', $tableOfContents->getDisplayLabel()); + + // TODO: implement reading of elements + } +} diff --git a/tests/Mods/Reader/TitleInfoReader.php b/tests/Mods/Reader/TitleInfoReader.php new file mode 100644 index 0000000..3cf32c7 --- /dev/null +++ b/tests/Mods/Reader/TitleInfoReader.php @@ -0,0 +1,77 @@ +bookReader->getTitleInfos(); + self::assertNotEmpty($titleInfos); + self::assertEquals(2, count($titleInfos)); + self::assertNotEmpty($titleInfos[0]->getValue()); + self::assertEquals('Sound and fury', $titleInfos[0]->getTitle()->getValue()); + self::assertEquals('the making of the punditocracy', $titleInfos[0]->getSubTitle()->getValue()); + } + + public function testGetTitleInfosByQueryForBookDocument() + { + $titleInfos = $this->bookReader->getTitleInfos('[@xml:lang="fr"]'); + self::assertNotEmpty($titleInfos); + self::assertEquals(1, count($titleInfos)); + self::assertNotEmpty($titleInfos[0]->getValue()); + self::assertNotEmpty($titleInfos[0]->getType()); + self::assertEquals('translated', $titleInfos[0]->getType()); + self::assertNotEmpty($titleInfos[0]->getNonSort()); + self::assertEquals('Le', $titleInfos[0]->getNonSort()->getValue()); + self::assertNotEmpty($titleInfos[0]->getTitle()); + self::assertEquals('bruit et la fureur', $titleInfos[0]->getTitle()->getValue()); + self::assertNotEmpty($titleInfos[0]->getSubTitle()); + self::assertEquals('la création de la punditocratie', $titleInfos[0]->getSubTitle()->getValue()); + } + + public function testGetTitleInfosForSerialDocument() + { + $titleInfos = $this->serialReader->getTitleInfos(); + self::assertNotEmpty($titleInfos); + self::assertEquals(3, count($titleInfos)); + self::assertNotEmpty($titleInfos[0]->getValue()); + self::assertNotEmpty($titleInfos[0]->getTitle()); + self::assertEquals('E-JASL', $titleInfos[0]->getTitle()->getValue()); + self::assertNotEmpty($titleInfos[0]->getSubTitle()); + self::assertEquals('the electronic journal of academic and special librarianship', $titleInfos[0]->getSubTitle()->getValue()); + } + + public function testGetTitleInfosByQueryForSerialDocument() + { + $titleInfos = $this->serialReader->getTitleInfos('[@type="abbreviated"]'); + self::assertNotEmpty($titleInfos); + self::assertEquals(1, count($titleInfos)); + self::assertNotEmpty($titleInfos[0]->getValue()); + self::assertEquals('E-JASL', $titleInfos[0]->getTitle()->getValue()); + self::assertNotEmpty($titleInfos[0]->getSubTitle()); + self::assertEquals('(Athabasca)', $titleInfos[0]->getSubTitle()->getValue()); + } + + public function testGetNoTitleInfosByQueryForSerialDocument() + { + $titleInfos = $this->serialReader->getTitleInfos('[@type="uniform"]'); + self::assertEmpty($titleInfos); + } +} diff --git a/tests/Mods/Reader/TypeOfResourceTest.php b/tests/Mods/Reader/TypeOfResourceTest.php new file mode 100644 index 0000000..6b5627c --- /dev/null +++ b/tests/Mods/Reader/TypeOfResourceTest.php @@ -0,0 +1,80 @@ +bookReader->getTypeOfResource(); + self::assertTypeOfResourceForBookDocument($typeOfResource); + } + + /** + * @test + */ + public function getTypeOfResourceByQueryForBookDocument() + { + $typeOfResource = $this->bookReader->getTypeOfResource('[@displayLabel="format"]'); + self::assertTypeOfResourceForBookDocument($typeOfResource); + } + + /** + * @test + */ + public function getNoTypeOfResourceByQueryForBookDocument() + { + $typeOfResource = $this->bookReader->getTypeOfResource('[@displayLabel="random"]'); + self::assertNull($typeOfResource); + } + + /** + * @test + */ + public function getTypeOfResourceForSerialDocument() + { + $typeOfResource = $this->serialReader->getTypeOfResource(); + self::assertNotNull($typeOfResource); + self::assertEmpty($typeOfResource->getDisplayLabel()); + self::assertNotEmpty($typeOfResource->getValue()); + self::assertEquals('text', $typeOfResource->getValue()); + } + + /** + * @test + */ + public function getNoTypeOfResourceByQueryForSerialDocument() + { + $abstract = $this->serialReader->getAbstract('[@displayForm="format"]'); + self::assertNull($abstract); + } + + private static function assertTypeOfResourceForBookDocument(TypeOfResource $typeOfResource) + { + self::assertNotNull($typeOfResource); + self::assertNotEmpty($typeOfResource->getDisplayLabel()); + self::assertEquals('format', $typeOfResource->getDisplayLabel()); + self::assertNotEmpty($typeOfResource->getValue()); + self::assertEquals('text', $typeOfResource->getValue()); + } +}