aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php42
1 files changed, 19 insertions, 23 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index cbd84a97..e9c85a17 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -7,6 +7,8 @@ use Doctrine\ORM\AbstractQuery;
7 7
8class EntryControllerTest extends WallabagCoreTestCase 8class EntryControllerTest extends WallabagCoreTestCase
9{ 9{
10 public $url = 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html';
11
10 public function testLogin() 12 public function testLogin()
11 { 13 {
12 $client = $this->getClient(); 14 $client = $this->getClient();
@@ -60,7 +62,7 @@ class EntryControllerTest extends WallabagCoreTestCase
60 $form = $crawler->filter('button[type=submit]')->form(); 62 $form = $crawler->filter('button[type=submit]')->form();
61 63
62 $data = array( 64 $data = array(
63 'entry[url]' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', 65 'entry[url]' => $this->url,
64 ); 66 );
65 67
66 $client->submit($form, $data); 68 $client->submit($form, $data);
@@ -101,7 +103,7 @@ class EntryControllerTest extends WallabagCoreTestCase
101 $content = $client->getContainer() 103 $content = $client->getContainer()
102 ->get('doctrine.orm.entity_manager') 104 ->get('doctrine.orm.entity_manager')
103 ->getRepository('WallabagCoreBundle:Entry') 105 ->getRepository('WallabagCoreBundle:Entry')
104 ->findOneByIsArchived(false); 106 ->findOneByUrl($this->url);
105 107
106 $client->request('GET', '/view/'.$content->getId()); 108 $client->request('GET', '/view/'.$content->getId());
107 109
@@ -117,7 +119,7 @@ class EntryControllerTest extends WallabagCoreTestCase
117 $content = $client->getContainer() 119 $content = $client->getContainer()
118 ->get('doctrine.orm.entity_manager') 120 ->get('doctrine.orm.entity_manager')
119 ->getRepository('WallabagCoreBundle:Entry') 121 ->getRepository('WallabagCoreBundle:Entry')
120 ->findOneByIsArchived(false); 122 ->findOneByUrl($this->url);
121 123
122 $crawler = $client->request('GET', '/edit/'.$content->getId()); 124 $crawler = $client->request('GET', '/edit/'.$content->getId());
123 125
@@ -135,7 +137,7 @@ class EntryControllerTest extends WallabagCoreTestCase
135 $content = $client->getContainer() 137 $content = $client->getContainer()
136 ->get('doctrine.orm.entity_manager') 138 ->get('doctrine.orm.entity_manager')
137 ->getRepository('WallabagCoreBundle:Entry') 139 ->getRepository('WallabagCoreBundle:Entry')
138 ->findOneByIsArchived(false); 140 ->findOneByUrl($this->url);
139 141
140 $crawler = $client->request('GET', '/edit/'.$content->getId()); 142 $crawler = $client->request('GET', '/edit/'.$content->getId());
141 143
@@ -165,7 +167,7 @@ class EntryControllerTest extends WallabagCoreTestCase
165 $content = $client->getContainer() 167 $content = $client->getContainer()
166 ->get('doctrine.orm.entity_manager') 168 ->get('doctrine.orm.entity_manager')
167 ->getRepository('WallabagCoreBundle:Entry') 169 ->getRepository('WallabagCoreBundle:Entry')
168 ->findOneByIsArchived(false); 170 ->findOneByUrl($this->url);
169 171
170 $client->request('GET', '/archive/'.$content->getId()); 172 $client->request('GET', '/archive/'.$content->getId());
171 173
@@ -174,7 +176,7 @@ class EntryControllerTest extends WallabagCoreTestCase
174 $res = $client->getContainer() 176 $res = $client->getContainer()
175 ->get('doctrine.orm.entity_manager') 177 ->get('doctrine.orm.entity_manager')
176 ->getRepository('WallabagCoreBundle:Entry') 178 ->getRepository('WallabagCoreBundle:Entry')
177 ->findOneById($content->getId()); 179 ->find($content->getId());
178 180
179 $this->assertEquals($res->isArchived(), true); 181 $this->assertEquals($res->isArchived(), true);
180 } 182 }
@@ -187,7 +189,7 @@ class EntryControllerTest extends WallabagCoreTestCase
187 $content = $client->getContainer() 189 $content = $client->getContainer()
188 ->get('doctrine.orm.entity_manager') 190 ->get('doctrine.orm.entity_manager')
189 ->getRepository('WallabagCoreBundle:Entry') 191 ->getRepository('WallabagCoreBundle:Entry')
190 ->findOneByIsStarred(false); 192 ->findOneByUrl($this->url);
191 193
192 $client->request('GET', '/star/'.$content->getId()); 194 $client->request('GET', '/star/'.$content->getId());
193 195
@@ -209,7 +211,7 @@ class EntryControllerTest extends WallabagCoreTestCase
209 $content = $client->getContainer() 211 $content = $client->getContainer()
210 ->get('doctrine.orm.entity_manager') 212 ->get('doctrine.orm.entity_manager')
211 ->getRepository('WallabagCoreBundle:Entry') 213 ->getRepository('WallabagCoreBundle:Entry')
212 ->findOneByIsStarred(false); 214 ->findOneByUrl($this->url);
213 215
214 $client->request('GET', '/delete/'.$content->getId()); 216 $client->request('GET', '/delete/'.$content->getId());
215 217
@@ -222,21 +224,15 @@ class EntryControllerTest extends WallabagCoreTestCase
222 224
223 public function testViewOtherUserEntry() 225 public function testViewOtherUserEntry()
224 { 226 {
225 $this->logInAs('bob'); 227 $this->logInAs('admin');
226 $client = $this->getClient(); 228 $client = $this->getClient();
227 229
228 $content = $client->getContainer() 230 $content = $client->getContainer()
229 ->get('doctrine.orm.entity_manager') 231 ->get('doctrine.orm.entity_manager')
230 ->getRepository('WallabagCoreBundle:Entry') 232 ->getRepository('WallabagCoreBundle:Entry')
231 ->createQueryBuilder('e') 233 ->findOneByUsernameAndNotArchived('bob');
232 ->select('e.id')
233 ->leftJoin('e.user', 'u')
234 ->where('u.username != :username')->setParameter('username', 'bob')
235 ->setMaxResults(1)
236 ->getQuery()
237 ->getSingleResult(AbstractQuery::HYDRATE_ARRAY);
238 234
239 $client->request('GET', '/view/'.$content['id']); 235 $client->request('GET', '/view/'.$content->getId());
240 236
241 $this->assertEquals(403, $client->getResponse()->getStatusCode()); 237 $this->assertEquals(403, $client->getResponse()->getStatusCode());
242 } 238 }
@@ -334,11 +330,11 @@ class EntryControllerTest extends WallabagCoreTestCase
334 $crawler = $client->request('GET', '/unread/list'); 330 $crawler = $client->request('GET', '/unread/list');
335 $form = $crawler->filter('button[id=submit-filter]')->form(); 331 $form = $crawler->filter('button[id=submit-filter]')->form();
336 $data = array( 332 $data = array(
337 'entry_filter[domainName]' => 'monde', 333 'entry_filter[domainName]' => 'domain',
338 ); 334 );
339 335
340 $crawler = $client->submit($form, $data); 336 $crawler = $client->submit($form, $data);
341 $this->assertCount(1, $crawler->filter('div[class=entry]')); 337 $this->assertCount(5, $crawler->filter('div[class=entry]'));
342 338
343 $form = $crawler->filter('button[id=submit-filter]')->form(); 339 $form = $crawler->filter('button[id=submit-filter]')->form();
344 $data = array( 340 $data = array(
@@ -360,14 +356,14 @@ class EntryControllerTest extends WallabagCoreTestCase
360 $form['entry_filter[isStarred]']->untick(); 356 $form['entry_filter[isStarred]']->untick();
361 357
362 $crawler = $client->submit($form); 358 $crawler = $client->submit($form);
363 $this->assertCount(2, $crawler->filter('div[class=entry]')); 359 $this->assertCount(1, $crawler->filter('div[class=entry]'));
364 360
365 $form = $crawler->filter('button[id=submit-filter]')->form(); 361 $form = $crawler->filter('button[id=submit-filter]')->form();
366 $form['entry_filter[isArchived]']->untick(); 362 $form['entry_filter[isArchived]']->untick();
367 $form['entry_filter[isStarred]']->tick(); 363 $form['entry_filter[isStarred]']->tick();
368 364
369 $crawler = $client->submit($form); 365 $crawler = $client->submit($form);
370 $this->assertCount(2, $crawler->filter('div[class=entry]')); 366 $this->assertCount(1, $crawler->filter('div[class=entry]'));
371 } 367 }
372 368
373 public function testPreviewPictureFilter() 369 public function testPreviewPictureFilter()
@@ -391,11 +387,11 @@ class EntryControllerTest extends WallabagCoreTestCase
391 $crawler = $client->request('GET', '/unread/list'); 387 $crawler = $client->request('GET', '/unread/list');
392 $form = $crawler->filter('button[id=submit-filter]')->form(); 388 $form = $crawler->filter('button[id=submit-filter]')->form();
393 $data = array( 389 $data = array(
394 'entry_filter[language]' => 'de', 390 'entry_filter[language]' => 'fr',
395 ); 391 );
396 392
397 $crawler = $client->submit($form, $data); 393 $crawler = $client->submit($form, $data);
398 $this->assertCount(1, $crawler->filter('div[class=entry]')); 394 $this->assertCount(2, $crawler->filter('div[class=entry]'));
399 395
400 $form = $crawler->filter('button[id=submit-filter]')->form(); 396 $form = $crawler->filter('button[id=submit-filter]')->form();
401 $data = array( 397 $data = array(