From 6d7fd245a57d81746ac0f0950b4a13ca9d483ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 11 Dec 2020 15:35:18 +0100 Subject: [PATCH] Fix generating the redirect url MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Controller/ContactsController.php | 4 +++- tests/unit/Controller/ContactsControllerTest.php | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/Controller/ContactsController.php b/lib/Controller/ContactsController.php index 24361096e..0404c3ac4 100644 --- a/lib/Controller/ContactsController.php +++ b/lib/Controller/ContactsController.php @@ -56,7 +56,9 @@ public function __construct(IRequest $request, * @param string $uuid */ public function direct(string $contact): RedirectResponse { - $url = $this->urlGenerator->getAbsoluteURL('/apps/contacts/' . $this->l10n->t('All contacts') . '/' . $contact); + $url = $this->urlGenerator->getAbsoluteURL( + $this->urlGenerator->linkToRoute('contacts.page.index') . $this->l10n->t('All contacts') . '/' . $contact + ); return new RedirectResponse($url); } } diff --git a/tests/unit/Controller/ContactsControllerTest.php b/tests/unit/Controller/ContactsControllerTest.php index c55cc1f21..e618bba99 100644 --- a/tests/unit/Controller/ContactsControllerTest.php +++ b/tests/unit/Controller/ContactsControllerTest.php @@ -62,13 +62,18 @@ public function testRedirect() { ->with('All contacts') ->willReturn('All contacts'); + $this->urlGenerator->expects($this->once()) + ->method('linkToRoute') + ->with('contacts.page.index') + ->willReturn('/index.php/apps/contacts/'); + $this->urlGenerator->expects($this->once()) ->method('getAbsoluteURL') - ->with('/apps/contacts/All contacts/' . $contact) - ->willReturn('/apps/contacts/All contacts/' . $contact); + ->with('/index.php/apps/contacts/All contacts/' . $contact) + ->willReturn('/index.php/apps/contacts/All contacts/' . $contact); $result = $this->controller->direct('uuid~addressbook'); $this->assertTrue($result instanceof RedirectResponse); - $this->assertEquals('/apps/contacts/All contacts/' . $contact, $result->getRedirectURL()); + $this->assertEquals('/index.php/apps/contacts/All contacts/' . $contact, $result->getRedirectURL()); } }