diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-06-01 21:27:35 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-06-22 17:59:35 +0200 |
commit | 23634d5d842dabcf5d7475e2becb7e127824239e (patch) | |
tree | b91688722a996c46f27e8fe0542c356424483da3 /src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php | |
parent | 891a026e31ad54ca90b70f6026f23260cfadb7fd (diff) | |
download | wallabag-23634d5d842dabcf5d7475e2becb7e127824239e.tar.gz wallabag-23634d5d842dabcf5d7475e2becb7e127824239e.tar.zst wallabag-23634d5d842dabcf5d7475e2becb7e127824239e.zip |
Jump to Symfony 3.1
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php b/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php deleted file mode 100644 index 05450c0b..00000000 --- a/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Tests; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
6 | |||
7 | abstract class WallabagCoreTestCase extends WebTestCase | ||
8 | { | ||
9 | private $client = null; | ||
10 | |||
11 | public function getClient() | ||
12 | { | ||
13 | return $this->client; | ||
14 | } | ||
15 | |||
16 | public function setUp() | ||
17 | { | ||
18 | parent::setUp(); | ||
19 | |||
20 | $this->client = static::createClient(); | ||
21 | } | ||
22 | |||
23 | public function logInAs($username) | ||
24 | { | ||
25 | $crawler = $this->client->request('GET', '/login'); | ||
26 | $form = $crawler->filter('button[type=submit]')->form(); | ||
27 | $data = [ | ||
28 | '_username' => $username, | ||
29 | '_password' => 'mypassword', | ||
30 | ]; | ||
31 | |||
32 | $this->client->submit($form, $data); | ||
33 | } | ||
34 | |||
35 | /** | ||
36 | * Return the user id of the logged in user. | ||
37 | * You should be sure that you called `logInAs` before. | ||
38 | * | ||
39 | * @return int | ||
40 | */ | ||
41 | public function getLoggedInUserId() | ||
42 | { | ||
43 | $token = static::$kernel->getContainer()->get('security.token_storage')->getToken(); | ||
44 | |||
45 | if (null !== $token) { | ||
46 | return $token->getUser()->getId(); | ||
47 | } | ||
48 | |||
49 | throw new \RuntimeException('No logged in User.'); | ||
50 | } | ||
51 | } | ||