Remove support for fallback in Redirect helper

This commit is contained in:
Yassine Guedidi
2023-12-28 21:16:32 +01:00
parent ffec47bd88
commit f4493f7472
4 changed files with 14 additions and 31 deletions

View File

@ -33,7 +33,7 @@ class RedirectTest extends TestCase
$this->routerMock->expects($this->any())
->method('generate')
->with('homepage')
->willReturn('homepage');
->willReturn('/');
$this->user = new User();
$this->user->setName('youpi');
@ -59,18 +59,11 @@ class RedirectTest extends TestCase
$this->redirect = new Redirect($this->routerMock, $tokenStorage);
}
public function testRedirectToNullWithFallback()
{
$redirectUrl = $this->redirect->to(null, 'fallback');
$this->assertSame('fallback', $redirectUrl);
}
public function testRedirectToNullWithoutFallback()
public function testRedirectToNull()
{
$redirectUrl = $this->redirect->to(null);
$this->assertSame($this->routerMock->generate('homepage'), $redirectUrl);
$this->assertSame('/', $redirectUrl);
}
public function testRedirectToValidUrl()
@ -94,24 +87,24 @@ class RedirectTest extends TestCase
$redirectUrl = $this->redirect->to('/unread/list');
$this->assertSame($this->routerMock->generate('homepage'), $redirectUrl);
$this->assertSame('/', $redirectUrl);
}
public function testUserForRedirectWithIgnoreActionMarkAsRead()
{
$this->user->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE);
$redirectUrl = $this->redirect->to('/unread/list', '', true);
$redirectUrl = $this->redirect->to('/unread/list', true);
$this->assertSame('/unread/list', $redirectUrl);
}
public function testUserForRedirectNullWithFallbackWithIgnoreActionMarkAsRead()
public function testUserForRedirectNullWithIgnoreActionMarkAsRead()
{
$this->user->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE);
$redirectUrl = $this->redirect->to(null, 'fallback', true);
$redirectUrl = $this->redirect->to(null, true);
$this->assertSame('fallback', $redirectUrl);
$this->assertSame('/', $redirectUrl);
}
}