aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ApiBundle/WallabagApiTestCase.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/ApiBundle/WallabagApiTestCase.php')
-rw-r--r--tests/Wallabag/ApiBundle/WallabagApiTestCase.php23
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php
index 8a188e1c..fd2e113e 100644
--- a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php
+++ b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php
@@ -31,9 +31,9 @@ abstract class WallabagApiTestCase extends WebTestCase
31 $container = $client->getContainer(); 31 $container = $client->getContainer();
32 32
33 /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */ 33 /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
34 $userManager = $container->get('fos_user.user_manager'); 34 $userManager = $container->get('fos_user.user_manager.test');
35 /** @var $loginManager \FOS\UserBundle\Security\LoginManager */ 35 /** @var $loginManager \FOS\UserBundle\Security\LoginManager */
36 $loginManager = $container->get('fos_user.security.login_manager'); 36 $loginManager = $container->get('fos_user.security.login_manager.test');
37 $firewallName = $container->getParameter('fos_user.firewall_name'); 37 $firewallName = $container->getParameter('fos_user.firewall_name');
38 38
39 $this->user = $userManager->findUserBy(['username' => 'admin']); 39 $this->user = $userManager->findUserBy(['username' => 'admin']);
@@ -48,4 +48,23 @@ abstract class WallabagApiTestCase extends WebTestCase
48 48
49 return $client; 49 return $client;
50 } 50 }
51
52 /**
53 * Return the ID for the user admin.
54 * Used because on heavy testing we don't want to re-create the database on each run.
55 * Which means "admin" user won't have id 1 all the time.
56 *
57 * @param string $username
58 *
59 * @return int
60 */
61 protected function getUserId($username = 'admin')
62 {
63 return $this->client
64 ->getContainer()
65 ->get('doctrine.orm.entity_manager')
66 ->getRepository('WallabagUserBundle:User')
67 ->findOneByUserName($username)
68 ->getId();
69 }
51} 70}