From: Jeremy Benoist Date: Tue, 30 May 2017 07:57:57 +0000 (+0200) Subject: Avoid side effect on other tests X-Git-Tag: 2.3.0~31^2~84^2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=fe6461e4aaff5aa2fd846492e3abd9ea38c07a5b;p=github%2Fwallabag%2Fwallabag.git Avoid side effect on other tests --- 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', ]);