Fix findOneByUrl side effect in tests

Fix #1566
This commit is contained in:
Jeremy Benoist
2016-01-15 15:28:22 +01:00
parent 790573d458
commit 7883367246
8 changed files with 33 additions and 18 deletions

View File

@ -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.');
}
}