From e9ff2fb4840f030debd77cf7efa7ae51b7457257 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 | 76 + .../Mods/Reader/AccessConditionReaderTest.php | 137 ++ .../Mods/Reader/ClassificationReaderTest.php | 138 ++ tests/Mods/Reader/ExtensionReaderTest.php | 36 + tests/Mods/Reader/GenreReaderTest.php | 183 ++ tests/Mods/Reader/IdentifierReaderTest.php | 241 +++ tests/Mods/Reader/LanguageReaderTest.php | 175 ++ tests/Mods/Reader/LocationReaderTest.php | 169 ++ tests/Mods/Reader/NameReaderTest.php | 183 ++ tests/Mods/Reader/NoteReaderTest.php | 178 ++ tests/Mods/Reader/OriginInfoReaderTest.php | 198 +++ tests/Mods/Reader/PartReaderTest.php | 144 ++ .../Reader/PhysicalDescriptionReaderTest.php | 118 ++ tests/Mods/Reader/RecordInfoReaderTest.php | 173 ++ tests/Mods/Reader/RelatedItemReaderTest.php | 94 ++ tests/Mods/Reader/SubjectReaderTest.php | 121 ++ .../Mods/Reader/TableOfContentsReaderTest.php | 60 + tests/Mods/Reader/TitleInfoReader.php | 77 + tests/Mods/Reader/TypeOfResourceTest.php | 63 + 20 files changed, 2568 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..29eb202 --- /dev/null +++ b/tests/Mods/Reader/AbstractReaderTest.php @@ -0,0 +1,76 @@ +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); + } +} diff --git a/tests/Mods/Reader/AccessConditionReaderTest.php b/tests/Mods/Reader/AccessConditionReaderTest.php new file mode 100644 index 0000000..7bc29bc --- /dev/null +++ b/tests/Mods/Reader/AccessConditionReaderTest.php @@ -0,0 +1,137 @@ +bookReader->getAccessConditions(); + self::assertNotEmpty($accessConditions); + self::assertEquals(1, count($accessConditions)); + self::assertAccessConditionForBookDocument($accessConditions[0]); + } + + public function testGetAccessConditionForBookDocument() + { + $accessCondition = $this->bookReader->getAccessCondition(0); + self::assertAccessConditionForBookDocument($accessCondition); + } + + public function testGetFirstAccessConditionForBookDocument() + { + $accessCondition = $this->bookReader->getFirstAccessCondition(); + self::assertAccessConditionForBookDocument($accessCondition); + } + + public function testGetLastAccessConditionForBookDocument() + { + $accessCondition = $this->bookReader->getLastAccessCondition(); + self::assertAccessConditionForBookDocument($accessCondition); + } + + public function testGetAccessConditionsByQueryForBookDocument() + { + $accessConditions = $this->bookReader->getAccessConditions('[@type="use and reproduction"]'); + self::assertNotEmpty($accessConditions); + self::assertEquals(1, count($accessConditions)); + self::assertAccessConditionForBookDocument($accessConditions[0]); + } + + public function testGetFirstAccessConditionByQueryForBookDocument() + { + $accessCondition = $this->bookReader->getFirstAccessCondition('[@type="use and reproduction"]'); + self::assertAccessConditionForBookDocument($accessCondition); + } + + public function testGetLastAccessConditionByQueryForBookDocument() + { + $accessCondition = $this->bookReader->getLastAccessCondition('[@type="use and reproduction"]'); + self::assertAccessConditionForBookDocument($accessCondition); + } + + public function testGetNoAccessConditionsByQueryForBookDocument() + { + $accessConditions = $this->bookReader->getAccessConditions('[@type="restriction on access"]'); + self::assertEmpty($accessConditions); + } + + public function testGetNoAccessConditionByQueryForBookDocument() + { + $accessCondition = $this->bookReader->getAccessCondition(1, '[@type="restriction on access"]'); + self::assertNull($accessCondition); + } + + public function testGetNoFirstAccessConditionsByQueryForBookDocument() + { + $accessCondition = $this->bookReader->getFirstAccessCondition('[@type="restriction on access"]'); + self::assertNull($accessCondition); + } + + public function testGetNoLastAccessConditionsByQueryForBookDocument() + { + $accessCondition = $this->bookReader->getLastAccessCondition('[@type="restriction on access"]'); + self::assertNull($accessCondition); + } + + public function testGetAccessConditionsForSerialDocument() + { + $accessConditions = $this->serialReader->getAccessConditions(); + self::assertNotEmpty($accessConditions); + self::assertEquals(1, count($accessConditions)); + self::assertAccessConditionForSerialDocument($accessConditions[0]); + } + + public function testGetAccessConditionsByQueryForSerialDocument() + { + $accessConditions = $this->serialReader->getAccessConditions('[@type="restriction on access"]'); + self::assertNotEmpty($accessConditions); + self::assertEquals(1, count($accessConditions)); + self::assertAccessConditionForSerialDocument($accessConditions[0]); + } + + public function testGetNoAccessConditionsByQueryForSerialDocument() + { + $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..80e961a --- /dev/null +++ b/tests/Mods/Reader/ClassificationReaderTest.php @@ -0,0 +1,138 @@ +bookReader->getClassifications(); + self::assertNotEmpty($classifications); + self::assertEquals(2, count($classifications)); + self::assertFirstClassificationForBookDocument($classifications[0]); + } + + public function testGetClassificationForBookDocument() + { + $classification = $this->bookReader->getClassification(0); + self::assertFirstClassificationForBookDocument($classification); + } + + public function testGetFirstClassificationForBookDocument() + { + $classification = $this->bookReader->getFirstClassification(); + self::assertFirstClassificationForBookDocument($classification); + } + + public function testGetLastClassificationForBookDocument() + { + $classification = $this->bookReader->getLastClassification(); + self::assertSecondClassificationForBookDocument($classification); + } + + public function testGetClassificationsByQueryForBookDocument() + { + $classifications = $this->bookReader->getClassifications('[@authority="ddc"]'); + self::assertNotEmpty($classifications); + self::assertEquals(1, count($classifications)); + self::assertSecondClassificationForBookDocument($classifications[0]); + } + + public function testGetNoClassificationsByQueryForBookDocument() + { + $classifications = $this->bookReader->getClassifications('[@generator="xyz"]'); + self::assertEmpty($classifications); + } + + public function testGetNoClassificationByQueryForBookDocument() + { + $classification = $this->bookReader->getClassification(1, '[@generator="xyz"]'); + self::assertNull($classification); + } + + public function testGetNoFirstClassificationByQueryForBookDocument() + { + $classification = $this->bookReader->getFirstClassification('[@generator="xyz"]'); + self::assertNull($classification); + + $lastClassification = $this->bookReader->getLastClassification('[@generator="xyz"]'); + self::assertNull($lastClassification); + } + + public function testGetNoLastClassificationByQueryForBookDocument() + { + $classification = $this->bookReader->getLastClassification('[@generator="xyz"]'); + self::assertNull($classification); + } + + public function testGetClassificationsForSerialDocument() + { + $classifications = $this->serialReader->getClassifications(); + self::assertNotEmpty($classifications); + self::assertEquals(1, count($classifications)); + self::assertClassificationForSerialDocument($classifications[0]); + } + + public function testGetClassificationsByQueryForSerialDocument() + { + $classifications = $this->serialReader->getClassifications('[@authority="ddc"]'); + self::assertNotEmpty($classifications); + self::assertEquals(1, count($classifications)); + self::assertClassificationForSerialDocument($classifications[0]); + } + + public function testGetNoClassificationsByQueryForSerialDocument() + { + $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..b5fd3d1 --- /dev/null +++ b/tests/Mods/Reader/ExtensionReaderTest.php @@ -0,0 +1,36 @@ +bookReader->getExtensions(); + + $this->assertTrue(true, 'WIP'); + } + + public function testGetExtensionsForSerialDocument() + { + $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..1848f9c --- /dev/null +++ b/tests/Mods/Reader/GenreReaderTest.php @@ -0,0 +1,183 @@ +bookReader->getGenres(); + self::assertNotEmpty($genres); + self::assertEquals(1, count($genres)); + self::assertGenreForBookDocument($genres[0]); + } + + public function testGetGenreForBookDocument() + { + $genre = $this->bookReader->getGenre(0); + self::assertGenreForBookDocument($genre); + } + + public function testGetFirstGenreForBookDocument() + { + $genre = $this->bookReader->getFirstGenre(); + self::assertGenreForBookDocument($genre); + } + + public function testGetLastGenreForBookDocument() + { + $genre = $this->bookReader->getLastGenre(); + self::assertGenreForBookDocument($genre); + } + + public function testGetGenresByQueryForBookDocument() + { + $genres = $this->bookReader->getGenres('[@authority="marcgt"]'); + self::assertNotEmpty($genres); + self::assertEquals(1, count($genres)); + self::assertGenreForBookDocument($genres[0]); + } + + public function testGetGenreByQueryForBookDocument() + { + $genre = $this->bookReader->getGenre(0, '[@authority="marcgt"]'); + self::assertGenreForBookDocument($genre); + } + + public function testGetFirstGenreByQueryForBookDocument() + { + $genre = $this->bookReader->getFirstGenre('[@authority="marcgt"]'); + self::assertGenreForBookDocument($genre); + } + + public function testGetLastGenreByQueryForBookDocument() + { + $genre = $this->bookReader->getLastGenre('[@authority="marcgt"]'); + self::assertGenreForBookDocument($genre); + } + + 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 testGetNoGenreByQueryForBookDocument() + { + $genre = $this->bookReader->getGenre(0, '[@authority="merc"]'); + self::assertNull($genre); + } + + public function testGetNoFirstGenreByQueryForBookDocument() + { + $genre = $this->bookReader->getFirstGenre('[@authority="merc"]'); + self::assertNull($genre); + + $lastGenre = $this->bookReader->getLastGenre('[@authority="merc"]'); + self::assertNull($lastGenre); + } + + public function testGetNoLastGenreByQueryForBookDocument() + { + $genre = $this->bookReader->getLastGenre('[@authority="merc"]'); + self::assertNull($genre); + } + + public function testGetGenresForSerialDocument() + { + $genres = $this->serialReader->getGenres(); + self::assertNotEmpty($genres); + self::assertEquals(2, count($genres)); + self::assertFirstGenreForSerialDocument($genres[0]); + + $firstGenre = $this->serialReader->getFirstGenre(); + self::assertEquals($genres[0], $firstGenre); + + $lastGenre = $this->serialReader->getLastGenre(); + self::assertEquals($genres[1], $lastGenre); + } + + public function testGetGenreForSerialDocument() + { + $genre = $this->serialReader->getGenre(0); + self::assertFirstGenreForSerialDocument($genre); + } + + public function testGetFirstGenreForSerialDocument() + { + $genre = $this->serialReader->getFirstGenre(); + self::assertFirstGenreForSerialDocument($genre); + } + + public function testGetLastGenreForSerialDocument() + { + $genre = $this->serialReader->getLastGenre(); + self::assertSecondGenreForSerialDocument($genre); + } + + public function testGetGenresByQueryForSerialDocument() + { + $genres = $this->serialReader->getGenres('[@usage="primary"]'); + self::assertNotEmpty($genres); + self::assertEquals(1, count($genres)); + self::assertFirstGenreForSerialDocument($genres[0]); + } + + public function testGetNoGenresByQueryForSerialDocument() + { + $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..010ab24 --- /dev/null +++ b/tests/Mods/Reader/IdentifierReaderTest.php @@ -0,0 +1,241 @@ +bookReader->getIdentifiers(); + self::assertNotEmpty($identifiers); + self::assertEquals(2, count($identifiers)); + self::assertFirstIdentifierForBookDocument($identifiers[0]); + } + + public function testGetIdentifierForBookDocument() + { + $identifier = $this->bookReader->getIdentifier(0); + self::assertFirstIdentifierForBookDocument($identifier); + } + + public function testGetFirstIdentifierForBookDocument() + { + $identifier = $this->bookReader->getFirstIdentifier(); + self::assertFirstIdentifierForBookDocument($identifier); + } + + public function testGetLastIdentifierForBookDocument() + { + $identifier = $this->bookReader->getLastIdentifier(); + self::assertSecondIdentifierForBookDocument($identifier); + } + + public function testGetIdentifiersByQueryForBookDocument() + { + $identifiers = $this->bookReader->getIdentifiers('[@type="lccn"]'); + self::assertNotEmpty($identifiers); + self::assertEquals(1, count($identifiers)); + self::assertSecondIdentifierForBookDocument($identifiers[0]); + } + + public function testGetIdentifierByQueryForBookDocument() + { + $identifier = $this->bookReader->getIdentifier(0, '[@type="lccn"]'); + self::assertSecondIdentifierForBookDocument($identifier); + } + + public function testGetFirstIdentifierByQueryForBookDocument() + { + $identifier = $this->bookReader->getFirstIdentifier('[@type="lccn"]'); + self::assertSecondIdentifierForBookDocument($identifier); + } + + public function testGetLastIdentifierByQueryForBookDocument() + { + $identifier = $this->bookReader->getLastIdentifier('[@type="lccn"]'); + self::assertSecondIdentifierForBookDocument($identifier); + } + + public function testGetNoIdentifiersByQueryForBookDocument() + { + $identifiers = $this->bookReader->getIdentifiers('[@type="xyz"]'); + self::assertEmpty($identifiers); + } + + public function testGetNoIdentifierByQueryForBookDocument() + { + $identifier = $this->bookReader->getIdentifier(5, '[@type="lccn"]'); + self::assertNull($identifier); + } + + public function testGetNoFirstIdentifierByQueryForBookDocument() + { + $identifier = $this->bookReader->getFirstIdentifier('[@type="xyz"]'); + self::assertNull($identifier); + } + + public function testGetNoLastIdentifierByQueryForBookDocument() + { + $identifier = $this->bookReader->getLastIdentifier('[@type="xyz"]'); + self::assertNull($identifier); + } + + public function testGetIdentifiersForSerialDocument() + { + $identifiers = $this->serialReader->getIdentifiers(); + self::assertNotEmpty($identifiers); + self::assertEquals(4, count($identifiers)); + self::assertFirstIdentifierForSerialDocument($identifiers[0]); + } + + public function testGetIdentifierForSerialDocument() + { + $identifier = $this->serialReader->getIdentifier(2); + self::assertThirdIdentifierForSerialDocument($identifier); + } + + public function testGetFirstIdentifierForSerialDocument() + { + $identifier = $this->serialReader->getFirstIdentifier(); + self::assertFirstIdentifierForSerialDocument($identifier); + } + + public function testGetLastIdentifierForSerialDocument() + { + $identifier = $this->serialReader->getLastIdentifier(); + self::assertFourthIdentifierForSerialDocument($identifier); + } + + public function testGetIdentifiersByQueryForSerialDocument() + { + $identifiers = $this->serialReader->getIdentifiers('[@type="issn"]'); + self::assertNotEmpty($identifiers); + self::assertEquals(2, count($identifiers)); + self::assertSecondIdentifierForSerialDocument($identifiers[1]); + } + + public function testGetIdentifierByQueryForSerialDocument() + { + $identifier = $this->serialReader->getIdentifier(0, '[@type="issn"]'); + self::assertFirstIdentifierForSerialDocument($identifier); + } + + public function testGetFirstIdentifierByQueryForSerialDocument() + { + $identifier = $this->serialReader->getFirstIdentifier('[@type="lccn"]'); + self::assertThirdIdentifierForSerialDocument($identifier); + } + + public function testGetLastIdentifierByQueryForSerialDocument() + { + $identifier = $this->serialReader->getLastIdentifier('[@type="lccn"]'); + self::assertThirdIdentifierForSerialDocument($identifier); + } + + public function testGetNoIdentifiersByQueryForSerialDocument() + { + $identifiers = $this->serialReader->getIdentifiers('[@type="xyz"]'); + self::assertEmpty($identifiers); + } + + public function testGetNoIdentifierByQueryForSerialDocument() + { + $identifier = $this->serialReader->getIdentifier(2, '[@type="xyz"]'); + self::assertNull($identifier); + } + + public function testGetNoFirstIdentifierByQueryForSerialDocument() + { + $identifier = $this->serialReader->getFirstIdentifier('[@type="xyz"]'); + self::assertNull($identifier); + } + + public function testGetNoLastIdentifierByQueryForSerialDocument() + { + $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..05ca84d --- /dev/null +++ b/tests/Mods/Reader/LanguageReaderTest.php @@ -0,0 +1,175 @@ +bookReader->getLanguages(); + self::assertNotEmpty($languages); + self::assertEquals(2, count($languages)); + self::assertFirstLanguageForBookDocument($languages[0]); + } + + public function testGetLanguageForBookDocument() + { + $language = $this->bookReader->getLanguage(0); + self::assertFirstLanguageForBookDocument($language); + } + + public function testGetFirstLanguageForBookDocument() + { + $language = $this->bookReader->getFirstLanguage(); + self::assertFirstLanguageForBookDocument($language); + } + + public function testGetLastLanguageForBookDocument() + { + $language = $this->bookReader->getLastLanguage(); + self::assertSecondLanguageForBookDocument($language); + } + + public function testGetLanguagesByQueryForBookDocument() + { + $languages = $this->bookReader->getLanguages('[@objectPart="summary"]'); + self::assertNotEmpty($languages); + self::assertEquals(1, count($languages)); + self::assertSecondLanguageForBookDocument($languages[0]); + } + + public function testGetLanguageByQueryForBookDocument() + { + $language = $this->bookReader->getLanguage(0, '[@objectPart="summary"]'); + self::assertSecondLanguageForBookDocument($language); + } + + public function testGetFirstLanguageByQueryForBookDocument() + { + $language = $this->bookReader->getFirstLanguage('[@objectPart="summary"]'); + self::assertSecondLanguageForBookDocument($language); + } + + public function testGetLastLanguageByQueryForBookDocument() + { + $language = $this->bookReader->getLastLanguage('[@objectPart="summary"]'); + self::assertSecondLanguageForBookDocument($language); + } + + public function testGetNoLanguagesByQueryForBookDocument() + { + $languages = $this->bookReader->getLanguages('[@objectPart="abstract"]'); + self::assertEmpty($languages); + } + + public function testGetNoLanguageByQueryForBookDocument() + { + $language = $this->bookReader->getLanguage(0, '[@objectPart="abstract"]'); + self::assertNull($language); + } + + public function testGetNoFirstLanguageByQueryForBookDocument() + { + $language = $this->bookReader->getFirstLanguage('[@objectPart="abstract"]'); + self::assertNull($language); + } + + public function testGetNoLastLanguageByQueryForBookDocument() + { + $language = $this->bookReader->getLastLanguage('[@objectPart="abstract"]'); + self::assertNull($language); + } + + public function testGetLanguagesForSerialDocument() + { + $languages = $this->serialReader->getLanguages(); + self::assertNotEmpty($languages); + self::assertEquals(1, count($languages)); + self::assertLanguageForSerialDocument($languages[0]); + } + + public function testGetLanguagesByQueryForSerialDocument() + { + $languages = $this->serialReader->getLanguages('[./mods:languageTerm[@type="code"]]'); + self::assertNotEmpty($languages); + self::assertEquals(1, count($languages)); + self::assertLanguageForSerialDocument($languages[0]); + } + + public function testGetNoLanguagesByQueryForSerialDocument() + { + $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..1971002 --- /dev/null +++ b/tests/Mods/Reader/LocationReaderTest.php @@ -0,0 +1,169 @@ +bookReader->getLocations(); + self::assertNotEmpty($locations); + self::assertEquals(2, count($locations)); + self::assertFirstLocationForBookDocument($locations[0]); + } + + public function testGetLocationForBookDocument() + { + $location = $this->bookReader->getLocation(1); + self::assertSecondLocationForBookDocument($location); + } + + public function testGetFirstLocationForBookDocument() + { + $location = $this->bookReader->getFirstLocation(); + self::assertFirstLocationForBookDocument($location); + } + + public function testGetLastLocationForBookDocument() + { + $location = $this->bookReader->getLastLocation(); + self::assertSecondLocationForBookDocument($location); + } + + public function testGetLocationsByQueryForBookDocument() + { + $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(); + } + + public function testGetLocationByQueryForBookDocument() + { + $location = $this->bookReader->getLocation(0, '[@displayLabel="links"]'); + self::assertSecondLocationForBookDocument($location); + } + + public function testGetFirstLocationByQueryForBookDocument() + { + $location = $this->bookReader->getFirstLocation('[@displayLabel="links"]'); + self::assertSecondLocationForBookDocument($location); + } + + public function testGetLastLocationForByQueryBookDocument() + { + $location = $this->bookReader->getLastLocation('[@displayLabel="links"]'); + self::assertSecondLocationForBookDocument($location); + } + + public function testGetNoLocationsByQueryForBookDocument() + { + $locations = $this->bookReader->getLocations('[@displayLabel="random"]'); + self::assertEmpty($locations); + } + + public function testGetNoLocationByQueryForBookDocument() + { + $location = $this->bookReader->getLocation(6, '[@displayLabel="links"]'); + self::assertNull($location); + } + + public function testGetNoFirstLocationByQueryForBookDocument() + { + $location = $this->bookReader->getFirstLocation('[@displayLabel="random"]'); + self::assertNull($location); + } + + public function testGetNoLastLocationByQueryForBookDocument() + { + $location = $this->bookReader->getLastLocation('[@displayLabel="random"]'); + self::assertNull($location); + } + + public function testGetLocationsForSerialDocument() + { + $locations = $this->serialReader->getLocations(); + self::assertNotEmpty($locations); + self::assertEquals(2, count($locations)); + self::assertLocationForSerialDocument($locations[0]); + } + + public function testGetLocationsByQueryForSerialDocument() + { + $locations = $this->serialReader->getLocations('[./mods:url[@usage="primaryDisplay"]]'); + self::assertNotEmpty($locations); + self::assertEquals(1, count($locations)); + self::assertLocationForSerialDocument($locations[0]); + } + + public function testNoGetLocationsByQueryForSerialDocument() + { + $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..02f7d4b --- /dev/null +++ b/tests/Mods/Reader/NameReaderTest.php @@ -0,0 +1,183 @@ +bookReader->getNames(); + self::assertNotEmpty($names); + self::assertEquals(2, count($names)); + self::assertFirstNameForBookDocument($names[0]); + + $firstName = $this->bookReader->getFirstName(); + self::assertEquals($names[0], $firstName); + + $lastName = $this->bookReader->getLastName(); + self::assertEquals($names[1], $lastName); + } + + public function testGetNameForBookDocument() + { + $name = $this->bookReader->getName(1); + self::assertSecondNameForBookDocument($name); + + } + + public function testGetFirstNameForBookDocument() + { + $name = $this->bookReader->getFirstName(); + self::assertFirstNameForBookDocument($name); + } + + public function testGetLastNameForBookDocument() + { + $name = $this->bookReader->getLastName(); + self::assertSecondNameForBookDocument($name); + } + + public function testGetNamesByQueryForBookDocument() + { + $names = $this->bookReader->getNames('[@type="personal" and not(@usage="primary")]'); + self::assertNotEmpty($names); + self::assertEquals(1, count($names)); + self::assertSecondNameForBookDocument($names[0]); + } + + public function testGetNameByQueryForBookDocument() + { + $name = $this->bookReader->getName(0, '[@type="personal" and not(@usage="primary")]'); + self::assertSecondNameForBookDocument($name); + } + + public function testGetFirstNameByQueryForBookDocument() + { + $name = $this->bookReader->getFirstName('[@type="personal" and not(@usage="primary")]'); + self::assertSecondNameForBookDocument($name); + } + + public function testGetLastNameByQueryForBookDocument() + { + $name = $this->bookReader->getLastName('[@type="personal" and not(@usage="primary")]'); + self::assertSecondNameForBookDocument($name); + } + + public function testGetNoNamesByQueryForBookDocument() + { + $names = $this->bookReader->getNames('[@type="corporate"]'); + self::assertEmpty($names); + } + + public function testGetNoNameByQueryForBookDocument() + { + $name = $this->bookReader->getName(3, '[@type="corporate"]'); + self::assertNull($name); + } + + public function testGetNoFirstNameByQueryForBookDocument() + { + $name = $this->bookReader->getFirstName('[@type="corporate"]'); + self::assertNull($name); + } + + public function testGetNoLastNameByQueryForBookDocument() + { + $name = $this->bookReader->getLastName('[@type="corporate"]'); + self::assertNull($name); + } + + public function testGetNamesForSerialDocument() + { + $names = $this->serialReader->getNames(); + self::assertNotEmpty($names); + self::assertEquals(1, count($names)); + self::assertNameForSerialDocument($names[0]); + } + + public function testGetNamesByQueryForSerialDocument() + { + $names = $this->serialReader->getNames('[@type="corporate"]'); + self::assertNotEmpty($names); + self::assertEquals(1, count($names)); + self::assertNameForSerialDocument($names[0]); + } + + public function testGetNoNamesByQueryForSerialDocument() + { + $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..9210b95 --- /dev/null +++ b/tests/Mods/Reader/NoteReaderTest.php @@ -0,0 +1,178 @@ +bookReader->getNotes(); + self::assertNotEmpty($notes); + self::assertEquals(2, count($notes)); + self::assertFirstNoteForBookDocument($notes[0]); + } + + public function testGetNoteForBookDocument() + { + $note = $this->bookReader->getNote(1); + self::assertSecondNoteForBookDocument($note); + } + + public function testGetFirstNoteForBookDocument() + { + $note = $this->bookReader->getFirstNote(); + self::assertFirstNoteForBookDocument($note); + } + + public function testGetLastNoteForBookDocument() + { + $note = $this->bookReader->getLastNote(); + self::assertSecondNoteForBookDocument($note); + } + + public function testGetNotesByQueryForBookDocument() + { + $notes = $this->bookReader->getNotes('[@type="bibliography"]'); + self::assertNotEmpty($notes); + self::assertEquals(1, count($notes)); + self::assertSecondNoteForBookDocument($notes[0]); + } + + public function testGetNoteByQueryForBookDocument() + { + $note = $this->bookReader->getNote(0, '[@type="bibliography"]'); + self::assertFirstNoteForBookDocument($note); + } + + public function testGetFirstNoteByQueryForBookDocument() + { + $note = $this->bookReader->getFirstNote('[@type="bibliography"]'); + self::assertFirstNoteForBookDocument($note); + } + + public function testGetLastNoteByQueryForBookDocument() + { + $note = $this->bookReader->getLastNote('[@type="bibliography"]'); + self::assertFirstNoteForBookDocument($note); + } + + public function testGetNoNotesByQueryForBookDocument() + { + $notes = $this->bookReader->getNotes('[@type="xyz"]'); + self::assertEmpty($notes); + } + + public function testGetNoNoteByQueryForBookDocument() + { + $note = $this->bookReader->getNote(0, '[@type="xyz"]'); + self::assertNull($note); + } + + public function testGetNoFirstNoteByQueryForBookDocument() + { + $note = $this->bookReader->getFirstNote('[@type="xyz"]'); + self::assertNull($note); + } + + public function testGetNoLastNoteByQueryForBookDocument() + { + $note = $this->bookReader->getLastNote('[@type="xyz"]'); + self::assertNull($note); + } + + public function testGetNotesForSerialDocument() + { + $notes = $this->serialReader->getNotes(); + self::assertNotEmpty($notes); + self::assertEquals(6, count($notes)); + self::assertFirstNoteForBookDocument($notes[0]); + } + + public function testGetNoteForSerialDocument() + { + $note = $this->serialReader->getNote(5); + self::assertSixthNoteForSerialDocument($note); + } + + public function testGetFirstNoteForSerialDocument() + { + $note = $this->serialReader->getFirstNote(); + self::assertFirstNoteForSerialDocument($note); + } + + public function testGetLastNoteForSerialDocument() + { + $note = $this->serialReader->getLastNote(); + self::assertSixthNoteForSerialDocument($note); + } + + public function testGetNotesByQueryForSerialDocument() + { + $notes = $this->serialReader->getNotes('[@type="system details"]'); + self::assertNotEmpty($notes); + self::assertEquals(1, count($notes)); + self::assertFifthNoteForSerialDocument($notes[0]); + } + + public function testGetNoNotesByQueryForSerialDocument() + { + $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..bdfc313 --- /dev/null +++ b/tests/Mods/Reader/OriginInfoReaderTest.php @@ -0,0 +1,198 @@ +bookReader->getOriginInfos(); + self::assertNotEmpty($originInfos); + self::assertEquals(2, count($originInfos)); + self::assertFirstOriginInfoForBookDocument($originInfos[0]); + } + + public function testGetOriginInfoForBookDocument() + { + $originInfo = $this->bookReader->getOriginInfo(1); + self::assertSecondOriginInfoForBookDocument($originInfo); + } + + public function testGetFirstOriginInfoForBookDocument() + { + $originInfo = $this->bookReader->getFirstOriginInfo(); + self::assertFirstOriginInfoForBookDocument($originInfo); + } + + public function testGetLastOriginInfoForBookDocument() + { + $originInfo = $this->bookReader->getLastOriginInfo(); + self::assertSecondOriginInfoForBookDocument($originInfo); + } + + public function testGetOriginInfosByQueryForBookDocument() + { + $originInfos = $this->bookReader->getOriginInfos('[@eventType="redaction"]'); + self::assertNotEmpty($originInfos); + self::assertEquals(1, count($originInfos)); + self::assertSecondOriginInfoForBookDocument($originInfos[0]); + } + + 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 testGetNoOriginInfoByQueryForBookDocument() + { + $originInfo = $this->bookReader->getOriginInfo(4, '[@eventType="xyz"]'); + self::assertNull($originInfo); + } + + public function testGetNoFirstOriginInfoByQueryForBookDocument() + { + $originInfo = $this->bookReader->getFirstOriginInfo('[@eventType="xyz"]'); + self::assertNull($originInfo); + } + + public function testGetNoLastOriginInfoByQueryForBookDocument() + { + $originInfo = $this->bookReader->getLastOriginInfo('[@eventType="xyz"]'); + self::assertNull($originInfo); + } + + public function testGetOriginInfosForSerialDocument() + { + $originInfos = $this->serialReader->getOriginInfos(); + self::assertNotEmpty($originInfos); + self::assertEquals(1, count($originInfos)); + self::assertOriginInfoForSerialDocument($originInfos[0]); + } + + public function testGetOriginInfosByQueryForSerialDocument() + { + $originInfos = $this->serialReader->getOriginInfos('[@eventType="publication"]'); + self::assertNotEmpty($originInfos); + self::assertEquals(1, count($originInfos)); + self::assertOriginInfoForSerialDocument($originInfos[0]); + } + + public function testGetNoOriginInfosByQueryForSerialDocument() + { + $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..f8bd103 --- /dev/null +++ b/tests/Mods/Reader/PartReaderTest.php @@ -0,0 +1,144 @@ +bookReader->getParts(); + self::assertNotEmpty($parts); + self::assertEquals(2, count($parts)); + self::assertFirstPartForBookDocument($parts[0]); + } + + public function testGetPartForBookDocument() + { + $part = $this->bookReader->getPart(1); + self::assertSecondPartForBookDocument($part); + + } + + public function testGetFirstPartForBookDocument() + { + $part = $this->bookReader->getFirstPart(); + self::assertFirstPartForBookDocument($part); + } + + public function testGetLastPartForBookDocument() + { + $part = $this->bookReader->getLastPart(); + self::assertSecondPartForBookDocument($part); + + } + + public function testGetPartsByQueryForBookDocument() + { + $parts = $this->bookReader->getParts('[@order="2"]'); + self::assertNotEmpty($parts); + self::assertEquals(1, count($parts)); + self::assertSecondPartForBookDocument($parts[0]); + } + + public function testGetNoPartsByQueryForBookDocument() + { + $parts = $this->bookReader->getParts('[@order="3"]'); + self::assertEmpty($parts); + } + + public function testGetNoPartByQueryForBookDocument() + { + $part = $this->bookReader->getPart(0, '[@order="3"]'); + self::assertNull($part); + } + + public function testGetNoFirstPartByQueryForBookDocument() + { + $part = $this->bookReader->getFirstPart('[@order="3"]'); + self::assertNull($part); + } + + public function testGetNoLastPartByQueryForBookDocument() + { + $part = $this->bookReader->getLastPart('[@order="3"]'); + self::assertNull($part); + } + + public function testGetNoPartsForSerialDocument() + { + $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..8a8c531 --- /dev/null +++ b/tests/Mods/Reader/PhysicalDescriptionReaderTest.php @@ -0,0 +1,118 @@ +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); + } +} diff --git a/tests/Mods/Reader/RecordInfoReaderTest.php b/tests/Mods/Reader/RecordInfoReaderTest.php new file mode 100644 index 0000000..6ade386 --- /dev/null +++ b/tests/Mods/Reader/RecordInfoReaderTest.php @@ -0,0 +1,173 @@ +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); + } +} diff --git a/tests/Mods/Reader/RelatedItemReaderTest.php b/tests/Mods/Reader/RelatedItemReaderTest.php new file mode 100644 index 0000000..58dd24e --- /dev/null +++ b/tests/Mods/Reader/RelatedItemReaderTest.php @@ -0,0 +1,94 @@ +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); + } +} diff --git a/tests/Mods/Reader/SubjectReaderTest.php b/tests/Mods/Reader/SubjectReaderTest.php new file mode 100644 index 0000000..de3f0c3 --- /dev/null +++ b/tests/Mods/Reader/SubjectReaderTest.php @@ -0,0 +1,121 @@ +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); + } +} diff --git a/tests/Mods/Reader/TableOfContentsReaderTest.php b/tests/Mods/Reader/TableOfContentsReaderTest.php new file mode 100644 index 0000000..69aa737 --- /dev/null +++ b/tests/Mods/Reader/TableOfContentsReaderTest.php @@ -0,0 +1,60 @@ +bookReader->getTablesOfContents(); + 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 testGetTablesOfContentsByQueryForBookDocument() + { + $tableOfContents = $this->bookReader->getTablesOfContents('[@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 testGetNoTablesOfContentsByQueryForBookDocument() + { + $tableOfContents = $this->bookReader->getTablesOfContents('[@displayLabel="Pages"]'); + self::assertEmpty($tableOfContents); + } + + public function testGetNoTablesOfContentsForSerialDocument() + { + $tableOfContents = $this->serialReader->getTablesOfContents(); + self::assertEmpty($tableOfContents); + } +} 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..fbce62c --- /dev/null +++ b/tests/Mods/Reader/TypeOfResourceTest.php @@ -0,0 +1,63 @@ +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); + } +}