From a5adb86d01464ab8c2828c7631c4c6e3ecb4e12f Mon Sep 17 00:00:00 2001 From: Rastislav Chynoransky Date: Tue, 9 Apr 2024 16:06:55 +0200 Subject: [PATCH] [harvest] map credit in GMUHK item mapper --- app/Harvest/Mappers/GmuhkItemMapper.php | 12 ++++++++++++ tests/Harvest/Mappers/GmuhkItemMapperTest.php | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/app/Harvest/Mappers/GmuhkItemMapper.php b/app/Harvest/Mappers/GmuhkItemMapper.php index 42a1b6961..517fa46c6 100644 --- a/app/Harvest/Mappers/GmuhkItemMapper.php +++ b/app/Harvest/Mappers/GmuhkItemMapper.php @@ -78,6 +78,18 @@ public function mapWorkType(array $row, $locale) return trans("item.work_types.$key", locale: $locale); } + public function mapCredit(array $row, $locale): ?string + { + if (str($row['identifier'][0])->startsWith('SKT')) { + return [ + 'sk' => 'Zbierka Karla Tutscha', + 'cs' => 'Sbírka Karla Tutsche', + 'en' => 'Karel Tutsch Collection', + ][$locale]; + } + + return null; + } protected function parseIdentifier($id): array { diff --git a/tests/Harvest/Mappers/GmuhkItemMapperTest.php b/tests/Harvest/Mappers/GmuhkItemMapperTest.php index 391d9f2bc..c841a162f 100644 --- a/tests/Harvest/Mappers/GmuhkItemMapperTest.php +++ b/tests/Harvest/Mappers/GmuhkItemMapperTest.php @@ -57,6 +57,9 @@ public function testMap() 'work_type:sk' => 'grafika', 'work_type:en' => 'graphics', 'work_type:cs' => 'grafika', + 'credit:sk' => null, + 'credit:en' => null, + 'credit:cs' => null, ]; $this->assertEquals($expected, $mapped); } @@ -73,4 +76,16 @@ public function testMapWorkTypeFallback() $this->assertEquals('grafika', $mapper->mapWorkType($row, 'cs')); $this->assertEquals('graphics', $mapper->mapWorkType($row, 'en')); } + + public function testMapCredit_Skt() + { + $mapper = new GmuhkItemMapper(); + $row = [ + 'identifier' => ['SKT 372'], + ]; + + $this->assertEquals('Zbierka Karla Tutscha', $mapper->mapCredit($row, 'sk')); + $this->assertEquals('Sbírka Karla Tutsche', $mapper->mapCredit($row, 'cs')); + $this->assertEquals('Karel Tutsch Collection', $mapper->mapCredit($row, 'en')); + } }