From fdbf9428758bc26e1e89efcec596ac698e87a19d Mon Sep 17 00:00:00 2001 From: Johannes Wachter Date: Mon, 5 Feb 2018 14:57:25 +0100 Subject: [PATCH] added array_unique to avoid duplicated entries (#26) --- GoneSubscriber/GoneDocumentSubscriber.php | 4 +--- Tests/Unit/GoneSubscriber/GoneDocumentSubscriberTest.php | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/GoneSubscriber/GoneDocumentSubscriber.php b/GoneSubscriber/GoneDocumentSubscriber.php index aa0d562..cdfe55a 100644 --- a/GoneSubscriber/GoneDocumentSubscriber.php +++ b/GoneSubscriber/GoneDocumentSubscriber.php @@ -118,8 +118,6 @@ public function createRedirects(RemoveEvent $event) } /** - * @param BasePageDocument $docum ent - * * @return array */ protected function getUrls(BasePageDocument $document) @@ -165,7 +163,7 @@ protected function getUrls(BasePageDocument $document) $url = parse_url($url, PHP_URL_PATH); } - return $urls; + return array_unique($urls); } /** diff --git a/Tests/Unit/GoneSubscriber/GoneDocumentSubscriberTest.php b/Tests/Unit/GoneSubscriber/GoneDocumentSubscriberTest.php index dfff8ca..4bac184 100644 --- a/Tests/Unit/GoneSubscriber/GoneDocumentSubscriberTest.php +++ b/Tests/Unit/GoneSubscriber/GoneDocumentSubscriberTest.php @@ -101,7 +101,7 @@ protected function setUp() $this->webspaceManager = $this->prophesize(WebspaceManager::class); $this->webspaceManager->findWebspaceByKey('example')->willReturn($this->webspace->reveal()); $this->webspaceManager->findUrlsByResourceLocator('/article', 'test', 'en') - ->willReturn(['http://{host}/en/article']); + ->willReturn(['http://{host}/en/article', 'http://sulu.io/en/article']); $this->webspaceManager->findUrlsByResourceLocator('/article1', 'test', 'en') ->willReturn(['http://{host}/en/article1']); $this->webspaceManager->findUrlsByResourceLocator('/article2', 'test', 'en')