3 namespace Wallabag\CoreBundle\Tests\Helper
;
5 use Wallabag\CoreBundle\Helper\Redirect
;
7 class RedirectTest
extends \PHPUnit_Framework_TestCase
9 /** @var \Symfony\Component\Routing\Router */
15 public function setUp()
17 $this->routerMock
= $this->getRouterMock();
18 $this->redirect
= new Redirect($this->routerMock
);
21 public function testRedirectToNullWithFallback()
23 $redirectUrl = $this->redirect
->to(null, 'fallback');
25 $this->assertEquals('fallback', $redirectUrl);
28 public function testRedirectToNullWithoutFallback()
30 $redirectUrl = $this->redirect
->to(null);
32 $this->assertEquals($this->routerMock
->generate('homepage'), $redirectUrl);
35 public function testRedirectToValidUrl()
37 $redirectUrl = $this->redirect
->to('/unread/list');
39 $this->assertEquals('/unread/list', $redirectUrl);
42 private function getRouterMock()
44 return $this->getMockBuilder('Symfony\Component\Routing\Router')
45 ->setMethods(['generate'])
46 ->disableOriginalConstructor()