diff --git a/Classes/Domain/Import/JsonLD/Parser.php b/Classes/Domain/Import/JsonLD/Parser.php index e093d23..0b15981 100644 --- a/Classes/Domain/Import/JsonLD/Parser.php +++ b/Classes/Domain/Import/JsonLD/Parser.php @@ -94,6 +94,10 @@ class Parser ]; } + if (isset($jsonLD['schema:containedInPlace']) === false) { + return []; + } + return array_map(function (array $place) { return $place['@id']; }, $jsonLD['schema:containedInPlace']); diff --git a/Classes/Domain/Repository/Backend/TownRepository.php b/Classes/Domain/Repository/Backend/TownRepository.php index 1ea6c1d..5d9b7c7 100644 --- a/Classes/Domain/Repository/Backend/TownRepository.php +++ b/Classes/Domain/Repository/Backend/TownRepository.php @@ -46,6 +46,10 @@ class TownRepository extends Repository public function findOneByRemoteIds(array $remoteIds): ?Town { + if ($remoteIds === []) { + return null; + } + $query = $this->createQuery(); $query->in('remoteId', $remoteIds); diff --git a/Tests/Unit/Domain/Import/JsonLD/ParserTest.php b/Tests/Unit/Domain/Import/JsonLD/ParserTest.php index 360b36a..977ee95 100644 --- a/Tests/Unit/Domain/Import/JsonLD/ParserTest.php +++ b/Tests/Unit/Domain/Import/JsonLD/ParserTest.php @@ -211,6 +211,28 @@ class ParserTest extends TestCase ], $result); } + /** + * @test + */ + public function returnsContainedInPlaceIdsForNoEntry(): 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([]); + + self::assertSame([], $result); + } + /** * @test */