aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-11-07 10:26:05 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-11-16 23:07:34 +0100
commit65cd8a4a9a1d15d962033f58276005a5f7716f3a (patch)
treec0dd762b631ae22443fb5efba3b838aeee01f7af /tests/Wallabag
parentf052f1fd57e51c8ae5ac17587636d608619a2057 (diff)
downloadwallabag-65cd8a4a9a1d15d962033f58276005a5f7716f3a.tar.gz
wallabag-65cd8a4a9a1d15d962033f58276005a5f7716f3a.tar.zst
wallabag-65cd8a4a9a1d15d962033f58276005a5f7716f3a.zip
Added tests
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php65
-rw-r--r--tests/Wallabag/CoreBundle/Helper/RedirectTest.php4
2 files changed, 67 insertions, 2 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 4ab06dbf..bf4e0543 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -3,6 +3,7 @@
3namespace Tests\Wallabag\CoreBundle\Controller; 3namespace Tests\Wallabag\CoreBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Wallabag\CoreBundle\Entity\Config;
6use Wallabag\CoreBundle\Entity\Entry; 7use Wallabag\CoreBundle\Entity\Entry;
7 8
8class EntryControllerTest extends WallabagCoreTestCase 9class EntryControllerTest extends WallabagCoreTestCase
@@ -896,4 +897,68 @@ class EntryControllerTest extends WallabagCoreTestCase
896 897
897 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0); 898 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
898 } 899 }
900
901 public function testRedirectToHomepage()
902 {
903 $this->logInAs('empty');
904 $client = $this->getClient();
905
906 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
907 $user = $em
908 ->getRepository('WallabagUserBundle:User')
909 ->find($this->getLoggedInUserId());
910
911 if (!$user) {
912 $this->markTestSkipped('No user found in db.');
913 }
914
915 // Redirect to homepage
916 $config = $user->getConfig();
917 $config->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE);
918 $em->persist($config);
919 $em->flush();
920
921 $content = $client->getContainer()
922 ->get('doctrine.orm.entity_manager')
923 ->getRepository('WallabagCoreBundle:Entry')
924 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
925
926 $client->request('GET', '/view/'.$content->getId());
927 $client->request('GET', '/archive/'.$content->getId());
928
929 $this->assertEquals(302, $client->getResponse()->getStatusCode());
930 $this->assertEquals('/', $client->getResponse()->headers->get('location'));
931 }
932
933 public function testRedirectToCurrentPage()
934 {
935 $this->logInAs('empty');
936 $client = $this->getClient();
937
938 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
939 $user = $em
940 ->getRepository('WallabagUserBundle:User')
941 ->find($this->getLoggedInUserId());
942
943 if (!$user) {
944 $this->markTestSkipped('No user found in db.');
945 }
946
947 // Redirect to current page
948 $config = $user->getConfig();
949 $config->setActionMarkAsRead(Config::REDIRECT_TO_CURRENT_PAGE);
950 $em->persist($config);
951 $em->flush();
952
953 $content = $client->getContainer()
954 ->get('doctrine.orm.entity_manager')
955 ->getRepository('WallabagCoreBundle:Entry')
956 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
957
958 $client->request('GET', '/view/'.$content->getId());
959 $client->request('GET', '/archive/'.$content->getId());
960
961 $this->assertEquals(302, $client->getResponse()->getStatusCode());
962 $this->assertContains('/view/'.$content->getId(), $client->getResponse()->headers->get('location'));
963 }
899} 964}
diff --git a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
index 825e8d53..a2d6a524 100644
--- a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
@@ -25,14 +25,14 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
25 { 25 {
26 $redirectUrl = $this->redirect->to(null, 'fallback'); 26 $redirectUrl = $this->redirect->to(null, 'fallback');
27 27
28 $this->assertEquals('fallback', $redirectUrl); 28 $this->assertEquals(null, $redirectUrl);
29 } 29 }
30 30
31 public function testRedirectToNullWithoutFallback() 31 public function testRedirectToNullWithoutFallback()
32 { 32 {
33 $redirectUrl = $this->redirect->to(null); 33 $redirectUrl = $this->redirect->to(null);
34 34
35 $this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl); 35 $this->assertEquals(null, $redirectUrl);
36 } 36 }
37 37
38 public function testRedirectToValidUrl() 38 public function testRedirectToValidUrl()