diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php | 17 |
1 files changed, 17 insertions, 0 deletions
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 | } |