X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FTests%2FWallabagCoreTestCase.php;h=c4905478b27552e4304b23908e0069fff65e2389;hb=86719c63bf47686ca55020e6b0443344de36d45a;hp=e5096528cefe39d683a07a6fb67286913dc20a97;hpb=769e19dc4ab1a068e8165a7b237f42a78a6d312f;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php b/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php index e5096528..c4905478 100644 --- a/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php +++ b/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php @@ -15,6 +15,8 @@ abstract class WallabagCoreTestCase extends WebTestCase public function setUp() { + parent::setUp(); + $this->client = static::createClient(); } @@ -29,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.'); + } }