aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-06-01 21:27:35 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-06-22 17:59:35 +0200
commit23634d5d842dabcf5d7475e2becb7e127824239e (patch)
treeb91688722a996c46f27e8fe0542c356424483da3 /src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php
parent891a026e31ad54ca90b70f6026f23260cfadb7fd (diff)
downloadwallabag-23634d5d842dabcf5d7475e2becb7e127824239e.tar.gz
wallabag-23634d5d842dabcf5d7475e2becb7e127824239e.tar.zst
wallabag-23634d5d842dabcf5d7475e2becb7e127824239e.zip
Jump to Symfony 3.1
Diffstat (limited to 'src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php')
-rw-r--r--src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php51
1 files changed, 0 insertions, 51 deletions
diff --git a/src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php b/src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php
deleted file mode 100644
index 13d72d2c..00000000
--- a/src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php
+++ /dev/null
@@ -1,51 +0,0 @@
1<?php
2
3namespace Wallabag\ApiBundle\Tests;
4
5use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6use Symfony\Component\BrowserKit\Cookie;
7
8abstract class WallabagApiTestCase 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 /**
26 * @return Client
27 */
28 protected function createAuthorizedClient()
29 {
30 $client = static::createClient();
31 $container = $client->getContainer();
32
33 /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
34 $userManager = $container->get('fos_user.user_manager');
35 /** @var $loginManager \FOS\UserBundle\Security\LoginManager */
36 $loginManager = $container->get('fos_user.security.login_manager');
37 $firewallName = $container->getParameter('fos_user.firewall_name');
38
39 $this->user = $userManager->findUserBy(['username' => 'admin']);
40 $loginManager->loginUser($firewallName, $this->user);
41
42 // save the login token into the session and put it in a cookie
43 $container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));
44 $container->get('session')->save();
45
46 $session = $container->get('session');
47 $client->getCookieJar()->set(new Cookie($session->getName(), $session->getId()));
48
49 return $client;
50 }
51}