Skip to content

Commit

Permalink
Add tests for titleInfo element
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed Apr 9, 2024
1 parent b457be7 commit 671721c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
39 changes: 26 additions & 13 deletions tests/Mods/ModsReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -918,12 +918,26 @@ public function testGetTitleInfosForBookDocument()
{
$titleInfos = $this->bookReader->getTitleInfos();
self::assertNotEmpty($titleInfos);
self::assertEquals(1, count($titleInfos));
self::assertEquals(2, count($titleInfos));
self::assertNotEmpty($titleInfos[0]->getValue());
//self::assertNotEmpty($titleInfos[0]->getTitle());
//self::assertNotEmpty($titleInfos[0]->getSubTitle());
self::assertEquals('Sound and fury', $titleInfos[0]->getTitle()->getValue());
self::assertEquals('the making of the punditocracy', $titleInfos[0]->getSubTitle()->getValue());
}

// TODO: implement reading of elements
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()
Expand All @@ -932,22 +946,21 @@ public function testGetTitleInfosForSerialDocument()
self::assertNotEmpty($titleInfos);
self::assertEquals(3, count($titleInfos));
self::assertNotEmpty($titleInfos[0]->getValue());
//self::assertNotEmpty($titleInfos[0]->getTitle());
//self::assertNotEmpty($titleInfos[0]->getSubTitle());

// TODO: implement reading of elements
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="alternative"]');
$titleInfos = $this->serialReader->getTitleInfos('[@type="abbreviated"]');
self::assertNotEmpty($titleInfos);
self::assertEquals(1, count($titleInfos));
self::assertNotEmpty($titleInfos[0]->getValue());
//self::assertNotEmpty($titleInfos[0]->getTitle());
//self::assertEmpty($titleInfos[0]->getSubTitle());

// TODO: implement reading of elements
self::assertEquals('E-JASL', $titleInfos[0]->getTitle()->getValue());
self::assertNotEmpty($titleInfos[0]->getSubTitle());
self::assertEquals('(Athabasca)', $titleInfos[0]->getSubTitle()->getValue());
}

public function testGetNoTitleInfosByQueryForSerialDocument()
Expand Down
7 changes: 6 additions & 1 deletion tests/resources/mods_book.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<mods xmlns="http://www.loc.gov/mods/v3"
<mods xmlns="http://www.loc.gov/mods/v3" xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:zs="http://docs.oasis-open.org/ns/search-ws/sruResponse"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.8" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-8.xsd">
<titleInfo>
<title>Sound and fury</title>
<subTitle>the making of the punditocracy</subTitle>
</titleInfo>
<titleInfo xml:lang="fr" type="translated">
<nonSort>Le</nonSort>
<title>bruit et la fureur</title>
<subTitle>la création de la punditocratie</subTitle>
</titleInfo>
<name type="personal" usage="primary">
<namePart>Alterman, Eric.</namePart>
<role>
Expand Down

0 comments on commit 671721c

Please sign in to comment.