Skip to content

Commit

Permalink
Implement tests for reading location element
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed Apr 8, 2024
1 parent 84826bf commit c6817f8
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 8 deletions.
68 changes: 60 additions & 8 deletions tests/Mods/ModsReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,28 +407,81 @@ 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::assertNotNull($copyInformation);
self::assertNotEmpty($copyInformation->getSubLocations());
self::assertEquals('Reading room', $copyInformation->getSubLocations()[0]->getValue());
self::assertEquals('QH511.A1J68', $copyInformation->getShelfLocator()->getValue());
self::assertEquals('1', $copyInformation->getEnumerationAndChronology()->getUnitType());
self::assertEquals('v.1-v.2 1999-2002', $copyInformation->getEnumerationAndChronology()->getValue());
}

public function testGetLocationsByQueryForBookDocument()
{
$locations = $this->bookReader->getLocations('[@displayLabel="links"]');
self::assertNotEmpty($locations);
self::assertEquals(1, count($locations));

// TODO: implement reading of location elements
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());
}

public function testGetNoLocationsByQueryForBookDocument()
{
$locations = $this->bookReader->getLocations('[@displayLabel="random"]');
self::assertEmpty($locations);
}

public function testGetLocationsForSerialDocument()
{
$locations = $this->serialReader->getLocations();
self::assertNotEmpty($locations);
self::assertEquals(2, count($locations));

// TODO: implement reading of location elements
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('http://bibpurl.oclc.org/web/7085', $locations[0]->getUrls()[0]->getValue());
}

public function testGetLocationsByQueryForSerialDocument()
{
$locations = $this->serialReader->getLocations('[./mods:url[@usage="primary display"]]');
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('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));

// TODO: implement reading of name elements

}

Expand All @@ -437,8 +490,7 @@ public function testGetNamesForSerialDocument()
$names = $this->serialReader->getNames();
self::assertNotEmpty($names);
self::assertEquals(1, count($names));

// TODO: implement reading of name elements

}

public function testGetNotesForBookDocument()
Expand Down
10 changes: 10 additions & 0 deletions tests/resources/mods_book.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@
<identifier type="isbn">0801486394 (pbk. : acid-free, recycled paper)</identifier>
<identifier type="lccn">99042030</identifier>
<location>
<physicalLocation authority="marcorg">MnRM</physicalLocation>
<holdingSimple>
<copyInformation>
<subLocation>Reading room</subLocation>
<shelfLocator>QH511.A1J68</shelfLocator>
<enumerationAndChronology unitType="1">v.1-v.2 1999-2002</enumerationAndChronology>
</copyInformation>
</holdingSimple>
</location>
<location displayLabel='links'>
<url dateLastAccessed="2024-01-27">http://www.slub-dresden.de/some-url</url>
<url access="preview">http://www.slub-dresden.de/some-url/SLO-0000</url>
<url access="object in context">http://www.slub-dresden.de/some-url/SLO-0000</url>
Expand Down

0 comments on commit c6817f8

Please sign in to comment.