Skip to content

Commit

Permalink
ignore slash route when no title given (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes authored and alexander-schranz committed Dec 6, 2019
1 parent 21a4e7f commit 7090130
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public function map(
['route_schema' => '/{object.getTitle()}']
);

if ('/' === $routePath) {
return;
}

$localizedContentDimension->setTemplateData(
array_merge(
$localizedContentDimension->getTemplateData(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,52 @@ public function testMapNoRoutePropertyDataAndNoOldRoute(): void
$mapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal());
}

public function testMapNoRoutePropertyDataAndNoOldRouteIgnoreSlash(): void
{
$data = [
'template' => 'default',
];

$contentDimension = $this->prophesize(ContentDimensionInterface::class);
$localizedContentDimension = $this->prophesize(ContentDimensionInterface::class);
$localizedContentDimension->willImplement(RoutableInterface::class);
$localizedContentDimension->willImplement(TemplateInterface::class);

$factory = $this->prophesize(StructureMetadataFactoryInterface::class);
$routeGenerator = $this->prophesize(RouteGeneratorInterface::class);
$routeManager = $this->prophesize(RouteManagerInterface::class);

$metadata = $this->prophesize(StructureMetadata::class);
$property = $this->prophesize(PropertyMetadata::class);
$property->getType()->willReturn('route');
$property->getName()->willReturn('url');

$metadata->getProperties()->WillReturn([$property->reveal()]);

$localizedContentDimension->getContentClass()->willReturn('App\Entity\Example');

$localizedContentDimension->getContentId()->willReturn('123-123-123');
$localizedContentDimension->getTemplateType()->willReturn('example');
$localizedContentDimension->getTemplateData()->willReturn([]);
$localizedContentDimension->getLocale()->willReturn('en');
$factory->getStructureMetadata('example', 'default')->willReturn($metadata->reveal())->shouldBeCalled();

$routeGenerator->generate($localizedContentDimension, ['route_schema' => '/{object.getTitle()}'])
->willReturn('/');

$localizedContentDimension->setTemplateData(Argument::cetera())->shouldNotBeCalled();

$routeManager->createOrUpdateByAttributes(Argument::cetera())->shouldNotBeCalled();

$mapper = $this->createRouteMapperInstance(
$factory->reveal(),
$routeGenerator->reveal(),
$routeManager->reveal()
);

$mapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal());
}

public function testMapNoContentId(): void
{
$data = [
Expand Down

0 comments on commit 7090130

Please sign in to comment.