aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-06-23 11:47:46 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-06-23 11:47:46 +0200
commitf49d9ca383c9f8a1bc426cfabf6b1cea53ea26b4 (patch)
tree156b1a29cfbe1962e68d409c3dea5a3911a34e9c /tests/Wallabag/CoreBundle/Helper/RedirectTest.php
parent49e2854d5c15bbce3f24f91da34450e8f209295b (diff)
parentfb5c17a9ab5e10b1de9caa50e73638fdae19cb78 (diff)
downloadwallabag-f49d9ca383c9f8a1bc426cfabf6b1cea53ea26b4.tar.gz
wallabag-f49d9ca383c9f8a1bc426cfabf6b1cea53ea26b4.tar.zst
wallabag-f49d9ca383c9f8a1bc426cfabf6b1cea53ea26b4.zip
Merge branch 'master' into 2.1
Diffstat (limited to 'tests/Wallabag/CoreBundle/Helper/RedirectTest.php')
-rw-r--r--tests/Wallabag/CoreBundle/Helper/RedirectTest.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
new file mode 100644
index 00000000..f339f75e
--- /dev/null
+++ b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
@@ -0,0 +1,55 @@
1<?php
2
3namespace Tests\Wallabag\CoreBundle\Helper;
4
5use Wallabag\CoreBundle\Helper\Redirect;
6
7class RedirectTest extends \PHPUnit_Framework_TestCase
8{
9 /** @var \PHPUnit_Framework_MockObject_MockObject */
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 $mock = $this->getMockBuilder('Symfony\Component\Routing\Router')
45 ->disableOriginalConstructor()
46 ->getMock();
47
48 $mock->expects($this->any())
49 ->method('generate')
50 ->with('homepage')
51 ->willReturn('homepage');
52
53 return $mock;
54 }
55}