aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-04-15 07:58:01 +0200
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-04-15 07:58:01 +0200
commitaf497a641c2a46c99bbc67215e041a46c91695bc (patch)
tree40795f74b9bf9b6bcfeab4f71e39994c6688dd31 /src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php
parentf2e5fdc3666a2a6525b4202ab48df05efeebaf5c (diff)
downloadwallabag-af497a641c2a46c99bbc67215e041a46c91695bc.tar.gz
wallabag-af497a641c2a46c99bbc67215e041a46c91695bc.tar.zst
wallabag-af497a641c2a46c99bbc67215e041a46c91695bc.zip
Redirect to homepage if referer is null
Fix #1924
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php b/src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php
new file mode 100644
index 00000000..da19cf58
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php
@@ -0,0 +1,49 @@
1<?php
2
3namespace Wallabag\CoreBundle\Tests\Helper;
4
5use Wallabag\CoreBundle\Helper\Redirect;
6
7class RedirectTest extends \PHPUnit_Framework_TestCase
8{
9 /** @var \Symfony\Component\Routing\Router */
10 private $routerMock;
11
12 /** @var Redirect */
13 private $redirect;
14
15 public function setUp()
16 {
17 $this->routerMock = $this->getRouterMock();
18 $this->redirect = new Redirect($this->routerMock);
19 }
20
21 public function testRedirectToNullWithFallback()
22 {
23 $redirectUrl = $this->redirect->to(null, 'fallback');
24
25 $this->assertEquals('fallback', $redirectUrl);
26 }
27
28 public function testRedirectToNullWithoutFallback()
29 {
30 $redirectUrl = $this->redirect->to(null);
31
32 $this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl);
33 }
34
35 public function testRedirectToValidUrl()
36 {
37 $redirectUrl = $this->redirect->to('/unread/list');
38
39 $this->assertEquals('/unread/list', $redirectUrl);
40 }
41
42 private function getRouterMock()
43 {
44 return $this->getMockBuilder('Symfony\Component\Routing\Router')
45 ->setMethods(['generate'])
46 ->disableOriginalConstructor()
47 ->getMock();
48 }
49}