]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Avoid side effect on other tests 3065/head
authorJeremy Benoist <jeremy.benoist@gmail.com>
Tue, 30 May 2017 07:57:57 +0000 (09:57 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Tue, 30 May 2017 07:57:57 +0000 (09:57 +0200)
tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php

index 21d59a169795603becf6ea3d5a193d026771f1d0..3f4969a534bd7e6f4b2bb3701251a273e2b6301c 100644 (file)
@@ -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',
         ]);