]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Remove the created entry to avoid side effects on other tests 3095/head
authoradev <adev2000@gmail.com>
Tue, 9 May 2017 21:19:24 +0000 (23:19 +0200)
committeradev <adev2000@gmail.com>
Tue, 9 May 2017 21:19:24 +0000 (23:19 +0200)
tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php

index 0979ca93c3c2a6d24c9ec4e27e166866ab3c9b8c..deafd1fab70513dfad35c06a2ca8819897431646 100644 (file)
@@ -373,14 +373,24 @@ class EntryRestControllerTest extends WallabagApiTestCase
             ->willThrowException(new \Exception('Test Fetch content fails'));
         $container->set('wallabag_core.content_proxy', $contentProxy);
 
-        $this->client->request('POST', '/api/entries.json', [
-            'url' => 'http://www.example.com/',
-        ]);
-
-        $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
-        $content = json_decode($this->client->getResponse()->getContent(), true);
-        $this->assertGreaterThan(0, $content['id']);
-        $this->assertEquals('http://www.example.com/', $content['url']);
+        try {
+            $this->client->request('POST', '/api/entries.json', [
+                'url' => 'http://www.example.com/',
+            ]);
+
+            $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+            $content = json_decode($this->client->getResponse()->getContent(), true);
+            $this->assertGreaterThan(0, $content['id']);
+            $this->assertEquals('http://www.example.com/', $content['url']);
+        } finally {
+            // Remove the created entry to avoid side effects on other tests
+            if (isset($content['id'])) {
+                $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
+                $entry = $em->getReference('WallabagCoreBundle:Entry', $content['id']);
+                $em->remove($entry);
+                $em->flush();
+            }
+        }
     }
 
     public function testPostArchivedAndStarredEntry()