aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php91
-rw-r--r--src/Wallabag/CoreBundle/Tests/WallabagTestCase.php4
2 files changed, 79 insertions, 16 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index 5d8daea3..05854525 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -3,6 +3,7 @@
3namespace Wallabag\CoreBundle\Tests\Controller; 3namespace Wallabag\CoreBundle\Tests\Controller;
4 4
5use Wallabag\CoreBundle\Tests\WallabagTestCase; 5use Wallabag\CoreBundle\Tests\WallabagTestCase;
6use Doctrine\ORM\AbstractQuery;
6 7
7class EntryControllerTest extends WallabagTestCase 8class EntryControllerTest extends WallabagTestCase
8{ 9{
@@ -10,7 +11,7 @@ class EntryControllerTest extends WallabagTestCase
10 { 11 {
11 $client = $this->getClient(); 12 $client = $this->getClient();
12 13
13 $crawler = $client->request('GET', '/new'); 14 $client->request('GET', '/new');
14 15
15 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 16 $this->assertEquals(302, $client->getResponse()->getStatusCode());
16 $this->assertContains('login', $client->getResponse()->headers->get('location')); 17 $this->assertContains('login', $client->getResponse()->headers->get('location'));
@@ -18,7 +19,7 @@ class EntryControllerTest extends WallabagTestCase
18 19
19 public function testGetNew() 20 public function testGetNew()
20 { 21 {
21 $this->logIn(); 22 $this->logInAs('admin');
22 $client = $this->getClient(); 23 $client = $this->getClient();
23 24
24 $crawler = $client->request('GET', '/new'); 25 $crawler = $client->request('GET', '/new');
@@ -31,7 +32,7 @@ class EntryControllerTest extends WallabagTestCase
31 32
32 public function testPostNewEmpty() 33 public function testPostNewEmpty()
33 { 34 {
34 $this->logIn(); 35 $this->logInAs('admin');
35 $client = $this->getClient(); 36 $client = $this->getClient();
36 37
37 $crawler = $client->request('GET', '/new'); 38 $crawler = $client->request('GET', '/new');
@@ -49,7 +50,7 @@ class EntryControllerTest extends WallabagTestCase
49 50
50 public function testPostNewOk() 51 public function testPostNewOk()
51 { 52 {
52 $this->logIn(); 53 $this->logInAs('admin');
53 $client = $this->getClient(); 54 $client = $this->getClient();
54 55
55 $crawler = $client->request('GET', '/new'); 56 $crawler = $client->request('GET', '/new');
@@ -74,27 +75,27 @@ class EntryControllerTest extends WallabagTestCase
74 75
75 public function testArchive() 76 public function testArchive()
76 { 77 {
77 $this->logIn(); 78 $this->logInAs('admin');
78 $client = $this->getClient(); 79 $client = $this->getClient();
79 80
80 $crawler = $client->request('GET', '/archive'); 81 $client->request('GET', '/archive');
81 82
82 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 83 $this->assertEquals(200, $client->getResponse()->getStatusCode());
83 } 84 }
84 85
85 public function testStarred() 86 public function testStarred()
86 { 87 {
87 $this->logIn(); 88 $this->logInAs('admin');
88 $client = $this->getClient(); 89 $client = $this->getClient();
89 90
90 $crawler = $client->request('GET', '/starred'); 91 $client->request('GET', '/starred');
91 92
92 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 93 $this->assertEquals(200, $client->getResponse()->getStatusCode());
93 } 94 }
94 95
95 public function testView() 96 public function testView()
96 { 97 {
97 $this->logIn(); 98 $this->logInAs('admin');
98 $client = $this->getClient(); 99 $client = $this->getClient();
99 100
100 $content = $client->getContainer() 101 $content = $client->getContainer()
@@ -102,13 +103,75 @@ class EntryControllerTest extends WallabagTestCase
102 ->getRepository('WallabagCoreBundle:Entry') 103 ->getRepository('WallabagCoreBundle:Entry')
103 ->findOneByIsArchived(false); 104 ->findOneByIsArchived(false);
104 105
105 if (!$content) { 106 $client->request('GET', '/view/'.$content->getId());
106 $this->markTestSkipped('No content found in db.');
107 }
108
109 $crawler = $client->request('GET', '/view/'.$content->getId());
110 107
111 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 108 $this->assertEquals(200, $client->getResponse()->getStatusCode());
112 $this->assertContains($content->getTitle(), $client->getResponse()->getContent()); 109 $this->assertContains($content->getTitle(), $client->getResponse()->getContent());
113 } 110 }
111
112 public function testToggleArchive()
113 {
114 $this->logInAs('admin');
115 $client = $this->getClient();
116
117 $content = $client->getContainer()
118 ->get('doctrine.orm.entity_manager')
119 ->getRepository('WallabagCoreBundle:Entry')
120 ->findOneByIsArchived(false);
121
122 $client->request('GET', '/archive/'.$content->getId());
123
124 $this->assertEquals(302, $client->getResponse()->getStatusCode());
125
126 $res = $client->getContainer()
127 ->get('doctrine.orm.entity_manager')
128 ->getRepository('WallabagCoreBundle:Entry')
129 ->findOneById($content->getId());
130
131 $this->assertEquals($res->isArchived(), true);
132 }
133
134 public function testToggleStar()
135 {
136 $this->logInAs('admin');
137 $client = $this->getClient();
138
139 $content = $client->getContainer()
140 ->get('doctrine.orm.entity_manager')
141 ->getRepository('WallabagCoreBundle:Entry')
142 ->findOneByIsStarred(false);
143
144 $client->request('GET', '/star/'.$content->getId());
145
146 $this->assertEquals(302, $client->getResponse()->getStatusCode());
147
148 $res = $client->getContainer()
149 ->get('doctrine.orm.entity_manager')
150 ->getRepository('WallabagCoreBundle:Entry')
151 ->findOneById($content->getId());
152
153 $this->assertEquals($res->isStarred(), true);
154 }
155
156 public function testDelete()
157 {
158 $this->logInAs('admin');
159 $client = $this->getClient();
160
161 $content = $client->getContainer()
162 ->get('doctrine.orm.entity_manager')
163 ->getRepository('WallabagCoreBundle:Entry')
164 ->findOneByIsDeleted(false);
165
166 $client->request('GET', '/delete/'.$content->getId());
167
168 $this->assertEquals(302, $client->getResponse()->getStatusCode());
169
170 $res = $client->getContainer()
171 ->get('doctrine.orm.entity_manager')
172 ->getRepository('WallabagCoreBundle:Entry')
173 ->findOneById($content->getId());
174
175 $this->assertEquals($res->isDeleted(), true);
176 }
114} 177}
diff --git a/src/Wallabag/CoreBundle/Tests/WallabagTestCase.php b/src/Wallabag/CoreBundle/Tests/WallabagTestCase.php
index edc7d992..a80b8bac 100644
--- a/src/Wallabag/CoreBundle/Tests/WallabagTestCase.php
+++ b/src/Wallabag/CoreBundle/Tests/WallabagTestCase.php
@@ -18,12 +18,12 @@ class WallabagTestCase extends WebTestCase
18 $this->client = static::createClient(); 18 $this->client = static::createClient();
19 } 19 }
20 20
21 public function logIn() 21 public function logInAs($username)
22 { 22 {
23 $crawler = $this->client->request('GET', '/login'); 23 $crawler = $this->client->request('GET', '/login');
24 $form = $crawler->filter('button[type=submit]')->form(); 24 $form = $crawler->filter('button[type=submit]')->form();
25 $data = array( 25 $data = array(
26 '_username' => 'admin', 26 '_username' => $username,
27 '_password' => 'test', 27 '_password' => 'test',
28 ); 28 );
29 29