Skip to content

Commit

Permalink
Merge pull request #991 from SlovakNationalGallery/WEBUMENIA-2072
Browse files Browse the repository at this point in the history
[harvest] map credit in GMUHK item mapper
  • Loading branch information
rastislav-chynoransky authored Apr 10, 2024
2 parents f19f16f + a5adb86 commit bbd4f2f
Show file tree
Hide file tree
Showing 2 changed files with 27 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
15 changes: 15 additions & 0 deletions tests/Harvest/Mappers/GmuhkItemMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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'));
}
}

0 comments on commit bbd4f2f

Please sign in to comment.