diff --git a/src/Mods/Element/Specific/Location/Url.php b/src/Mods/Element/Specific/Location/Url.php index 0491db1..b1b8302 100644 --- a/src/Mods/Element/Specific/Location/Url.php +++ b/src/Mods/Element/Specific/Location/Url.php @@ -57,18 +57,10 @@ public function __construct(\SimpleXMLElement $xml) * @access public * * @return string - * - * @throws IncorrectValueInAttributeException */ public function getDateLastAccessed(): string { - $dateLastAccessed = $this->getStringAttribute('dateLastAccessed'); - - if (empty($dateLastAccessed) || in_array($dateLastAccessed, $this->allowedAccess)) { - return $dateLastAccessed; - } - - throw new IncorrectValueInAttributeException('dateLastAccessed', $dateLastAccessed); + return $this->getStringAttribute('dateLastAccessed'); } /** diff --git a/tests/Mods/ModsReaderTest.php b/tests/Mods/ModsReaderTest.php index 894e925..d0c61ba 100644 --- a/tests/Mods/ModsReaderTest.php +++ b/tests/Mods/ModsReaderTest.php @@ -12,6 +12,7 @@ namespace Slub\Mods; use PHPUnit\Framework\TestCase; +use Slub\Mods\Exception\IncorrectValueInAttributeException; class ModsReaderTest extends TestCase { @@ -497,6 +498,9 @@ public function testGetLocationsByQueryForBookDocument() 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() @@ -512,18 +516,18 @@ public function testGetLocationsForSerialDocument() self::assertEquals(2, count($locations)); self::assertNotEmpty($locations[0]->getUrls()); self::assertEquals('electronic resource', $locations[0]->getUrls()[0]->getDisplayLabel()); - self::assertEquals('primary display', $locations[0]->getUrls()[0]->getUsage()); + 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="primary display"]]'); + $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('primary display', $locations[0]->getUrls()[0]->getUsage()); + self::assertEquals('primaryDisplay', $locations[0]->getUrls()[0]->getUsage()); self::assertEquals('http://bibpurl.oclc.org/web/7085', $locations[0]->getUrls()[0]->getValue()); } @@ -968,7 +972,10 @@ public function testGetRecordInfosForSerialDocument() self::assertEquals('marcorg', $recordInfos[0]->getRecordContentSources()[0]->getAuthority()); self::assertEquals('NLC', $recordInfos[0]->getRecordContentSources()[0]->getValue()); self::assertNotEmpty($recordInfos[0]->getRecordCreationDates()); - self::assertEquals('marc', $recordInfos[0]->getRecordCreationDates()[0]->getEncoding()); + + $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()); @@ -979,6 +986,7 @@ public function testGetRecordInfosForSerialDocument() 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()); @@ -1003,7 +1011,10 @@ public function testGetRecordInfosByQueryForSerialDocument() self::assertEquals('marcorg', $recordInfos[0]->getRecordContentSources()[0]->getAuthority()); self::assertEquals('NLC', $recordInfos[0]->getRecordContentSources()[0]->getValue()); self::assertNotEmpty($recordInfos[0]->getRecordCreationDates()); - self::assertEquals('marc', $recordInfos[0]->getRecordCreationDates()[0]->getEncoding()); + + $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()); @@ -1014,6 +1025,7 @@ public function testGetRecordInfosByQueryForSerialDocument() 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()); diff --git a/tests/resources/mods_book.xml b/tests/resources/mods_book.xml index 662fb22..4a7b90e 100644 --- a/tests/resources/mods_book.xml +++ b/tests/resources/mods_book.xml @@ -137,7 +137,7 @@ http://www.slub-dresden.de/some-url http://www.slub-dresden.de/some-url/SLO-0000 http://www.slub-dresden.de/some-url/SLO-0000 - http://www.slub-dresden.de/some-url/SLO-0000 + http://www.slub-dresden.de/some-url/SLO-0000 Use of this public-domain resource is unrestricted. diff --git a/tests/resources/mods_serial.xml b/tests/resources/mods_serial.xml index b353e1b..937c19a 100644 --- a/tests/resources/mods_serial.xml +++ b/tests/resources/mods_serial.xml @@ -84,7 +84,7 @@ 027.7/05 - http://bibpurl.oclc.org/web/7085 + http://bibpurl.oclc.org/web/7085 http://collection.nlc-bnc.ca/100/201/300/ejasl/index.html @@ -109,7 +109,7 @@ aacr NLC - 021127 + 021127 20080910160139.0 15446420 Converted from MARCXML to MODS version 3.8 using MARC21slim2MODS3-8_XSLT1-0.xsl (Revision 1.172 20230208)