mirror of
https://github.com/werkraum-media/thuecat.git
synced 2024-12-05 03:26:13 +01:00
Handle resources with missing containedInPlace
Check for situation and return empty array. Do not create unnecessary requests to database but directly return.
This commit is contained in:
parent
eac551e2bc
commit
6b19485a36
3 changed files with 30 additions and 0 deletions
|
@ -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']);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue