From e3b8283c99192b292be4a2dd270db665d7d12cd1 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Wed, 27 Nov 2024 16:11:32 +0100 Subject: [PATCH 1/2] Add volume and number of volumes to footer --- Classes/Processing/BibEntryConfig.php | 9 ++- .../Unit/Processing/BibEntryProcessorTest.php | 57 +++++++++++++++++-- 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/Classes/Processing/BibEntryConfig.php b/Classes/Processing/BibEntryConfig.php index bcf4c0c..6532ba5 100644 --- a/Classes/Processing/BibEntryConfig.php +++ b/Classes/Processing/BibEntryConfig.php @@ -124,6 +124,12 @@ class BibEntryConfig 'conditionValue' => '', 'conditionRelation' => 'neq', ]; + const NUMBER_OF_VOLUMES = [ + 'field' => 'numberOfVolumes', + 'conditionField' => 'pages', + 'conditionValue' => '', + 'conditionRelation' => 'neq' + ]; public static function getAuthorHeader(): array { @@ -155,7 +161,8 @@ public static function getBookSectionFooter(): array { return [ self::circumfix(self::BOOK_TITLE, 'In ', ', '), - self::postfix(self::VOLUME, ', '), + self::circumfix(self::VOLUME, 'Bd. ', ', '), + self::postfix(self::NUMBER_OF_VOLUMES, 'Bde., '), self::circumfix(self::EDITOR, 'hg. von ', ', '), self::circumfix(self::TRANSLATOR, 'übers. von ', ', '), self::postfix(self::PLACE, ' '), diff --git a/Tests/Unit/Processing/BibEntryProcessorTest.php b/Tests/Unit/Processing/BibEntryProcessorTest.php index 0878387..cdcbe36 100644 --- a/Tests/Unit/Processing/BibEntryProcessorTest.php +++ b/Tests/Unit/Processing/BibEntryProcessorTest.php @@ -27,12 +27,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 = ''; @@ -55,9 +58,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; @@ -73,8 +88,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" } @@ -117,9 +139,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" @@ -177,7 +206,13 @@ 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 . ', ' . + 'Bd. ' . $this->volume . ', ' . + $this->place . ' ' . + $this->date + ); self::assertEquals($book['tx_lisztcommon_footer'], $expected); } @@ -188,8 +223,15 @@ 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 . ', ' . + 'Bd. ' . $this->volume . ', ' . + 'hg. von ' . $this->editorFirstName . ' ' . $this->editorLastName . ', ' . + 'übers. von ' . $this->translatorFirstName . ' ' . $this->translatorLastName . ', ' . + $this->place . ' ' . + $this->date . ', ' . + $this->pages + ); self::assertEquals($bookSection['tx_lisztcommon_footer'], $expected); } @@ -200,8 +242,13 @@ 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); } From caf9f4e3ba8217d79e5b443eaa9306bd8019f5a8 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Thu, 28 Nov 2024 13:35:36 +0100 Subject: [PATCH 2/2] Fix tests --- Classes/Processing/BibEntryConfig.php | 10 ++++++---- Tests/Unit/Processing/BibEntryProcessorTest.php | 16 +++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Classes/Processing/BibEntryConfig.php b/Classes/Processing/BibEntryConfig.php index 6532ba5..33a84d5 100644 --- a/Classes/Processing/BibEntryConfig.php +++ b/Classes/Processing/BibEntryConfig.php @@ -126,9 +126,9 @@ class BibEntryConfig ]; const NUMBER_OF_VOLUMES = [ 'field' => 'numberOfVolumes', - 'conditionField' => 'pages', + 'conditionField' => 'numberOfVolumes', 'conditionValue' => '', - 'conditionRelation' => 'neq' + 'conditionRelation' => 'neq', ]; public static function getAuthorHeader(): array @@ -161,10 +161,10 @@ public static function getBookSectionFooter(): array { return [ self::circumfix(self::BOOK_TITLE, 'In ', ', '), - self::circumfix(self::VOLUME, 'Bd. ', ', '), - self::postfix(self::NUMBER_OF_VOLUMES, 'Bde., '), 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 @@ -176,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 ]; diff --git a/Tests/Unit/Processing/BibEntryProcessorTest.php b/Tests/Unit/Processing/BibEntryProcessorTest.php index 6fb1368..08f7437 100644 --- a/Tests/Unit/Processing/BibEntryProcessorTest.php +++ b/Tests/Unit/Processing/BibEntryProcessorTest.php @@ -219,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']); } /** @@ -233,12 +233,13 @@ public function bookFooterIsProcessedCorrectly(): void $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']); } /** @@ -249,15 +250,16 @@ public function bookSectionFooterIsProcessedCorrectly(): void $bookSection = $this->subject->process($this->exampleBookSectionArray, new Collection(), new Collection()); $expected = Str::of( 'In ' . $this->bookTitle . ', ' . - 'Bd. ' . $this->volume . ', ' . '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']); } /** @@ -274,7 +276,7 @@ public function articleFooterIsProcessedCorrectly(): void $this->pages ); - self::assertEquals($article['tx_lisztcommon_footer'], $expected); + self::assertEquals($expected, $article['tx_lisztcommon_footer']); }