]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - tests/Wallabag/ApiBundle/WallabagApiTestCase.php
Fix tests
[github/wallabag/wallabag.git] / tests / Wallabag / ApiBundle / WallabagApiTestCase.php
index 0c52aea06addf2deae3e94a45c0bd0b34530b87a..a0f2f889513e6f58a481ce01935db65ed11d2118 100644 (file)
@@ -48,4 +48,23 @@ abstract class WallabagApiTestCase extends WebTestCase
 
         return $client;
     }
+
+    /**
+     * Return the ID for the user admin.
+     * Used because on heavy testing we don't want to re-create the database on each run.
+     * Which means "admin" user won't have id 1 all the time.
+     *
+     * @param  string $username
+     *
+     * @return int
+     */
+    public function getUserId($username = 'admin')
+    {
+        return $this->client
+            ->getContainer()
+            ->get('doctrine.orm.entity_manager')
+            ->getRepository('WallabagUserBundle:User')
+            ->findOneByUserName($username)
+            ->getId();
+    }
 }