diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-04-15 17:52:33 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-04-15 17:52:33 +0200 |
commit | d1f4996b77bc9c7b692cd98d835476f1c84edc28 (patch) | |
tree | e5e27ae5b1fa4f4d71623d13ba33e2ff7669f0cd /src/Wallabag/CoreBundle/Tests | |
parent | 51803026501e7098eaa889df489cd037d6dc22cd (diff) | |
parent | 345d74268b2d3d232b2de02f30e950d032a2e7b5 (diff) | |
download | wallabag-d1f4996b77bc9c7b692cd98d835476f1c84edc28.tar.gz wallabag-d1f4996b77bc9c7b692cd98d835476f1c84edc28.tar.zst wallabag-d1f4996b77bc9c7b692cd98d835476f1c84edc28.zip |
Merge pull request #1925 from wallabag/fix-redirect-without-referer
Redirect to homepage if referer is null
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php | 55 |
1 files changed, 55 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..f4aecc80 --- /dev/null +++ b/src/Wallabag/CoreBundle/Tests/Helper/RedirectTest.php | |||
@@ -0,0 +1,55 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Tests\Helper; | ||
4 | |||
5 | use Wallabag\CoreBundle\Helper\Redirect; | ||
6 | |||
7 | class 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 | } | ||