X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FTests%2FWallabagCoreTestCase.php;h=c4905478b27552e4304b23908e0069fff65e2389;hb=2a58606983bd6091866a9f38149a87c25900decd;hp=ce3cabe8d36af3f82d8c782a7d7855c1eb0245c1;hpb=f1eccfd63f214dcc730ab0d18a694a5465f425db;p=github%2Fwallabag%2Fwallabag.git 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 $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.'); + } }