3 namespace Wallabag\CoreBundle\Tests
;
5 use Symfony\Bundle\FrameworkBundle\Test\WebTestCase
;
7 abstract class WallabagCoreTestCase
extends WebTestCase
9 private $client = null;
11 public function getClient()
16 public function setUp()
20 $this->client
= static::createClient();
23 public function logInAs($username)
25 $crawler = $this->client
->request('GET', '/login');
26 $form = $crawler->filter('button[type=submit]')->form();
28 '_username' => $username,
29 '_password' => 'mypassword',
32 $this->client
->submit($form, $data);
36 * Return the user id of the logged in user.
37 * You should be sure that you called `logInAs` before.
41 public function getLoggedInUserId()
43 $token = static::$kernel->getContainer()->get('security.token_storage')->getToken();
45 if (null !== $token) {
46 return $token->getUser()->getId();
49 throw new \
RuntimeException('No logged in User.');