X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2FWallabag%2FCoreBundle%2FTests%2FWallabagCoreTestCase.php;h=05450c0b987ac7d86a0799213bfa555cb824e282;hb=refs%2Fpull%2F2103%2Fhead;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..05450c0b 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(); } @@ -22,11 +24,28 @@ abstract class WallabagCoreTestCase extends WebTestCase { $crawler = $this->client->request('GET', '/login'); $form = $crawler->filter('button[type=submit]')->form(); - $data = array( + $data = [ '_username' => $username, '_password' => 'mypassword', - ); + ]; $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.'); + } }