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.php20
-rw-r--r--src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php17
2 files changed, 27 insertions, 10 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index 3a775182..1d1620dc 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -38,7 +38,7 @@ class EntryControllerTest extends WallabagCoreTestCase
38 $form = $crawler->filter('button[type=submit]')->form(); 38 $form = $crawler->filter('button[type=submit]')->form();
39 39
40 $data = array( 40 $data = array(
41 'entry[url]' => 'https://www.wallabag.org/blog/2016/01/08/wallabag-alpha1-v2', 41 'entry[url]' => $this->url,
42 ); 42 );
43 43
44 $client->submit($form, $data); 44 $client->submit($form, $data);
@@ -82,7 +82,7 @@ class EntryControllerTest extends WallabagCoreTestCase
82 ->get('doctrine.orm.entity_manager'); 82 ->get('doctrine.orm.entity_manager');
83 $entry = $em 83 $entry = $em
84 ->getRepository('WallabagCoreBundle:Entry') 84 ->getRepository('WallabagCoreBundle:Entry')
85 ->findOneByUrl($this->url); 85 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
86 $em->remove($entry); 86 $em->remove($entry);
87 $em->flush(); 87 $em->flush();
88 } 88 }
@@ -202,7 +202,7 @@ class EntryControllerTest extends WallabagCoreTestCase
202 $content = $client->getContainer() 202 $content = $client->getContainer()
203 ->get('doctrine.orm.entity_manager') 203 ->get('doctrine.orm.entity_manager')
204 ->getRepository('WallabagCoreBundle:Entry') 204 ->getRepository('WallabagCoreBundle:Entry')
205 ->findOneByUrl($this->url); 205 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
206 206
207 $client->request('GET', '/view/'.$content->getId()); 207 $client->request('GET', '/view/'.$content->getId());
208 208
@@ -223,7 +223,7 @@ class EntryControllerTest extends WallabagCoreTestCase
223 $content = $client->getContainer() 223 $content = $client->getContainer()
224 ->get('doctrine.orm.entity_manager') 224 ->get('doctrine.orm.entity_manager')
225 ->getRepository('WallabagCoreBundle:Entry') 225 ->getRepository('WallabagCoreBundle:Entry')
226 ->findOneByUrl($this->url); 226 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
227 227
228 // empty content 228 // empty content
229 $content->setContent(''); 229 $content->setContent('');
@@ -237,7 +237,7 @@ class EntryControllerTest extends WallabagCoreTestCase
237 $content = $client->getContainer() 237 $content = $client->getContainer()
238 ->get('doctrine.orm.entity_manager') 238 ->get('doctrine.orm.entity_manager')
239 ->getRepository('WallabagCoreBundle:Entry') 239 ->getRepository('WallabagCoreBundle:Entry')
240 ->findOneByUrl($this->url); 240 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
241 241
242 $this->assertNotEmpty($content->getContent()); 242 $this->assertNotEmpty($content->getContent());
243 } 243 }
@@ -250,7 +250,7 @@ class EntryControllerTest extends WallabagCoreTestCase
250 $content = $client->getContainer() 250 $content = $client->getContainer()
251 ->get('doctrine.orm.entity_manager') 251 ->get('doctrine.orm.entity_manager')
252 ->getRepository('WallabagCoreBundle:Entry') 252 ->getRepository('WallabagCoreBundle:Entry')
253 ->findOneByUrl($this->url); 253 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
254 254
255 $crawler = $client->request('GET', '/edit/'.$content->getId()); 255 $crawler = $client->request('GET', '/edit/'.$content->getId());
256 256
@@ -268,7 +268,7 @@ class EntryControllerTest extends WallabagCoreTestCase
268 $content = $client->getContainer() 268 $content = $client->getContainer()
269 ->get('doctrine.orm.entity_manager') 269 ->get('doctrine.orm.entity_manager')
270 ->getRepository('WallabagCoreBundle:Entry') 270 ->getRepository('WallabagCoreBundle:Entry')
271 ->findOneByUrl($this->url); 271 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
272 272
273 $crawler = $client->request('GET', '/edit/'.$content->getId()); 273 $crawler = $client->request('GET', '/edit/'.$content->getId());
274 274
@@ -298,7 +298,7 @@ class EntryControllerTest extends WallabagCoreTestCase
298 $content = $client->getContainer() 298 $content = $client->getContainer()
299 ->get('doctrine.orm.entity_manager') 299 ->get('doctrine.orm.entity_manager')
300 ->getRepository('WallabagCoreBundle:Entry') 300 ->getRepository('WallabagCoreBundle:Entry')
301 ->findOneByUrl($this->url); 301 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
302 302
303 $client->request('GET', '/archive/'.$content->getId()); 303 $client->request('GET', '/archive/'.$content->getId());
304 304
@@ -320,7 +320,7 @@ class EntryControllerTest extends WallabagCoreTestCase
320 $content = $client->getContainer() 320 $content = $client->getContainer()
321 ->get('doctrine.orm.entity_manager') 321 ->get('doctrine.orm.entity_manager')
322 ->getRepository('WallabagCoreBundle:Entry') 322 ->getRepository('WallabagCoreBundle:Entry')
323 ->findOneByUrl($this->url); 323 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
324 324
325 $client->request('GET', '/star/'.$content->getId()); 325 $client->request('GET', '/star/'.$content->getId());
326 326
@@ -342,7 +342,7 @@ class EntryControllerTest extends WallabagCoreTestCase
342 $content = $client->getContainer() 342 $content = $client->getContainer()
343 ->get('doctrine.orm.entity_manager') 343 ->get('doctrine.orm.entity_manager')
344 ->getRepository('WallabagCoreBundle:Entry') 344 ->getRepository('WallabagCoreBundle:Entry')
345 ->findOneByUrl($this->url); 345 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
346 346
347 $client->request('GET', '/delete/'.$content->getId()); 347 $client->request('GET', '/delete/'.$content->getId());
348 348
diff --git a/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php b/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php
index ce3cabe8..c4905478 100644
--- a/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php
+++ b/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php
@@ -31,4 +31,21 @@ abstract class WallabagCoreTestCase extends WebTestCase
31 31
32 $this->client->submit($form, $data); 32 $this->client->submit($form, $data);
33 } 33 }
34
35 /**
36 * Return the user id of the logged in user.
37 * You should be sure that you called `logInAs` before.
38 *
39 * @return int
40 */
41 public function getLoggedInUserId()
42 {
43 $token = static::$kernel->getContainer()->get('security.token_storage')->getToken();
44
45 if (null !== $token) {
46 return $token->getUser()->getId();
47 }
48
49 throw new \RuntimeException('No logged in User.');
50 }
34} 51}