From 78833672469f7beb0c4a195aa0a76f7ca4133057 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 15 Jan 2016 15:28:22 +0100 Subject: Fix `findOneByUrl` side effect in tests Fix #1566 --- src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php') 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.'); + } } -- cgit v1.2.3