Skip to content

Commit

Permalink
Implement tests for originInfo element
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed Apr 12, 2024
1 parent 951b2ec commit 00254c7
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 9 deletions.
70 changes: 62 additions & 8 deletions tests/Mods/ModsReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,19 @@ public function testGetOriginInfosForBookDocument()
self::assertNotEmpty($originInfos[0]->getValue());
self::assertNotEmpty($originInfos[0]->getEventType());
self::assertEquals('publication', $originInfos[0]->getEventType());

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

public function testGetOriginInfosByQueryForBookDocument()
Expand All @@ -683,8 +694,17 @@ public function testGetOriginInfosByQueryForBookDocument()
self::assertNotEmpty($originInfos[0]->getValue());
self::assertNotEmpty($originInfos[0]->getEventType());
self::assertEquals('redaction', $originInfos[0]->getEventType());

// TODO: implement reading of elements
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()
Expand All @@ -701,8 +721,25 @@ public function testGetOriginInfosForSerialDocument()
self::assertNotEmpty($originInfos[0]->getValue());
self::assertNotEmpty($originInfos[0]->getEventType());
self::assertEquals('publication', $originInfos[0]->getEventType());

// TODO: implement reading of elements
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()
Expand All @@ -713,8 +750,25 @@ public function testGetOriginInfosByQueryForSerialDocument()
self::assertNotEmpty($originInfos[0]->getValue());
self::assertNotEmpty($originInfos[0]->getEventType());
self::assertEquals('publication', $originInfos[0]->getEventType());

// TODO: implement reading of elements
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()
Expand Down
1 change: 0 additions & 1 deletion tests/resources/mods_book.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
<placeTerm authority="marccountry" type="code">nyu</placeTerm>
</place>
<dateIssued encoding="marc">1999</dateIssued>
<issuance>monographic</issuance>
<place>
<placeTerm type="text">Ithaca, N.Y</placeTerm>
</place>
Expand Down

0 comments on commit 00254c7

Please sign in to comment.