aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/AnnotationBundle/Tests/WallabagAnnotationTestCase.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-02-26 18:17:37 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-02-26 18:17:37 +0100
commit162954763e6f68e0cf4002822007683bde62fc25 (patch)
treea85f850eddb30b3435d1bb5f45d16d9ab465bbf9 /src/Wallabag/AnnotationBundle/Tests/WallabagAnnotationTestCase.php
parentd3f1a9dc1ac181033ec54f9149d2807199fa8f17 (diff)
parentb07c7dfe787313b75e0996265e13cccc78da41be (diff)
downloadwallabag-162954763e6f68e0cf4002822007683bde62fc25.tar.gz
wallabag-162954763e6f68e0cf4002822007683bde62fc25.tar.zst
wallabag-162954763e6f68e0cf4002822007683bde62fc25.zip
Merge pull request #1653 from wallabag/v2-annotator-comments
V2 annotator comments
Diffstat (limited to 'src/Wallabag/AnnotationBundle/Tests/WallabagAnnotationTestCase.php')
-rw-r--r--src/Wallabag/AnnotationBundle/Tests/WallabagAnnotationTestCase.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/Wallabag/AnnotationBundle/Tests/WallabagAnnotationTestCase.php b/src/Wallabag/AnnotationBundle/Tests/WallabagAnnotationTestCase.php
new file mode 100644
index 00000000..2deff6bf
--- /dev/null
+++ b/src/Wallabag/AnnotationBundle/Tests/WallabagAnnotationTestCase.php
@@ -0,0 +1,63 @@
1<?php
2
3namespace Wallabag\AnnotationBundle\Tests;
4
5use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6use Symfony\Component\BrowserKit\Cookie;
7
8abstract class WallabagAnnotationTestCase 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}