From fe6461e4aaff5aa2fd846492e3abd9ea38c07a5b Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Tue, 30 May 2017 09:57:57 +0200 Subject: [PATCH] Avoid side effect on other tests --- .../Controller/UserRestControllerTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php index 21d59a16..3f4969a5 100644 --- a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php @@ -49,12 +49,24 @@ class UserRestControllerTest extends WallabagApiTestCase $this->assertEquals('google', $content['username']); $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); + + // remove the created user to avoid side effect on other tests + // @todo remove these lines when test will be isolated + $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); + + $query = $em->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\Config c WHERE c.user = :user_id'); + $query->setParameter('user_id', $content['id']); + $query->execute(); + + $query = $em->createQuery('DELETE FROM Wallabag\UserBundle\Entity\User u WHERE u.id = :id'); + $query->setParameter('id', $content['id']); + $query->execute(); } public function testCreateNewUserWithExistingEmail() { $this->client->request('PUT', '/api/user.json', [ - 'username' => 'google', + 'username' => 'admin', 'password' => 'googlegoogle', 'email' => 'bigboss@wallabag.org', ]); -- 2.41.0