X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FApiBundle%2FWallabagApiTestCase.php;h=a0f2f889513e6f58a481ce01935db65ed11d2118;hb=8f2038e5b15c2d7342ed18381531e5eb95e86d46;hp=0c52aea06addf2deae3e94a45c0bd0b34530b87a;hpb=1b6b77f02956a767fb3fa9825a7b97b4879f7d42;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php index 0c52aea0..a0f2f889 100644 --- a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php +++ b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php @@ -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(); + } }