Skip to content

Commit

Permalink
Merge pull request #37 from slub/34-number-of-volumes
Browse files Browse the repository at this point in the history
Add volume and number of volumes to footer
  • Loading branch information
dikastes authored Nov 28, 2024
2 parents cd8f048 + caf9f4e commit bd3ab8e
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 12 deletions.
11 changes: 10 additions & 1 deletion Classes/Processing/BibEntryConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ class BibEntryConfig
'conditionValue' => '',
'conditionRelation' => 'neq',
];
const NUMBER_OF_VOLUMES = [
'field' => 'numberOfVolumes',
'conditionField' => 'numberOfVolumes',
'conditionValue' => '',
'conditionRelation' => 'neq',
];

public static function getAuthorHeader(): array
{
Expand Down Expand Up @@ -155,9 +161,10 @@ public static function getBookSectionFooter(): array
{
return [
self::circumfix(self::BOOK_TITLE, 'In ', ', '),
self::postfix(self::VOLUME, ', '),
self::circumfix(self::EDITOR, 'hg. von ', ', '),
self::circumfix(self::TRANSLATOR, 'übers. von ', ', '),
self::postfix(self::NUMBER_OF_VOLUMES, 'Bde., '),
self::circumfix(self::VOLUME, 'Bd. ', ', '),
self::postfix(self::PLACE, ' '),
self::postfix(self::DATE, ', '),
self::PAGES
Expand All @@ -169,6 +176,8 @@ public static function getBookFooter(): array
return [
self::circumfix(self::EDITOR, 'hg. von ', ', '),
self::circumfix(self::TRANSLATOR, 'übers. von ', ', '),
self::postfix(self::NUMBER_OF_VOLUMES, 'Bde., '),
self::circumfix(self::VOLUME, 'Bd. ', ', '),
self::postfix(self::PLACE, ' '),
self::DATE
];
Expand Down
71 changes: 60 additions & 11 deletions Tests/Unit/Processing/BibEntryProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ final class BibEntryProcessorTest extends UnitTestCase
private string $authorLastName = 'ex_author_last';
private string $editorFirstName = 'ex_editor_first';
private string $editorLastName = 'ex_editor_last';
private string $translatorFirstName = 'ex_translator_first';
private string $translatorLastName = 'ex_translator_last';
private string $title = 'ex_title';
private string $bookTitle = 'ex_book_title';
private string $place = 'ex_place';
private string $date = 'ex_date';
private string $pages = 'ex_pages';
private string $volume = 'ex_volume';
private string $numberOfVolumes = 'ex_number_of_volumes';
private string $issue = 'ex_issue';

private string $exampleBook = '';
Expand All @@ -57,9 +60,21 @@ protected function setUp(): void
"creatorType": "author",
"firstName": "$this->authorFirstName",
"lastName": "$this->authorLastName"
},
{
"creatorType": "editor",
"firstName": "$this->editorFirstName",
"lastName": "$this->editorLastName"
},
{
"creatorType": "translator",
"firstName": "$this->translatorFirstName",
"lastName": "$this->translatorLastName"
}
],
"place": "$this->place",
"volume": "$this->volume",
"numberOfVolumes": "$this->numberOfVolumes",
"date": "$this->date"
}
JSON;
Expand All @@ -75,8 +90,15 @@ protected function setUp(): void
"creatorType": "editor",
"firstName": "$this->editorFirstName",
"lastName": "$this->editorLastName"
},
{
"creatorType": "translator",
"firstName": "$this->translatorFirstName",
"lastName": "$this->translatorLastName"
}
],
"volume": "$this->volume",
"numberOfVolumes": "$this->numberOfVolumes",
"place": "$this->place",
"date": "$this->date"
}
Expand Down Expand Up @@ -137,9 +159,16 @@ protected function setUp(): void
"creatorType": "editor",
"firstName": "$this->editorFirstName",
"lastName": "$this->editorLastName"
},
{
"creatorType": "translator",
"firstName": "$this->translatorFirstName",
"lastName": "$this->translatorLastName"
}
],
"bookTitle": "$this->bookTitle",
"volume": "$this->volume",
"numberOfVolumes": "$this->numberOfVolumes",
"place": "$this->place",
"date": "$this->date",
"pages": "$this->pages"
Expand Down Expand Up @@ -190,9 +219,9 @@ public function bodyIsProcessedCorrectly(): void
$bookSection = $this->subject->process($this->exampleBookSectionArray, new Collection(), new Collection());
$article = $this->subject->process($this->exampleArticleArray, new Collection(), new Collection());

