From 8f2038e5b15c2d7342ed18381531e5eb95e86d46 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 26 Nov 2018 22:22:49 +0100 Subject: Fix tests --- tests/Wallabag/ApiBundle/WallabagApiTestCase.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/Wallabag/ApiBundle/WallabagApiTestCase.php') 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(); + } } -- cgit v1.2.3 From b13b2ef052f3c21f17ab2a4f3f410049e3c79c83 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 26 Nov 2018 22:46:44 +0100 Subject: CS --- tests/Wallabag/ApiBundle/WallabagApiTestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/Wallabag/ApiBundle/WallabagApiTestCase.php') diff --git a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php index a0f2f889..fd2e113e 100644 --- a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php +++ b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php @@ -54,11 +54,11 @@ abstract class WallabagApiTestCase extends WebTestCase * 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 + * @param string $username * * @return int */ - public function getUserId($username = 'admin') + protected function getUserId($username = 'admin') { return $this->client ->getContainer() -- cgit v1.2.3