]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php
Fix `findOneByUrl` side effect in tests
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Tests / WallabagCoreTestCase.php
index ce3cabe8d36af3f82d8c782a7d7855c1eb0245c1..c4905478b27552e4304b23908e0069fff65e2389 100644 (file)
@@ -31,4 +31,21 @@ abstract class WallabagCoreTestCase extends WebTestCase
 
         $this->client->submit($form, $data);
     }
+
+    /**
+     * Return the user id of the logged in user.
+     * You should be sure that you called `logInAs` before.
+     *
+     * @return int
+     */
+    public function getLoggedInUserId()
+    {
+        $token = static::$kernel->getContainer()->get('security.token_storage')->getToken();
+
+        if (null !== $token) {
+            return $token->getUser()->getId();
+        }
+
+        throw new \RuntimeException('No logged in User.');
+    }
 }