Skip to content

Commit

Permalink
Implement tests for part element
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed Apr 15, 2024
1 parent 2bd59a3 commit b62e48a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
28 changes: 24 additions & 4 deletions tests/Mods/ModsReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,18 @@ public function testGetPartsForBookDocument()
self::assertEquals('poem', $parts[0]->getType());
self::assertNotEmpty($parts[0]->getOrder());
self::assertEquals(1, $parts[0]->getOrder());

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

public function testGetPartsByQueryForBookDocument()
Expand All @@ -801,8 +811,18 @@ public function testGetPartsByQueryForBookDocument()
self::assertEquals('poem', $parts[0]->getType());
self::assertNotEmpty($parts[0]->getOrder());
self::assertEquals(2, $parts[0]->getOrder());

// TODO: implement reading of elements
$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()
Expand Down
10 changes: 9 additions & 1 deletion tests/resources/mods_book.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,22 @@
<start>97</start>
<end>98</end>
</extent>
<date encoding="marc">1989</date>
<text>Some random text</text>
</part>
<part type="poem" order="2">
<detail>
<detail type="begin" level="1">
<title>Vagabonds</title>
<caption>Vavava Gagaga Bonds</caption>
</detail>
<detail type="end" level="2">
<title>Vagabonds</title>
<caption>Vavava Gagaga Bonds</caption>
</detail>
<extent unit="pages">
<start>99</start>
<end>100</end>
<total>2</total>
</extent>
</part>
<tableOfContents displayLabel="Chapters">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>
Expand Down

0 comments on commit b62e48a

Please sign in to comment.