aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CommentBundle/Tests/WallabagCommentTestCase.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CommentBundle/Tests/WallabagCommentTestCase.php')
-rw-r--r--src/Wallabag/CommentBundle/Tests/WallabagCommentTestCase.php63
1 files changed, 0 insertions, 63 deletions
diff --git a/src/Wallabag/CommentBundle/Tests/WallabagCommentTestCase.php b/src/Wallabag/CommentBundle/Tests/WallabagCommentTestCase.php
deleted file mode 100644
index f4a2ae6c..00000000
--- a/src/Wallabag/CommentBundle/Tests/WallabagCommentTestCase.php
+++ /dev/null
@@ -1,63 +0,0 @@
1<?php
2
3namespace Wallabag\CommentBundle\Tests;
4
5use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6use Symfony\Component\BrowserKit\Cookie;
7
8abstract class WallabagCommentTestCase extends WebTestCase
9{
10 /**
11 * @var Client
12 */
13 protected $client = null;
14
15 /**
16 * @var \FOS\UserBundle\Model\UserInterface
17 */
18 protected $user;
19
20 public function setUp()
21 {
22 $this->client = $this->createAuthorizedClient();
23 }
24
25 public function logInAs($username)
26 {
27 $crawler = $this->client->request('GET', '/login');
28 $form = $crawler->filter('button[type=submit]')->form();
29 $data = array(
30 '_username' => $username,
31 '_password' => 'mypassword',
32 );
33
34 $this->client->submit($form, $data);
35 }
36
37 /**
38 * @return Client
39 */
40 protected function createAuthorizedClient()
41 {
42 $client = static::createClient();
43 $container = $client->getContainer();
44
45 /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
46 $userManager = $container->get('fos_user.user_manager');
47 /** @var $loginManager \FOS\UserBundle\Security\LoginManager */
48 $loginManager = $container->get('fos_user.security.login_manager');
49 $firewallName = $container->getParameter('fos_user.firewall_name');
50
51 $this->user = $userManager->findUserBy(array('username' => 'admin'));
52 $loginManager->loginUser($firewallName, $this->user);
53
54 // save the login token into the session and put it in a cookie
55 $container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));
56 $container->get('session')->save();
57
58 $session = $container->get('session');
59 $client->getCookieJar()->set(new Cookie($session->getName(), $session->getId()));
60
61 return $client;
62 }
63}