Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Prokyonn committed Jul 16, 2024
1 parent e39eadb commit 322364c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Document/Subscriber/RoutableSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ private function getRoutePathPropertyName(string $structureType, string $locale)
{
$metadata = $this->metadataFactory->getStructureMetadata('article', $structureType);

if ($metadata->hasPropertyWithTagName(self::TAG_NAME)) {
if ($metadata->hasTag(self::TAG_NAME)) {
return $this->getPropertyName($locale, $metadata->getPropertyByTagName(self::TAG_NAME)->getName());
}

Expand Down
1 change: 0 additions & 1 deletion Resources/phpcr-migrations/Version202407111600.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use Sulu\Component\Localization\Localization;
use Symfony\Component\DependencyInjection\ContainerInterface;


class Version202407111600 implements VersionInterface, ContainerAwareInterface
{
/**
Expand Down
2 changes: 1 addition & 1 deletion Tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function registerBundles(): iterable
return $bundles;
}

public function registerContainerConfiguration(LoaderInterface $loader)
public function registerContainerConfiguration(LoaderInterface $loader): void
{
parent::registerContainerConfiguration($loader);

Expand Down
8 changes: 8 additions & 0 deletions Tests/Unit/Document/Subscriber/RoutableSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public function testHandlePersist()

$this->metadataFactory->getStructureMetadata('article', 'default')->willReturn($metadata->reveal());
$this->propertyEncoder->localizedSystemName('routePath', 'de')->willReturn('i18n:de-routePath');
$this->propertyEncoder->localizedContentName('routePathName', 'de')->willReturn('i18n:de-routePathName');

$children = [
$this->prophesize(RoutablePageBehavior::class),
Expand Down Expand Up @@ -200,8 +201,11 @@ public function testHandlePersist()
$children[2]->setRoutePath('/test-3')->shouldBeCalled();

$nodes[0]->setProperty('i18n:de-routePath', '/test-1')->shouldBeCalled();
$nodes[0]->setProperty('i18n:de-routePathName', 'i18n:de-routePath')->shouldBeCalled();
$nodes[1]->setProperty('i18n:de-routePath', '/test-2')->shouldBeCalled();
$nodes[1]->setProperty('i18n:de-routePathName', 'i18n:de-routePath')->shouldBeCalled();
$nodes[2]->setProperty('i18n:de-routePath', '/test-3')->shouldBeCalled();
$nodes[2]->setProperty('i18n:de-routePathName', 'i18n:de-routePath')->shouldBeCalled();

$this->routableSubscriber->handlePersist($event->reveal());
}
Expand Down Expand Up @@ -360,6 +364,7 @@ public function testHandleReorder()

$this->metadataFactory->getStructureMetadata('article', 'default')->willReturn($metadata->reveal());
$this->propertyEncoder->localizedSystemName('routePath', 'de')->willReturn('i18n:de-routePath');
$this->propertyEncoder->localizedContentName('routePathName', 'de')->willReturn('i18n:de-routePathName');

$children = [
$this->prophesize(RoutablePageBehavior::class),
Expand Down Expand Up @@ -401,8 +406,11 @@ public function testHandleReorder()
$children[2]->setRoutePath('/test-3')->shouldBeCalled();

$nodes[0]->setProperty('i18n:de-routePath', '/test-1')->shouldBeCalled();
$nodes[0]->setProperty('i18n:de-routePathName', 'i18n:de-routePath')->shouldBeCalled();
$nodes[1]->setProperty('i18n:de-routePath', '/test-2')->shouldBeCalled();
$nodes[1]->setProperty('i18n:de-routePathName', 'i18n:de-routePath')->shouldBeCalled();
$nodes[2]->setProperty('i18n:de-routePath', '/test-3')->shouldBeCalled();
$nodes[2]->setProperty('i18n:de-routePathName', 'i18n:de-routePath')->shouldBeCalled();

$this->routableSubscriber->handleReorder($event->reveal());
}
Expand Down

0 comments on commit 322364c

Please sign in to comment.