self::assertEquals($book['tx_lisztcommon_body'], Str::of($this->title));
self::assertEquals($bookSection['tx_lisztcommon_body'], Str::of($this->title));
self::assertEquals($article['tx_lisztcommon_body'], Str::of($this->title));
self::assertEquals(Str::of($this->title), $book['tx_lisztcommon_body']);
self::assertEquals(Str::of($this->title), $bookSection['tx_lisztcommon_body']);
self::assertEquals(Str::of($this->title), $article['tx_lisztcommon_body']);
}

/**
Expand All @@ -201,9 +230,16 @@ public function bodyIsProcessedCorrectly(): void
public function bookFooterIsProcessedCorrectly(): void
{
$book = $this->subject->process($this->exampleBookArray, new Collection(), new Collection());
$expected = Str::of($this->place . ' ' . $this->date);
$expected = Str::of(
'hg. von ' . $this->editorFirstName . ' ' . $this->editorLastName . ', ' .
'übers. von ' . $this->translatorFirstName . ' ' . $this->translatorLastName . ', ' .
$this->numberOfVolumes . 'Bde., ' .
'Bd. ' . $this->volume . ', ' .
$this->place . ' ' .
$this->date
);

self::assertEquals($book['tx_lisztcommon_footer'], $expected);
self::assertEquals($expected, $book['tx_lisztcommon_footer']);
}

/**
Expand All @@ -212,10 +248,18 @@ public function bookFooterIsProcessedCorrectly(): void
public function bookSectionFooterIsProcessedCorrectly(): void
{
$bookSection = $this->subject->process($this->exampleBookSectionArray, new Collection(), new Collection());
$expected = Str::of('In ' . $this->bookTitle . ', ' . 'hg. von ' . $this->editorFirstName . ' ' . $this->editorLastName .
', ' . $this->place . ' ' . $this->date . ', ' . $this->pages);
$expected = Str::of(
'In ' . $this->bookTitle . ', ' .
'hg. von ' . $this->editorFirstName . ' ' . $this->editorLastName . ', ' .
'übers. von ' . $this->translatorFirstName . ' ' . $this->translatorLastName . ', ' .
$this->numberOfVolumes . 'Bde., ' .
'Bd. ' . $this->volume . ', ' .
$this->place . ' ' .
$this->date . ', ' .
$this->pages
);

self::assertEquals($bookSection['tx_lisztcommon_footer'], $expected);
self::assertEquals($expected, $bookSection['tx_lisztcommon_footer']);
}

/**
Expand All @@ -224,10 +268,15 @@ public function bookSectionFooterIsProcessedCorrectly(): void
public function articleFooterIsProcessedCorrectly(): void
{
$article = $this->subject->process($this->exampleArticleArray, new Collection(), new Collection());
$expected = Str::of($this->bookTitle . ' ' . $this->volume . ' (' . $this->date . '), Nr. ' . $this->issue . ', ' . $this->pages);
var_dump($article['tx_lisztcommon_footer']);
$expected = Str::of(
$this->bookTitle . ' ' .
$this->volume .
' (' . $this->date . '), Nr. ' .
$this->issue . ', ' .
$this->pages
);

self::assertEquals($article['tx_lisztcommon_footer'], $expected);
self::assertEquals($expected, $article['tx_lisztcommon_footer']);
}


Expand Down

0 comments on commit bd3ab8e

Please sign in to comment.