diff --git a/Classes/Domain/Import/JsonLD/Parser.php b/Classes/Domain/Import/JsonLD/Parser.php index 3d01c27..e093d23 100644 --- a/Classes/Domain/Import/JsonLD/Parser.php +++ b/Classes/Domain/Import/JsonLD/Parser.php @@ -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']); diff --git a/Tests/Unit/Domain/Import/JsonLD/ParserTest.php b/Tests/Unit/Domain/Import/JsonLD/ParserTest.php index 08b559d..0a30b36 100644 --- a/Tests/Unit/Domain/Import/JsonLD/ParserTest.php +++ b/Tests/Unit/Domain/Import/JsonLD/ParserTest.php @@ -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 */