aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-04-15 09:58:29 +0200
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-04-15 09:58:29 +0200
commit4086e0782e4545bd3572f929b4476b200588f6c0 (patch)
treef7f58dcfa4d6f3a0c0be67700322c8821341cea4 /src
parentaf497a641c2a46c99bbc67215e041a46c91695bc (diff)
downloadwallabag-4086e0782e4545bd3572f929b4476b200588f6c0.tar.gz
wallabag-4086e0782e4545bd3572f929b4476b200588f6c0.tar.zst
wallabag-4086e0782e4545bd3572f929b4476b200588f6c0.zip
Fix tests
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Helper/Redirect.php17
-rw-r--r--src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php12
2 files changed, 18 insertions, 11 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/Redirect.php b/src/Wallabag/CoreBundle/Helper/Redirect.php
index 0921c3f9..c14c79d1 100644
--- a/src/Wallabag/CoreBundle/Helper/Redirect.php
+++ b/src/Wallabag/CoreBundle/Helper/Redirect.php
@@ -4,6 +4,9 @@ namespace Wallabag\CoreBundle\Helper;
4 4
5use Symfony\Component\Routing\Router; 5use Symfony\Component\Routing\Router;
6 6
7/**
8 * Manage redirections to avoid redirecting to empty routes.
9 */
7class Redirect 10class Redirect
8{ 11{
9 private $router; 12 private $router;
@@ -21,16 +24,14 @@ class Redirect
21 */ 24 */
22 public function to($url, $fallback = '') 25 public function to($url, $fallback = '')
23 { 26 {
24 $returnUrl = $url; 27 if (null !== $url) {
28 return $url;
29 }
25 30
26 if (null === $url) { 31 if ('' === $fallback) {
27 if ('' !== $fallback) { 32 return $this->router->generate('homepage');
28 $returnUrl = $fallback;
29 } else {
30 $returnUrl = $this->router->generate('homepage');
31 }
32 } 33 }
33 34
34 return $returnUrl; 35 return $fallback;
35 } 36 }
36} 37}
diff --git a/src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php b/src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php
index da19cf58..f4aecc80 100644
--- a/src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php
@@ -6,7 +6,7 @@ use Wallabag\CoreBundle\Helper\Redirect;
6 6
7class RedirectTest extends \PHPUnit_Framework_TestCase 7class RedirectTest extends \PHPUnit_Framework_TestCase
8{ 8{
9 /** @var \Symfony\Component\Routing\Router */ 9 /** @var \PHPUnit_Framework_MockObject_MockObject */
10 private $routerMock; 10 private $routerMock;
11 11
12 /** @var Redirect */ 12 /** @var Redirect */
@@ -41,9 +41,15 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
41 41
42 private function getRouterMock() 42 private function getRouterMock()
43 { 43 {
44 return $this->getMockBuilder('Symfony\Component\Routing\Router') 44 $mock = $this->getMockBuilder('Symfony\Component\Routing\Router')
45 ->setMethods(['generate'])
46 ->disableOriginalConstructor() 45 ->disableOriginalConstructor()
47 ->getMock(); 46 ->getMock();
47
48 $mock->expects($this->any())
49 ->method('generate')
50 ->with('homepage')
51 ->willReturn('homepage');
52
53 return $mock;
48 } 54 }
49} 55}