mirror of
https://github.com/werkraum-media/thuecat.git
synced 2024-12-05 03:26:13 +01:00
Handle relation to single "containedInPlace"
Only multiple containedInPlace were supported. Some instances only have a single containedInPlace. This is now handled as well.
This commit is contained in:
parent
bbf7ada1d2
commit
22932545d3
2 changed files with 35 additions and 1 deletions
|
@ -88,6 +88,12 @@ class Parser
|
|||
*/
|
||||
public function getContainedInPlaceIds(array $jsonLD): array
|
||||
{
|
||||
if (isset($jsonLD['schema:containedInPlace']['@id'])) {
|
||||
return [
|
||||
$jsonLD['schema:containedInPlace']['@id'],
|
||||
];
|
||||
}
|
||||
|
||||
return array_map(function (array $place) {
|
||||
return $place['@id'];
|
||||
}, $jsonLD['schema:containedInPlace']);
|
||||
|
|
|
@ -178,7 +178,7 @@ class ParserTest extends TestCase
|
|||
/**
|
||||
* @test
|
||||
*/
|
||||
public function returnsContainedInPlaceIds(): void
|
||||
public function returnsContainedInPlaceIdsForMultipleEntries(): void
|
||||
{
|
||||
$genericFields = $this->prophesize(GenericFields::class);
|
||||
$openingHours = $this->prophesize(OpeningHours::class);
|
||||
|
@ -211,6 +211,34 @@ class ParserTest extends TestCase
|
|||
], $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function returnsContainedInPlaceIdsForSingleEntry(): void
|
||||
{
|
||||
$genericFields = $this->prophesize(GenericFields::class);
|
||||
$openingHours = $this->prophesize(OpeningHours::class);
|
||||
$address = $this->prophesize(Address::class);
|
||||
$media = $this->prophesize(Media::class);
|
||||
|
||||
$subject = new Parser(
|
||||
$genericFields->reveal(),
|
||||
$openingHours->reveal(),
|
||||
$address->reveal(),
|
||||
$media->reveal()
|
||||
);
|
||||
|
||||
$result = $subject->getContainedInPlaceIds([
|
||||
'schema:containedInPlace' => [
|
||||
'@id' => 'https://thuecat.org/resources/043064193523-jcyt',
|
||||
],
|
||||
]);
|
||||
|
||||
self::assertSame([
|
||||
'https://thuecat.org/resources/043064193523-jcyt',
|
||||
], $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue