]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - tests/Wallabag/CoreBundle/Helper/RedirectTest.php
Enable PHPStan
[github/wallabag/wallabag.git] / tests / Wallabag / CoreBundle / Helper / RedirectTest.php
index 0539f20a90ddcffd5c24d12e1e25dd9df9eb54f6..29e12cbe5c90832716edea6550fbf09bb171c543 100644 (file)
@@ -2,13 +2,14 @@
 
 namespace Tests\Wallabag\CoreBundle\Helper;
 
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
+use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
 use Wallabag\CoreBundle\Entity\Config;
-use Wallabag\UserBundle\Entity\User;
 use Wallabag\CoreBundle\Helper\Redirect;
-use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
-use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
+use Wallabag\UserBundle\Entity\User;
 
-class RedirectTest extends \PHPUnit_Framework_TestCase
+class RedirectTest extends TestCase
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject */
     private $routerMock;
@@ -16,6 +17,9 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
     /** @var Redirect */
     private $redirect;
 
+    /** @var UsernamePasswordToken */
+    private $token;
+
     public function setUp()
     {
         $this->routerMock = $this->getMockBuilder('Symfony\Component\Routing\Router')
@@ -56,21 +60,21 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
     {
         $redirectUrl = $this->redirect->to(null, 'fallback');
 
-        $this->assertEquals('fallback', $redirectUrl);
+        $this->assertSame('fallback', $redirectUrl);
     }
 
     public function testRedirectToNullWithoutFallback()
     {
         $redirectUrl = $this->redirect->to(null);
 
-        $this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl);
+        $this->assertSame($this->routerMock->generate('homepage'), $redirectUrl);
     }
 
     public function testRedirectToValidUrl()
     {
         $redirectUrl = $this->redirect->to('/unread/list');
 
-        $this->assertEquals('/unread/list', $redirectUrl);
+        $this->assertSame('/unread/list', $redirectUrl);
     }
 
     public function testWithNotLoggedUser()
@@ -78,7 +82,7 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
         $redirect = new Redirect($this->routerMock, new TokenStorage());
         $redirectUrl = $redirect->to('/unread/list');
 
-        $this->assertEquals('/unread/list', $redirectUrl);
+        $this->assertSame('/unread/list', $redirectUrl);
     }
 
     public function testUserForRedirectToHomepage()
@@ -87,6 +91,24 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
 
         $redirectUrl = $this->redirect->to('/unread/list');
 
-        $this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl);
+        $this->assertSame($this->routerMock->generate('homepage'), $redirectUrl);
+    }
+
+    public function testUserForRedirectWithIgnoreActionMarkAsRead()
+    {
+        $this->token->getUser()->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE);
+
+        $redirectUrl = $this->redirect->to('/unread/list', '', true);
+
+        $this->assertSame('/unread/list', $redirectUrl);
+    }
+
+    public function testUserForRedirectNullWithFallbackWithIgnoreActionMarkAsRead()
+    {
+        $this->token->getUser()->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE);
+
+        $redirectUrl = $this->redirect->to(null, 'fallback', true);
+
+        $this->assertSame('fallback', $redirectUrl);
     }
 }