Skip to content

Commit

Permalink
[harvest] map credit in GMUHK item mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
rastislav-chynoransky committed Apr 9, 2024
1 parent f19f16f commit 8e247ae
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/Harvest/Mappers/GmuhkItemMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
12 changes: 12 additions & 0 deletions tests/Harvest/Mappers/GmuhkItemMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,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'));
}
}

0 comments on commit 8e247ae

Please sign in to comment.