Skip to content

Commit

Permalink
Merge branch '2.4' of https://github.com/sulu/sulu into 2.5
Browse files Browse the repository at this point in the history
 Conflicts:
	src/Sulu/Component/Content/Tests/Unit/Document/Subscriber/WebspaceSubscriberTest.php
  • Loading branch information
alexander-schranz committed Feb 15, 2023
2 parents af5f440 + cad4ed9 commit 675ea77
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -42805,11 +42805,6 @@ parameters:
count: 1
path: src/Sulu/Component/Content/Document/Subscriber/TitleSubscriber.php

-
message: "#^Cannot call method getAllLocalizations\\(\\) on Sulu\\\\Component\\\\Webspace\\\\Webspace\\|null\\.$#"
count: 1
path: src/Sulu/Component/Content/Document/Subscriber/WebspaceSubscriber.php

-
message: "#^Cannot call method remove\\(\\) on mixed\\.$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public function deleteUnavailableLocales(CopyEvent $event)
);

$webspace = $this->webspaceManager->findWebspaceByKey($this->documentInspector->getWebspace($copiedDocument));
if (!$webspace) {
return;
}

$webspaceLocales = \array_map(function($localization) {
return $localization->getLocale();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

use PHPCR\NodeInterface;
use PHPCR\PropertyInterface;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Sulu\Bundle\DocumentManagerBundle\Bridge\DocumentInspector;
use Sulu\Component\Content\Document\Behavior\WebspaceBehavior;
use Sulu\Component\Content\Document\Subscriber\WebspaceSubscriber;
use Sulu\Component\DocumentManager\Document\UnknownDocument;
use Sulu\Component\DocumentManager\DocumentManagerInterface;
use Sulu\Component\DocumentManager\Event\CopyEvent;
use Sulu\Component\Localization\Localization;
Expand Down Expand Up @@ -122,4 +124,28 @@ public function testDeleteUnavailableLocales(): void
$germanProperty2->remove()->shouldBeCalled();
$englishProperty1->remove()->shouldNotBeCalled();
}

public function testDeleteUnavailableLocalesNoneWebspaceDocument(): void
{
$copyEvent = $this->prophesize(CopyEvent::class);

$document = $this->prophesize(UnknownDocument::class);
$this->inspector->getLocale($document)->willReturn('fr');
$copyEvent->getDocument()->willReturn($document->reveal());

$copyEvent->getCopiedPath()->willReturn('/cmf/test_io/contents');

$copiedNode = $this->prophesize(NodeInterface::class);
$copyEvent->getCopiedNode()->willReturn($copiedNode->reveal());

$copiedDocument = $this->prophesize(UnknownDocument::class);
$this->documentManager->find('/cmf/test_io/contents', 'fr')->willReturn($copiedDocument->reveal());
$this->inspector->getWebspace($copiedDocument)->willReturn(null);

$this->webspaceManager->findWebspaceByKey(null)->willReturn(null);

$this->inspector->getLocales(Argument::any())->shouldNotBecalled();

$this->subscriber->deleteUnavailableLocales($copyEvent->reveal());
}
}

0 comments on commit 675ea77

Please sign in to comment.