From: Nicolas LÅ“uillet Date: Wed, 11 Feb 2015 06:43:43 +0000 (+0100) Subject: DELETE entry and use of query for fetch entries X-Git-Tag: 2.0.0-alpha.0~79^2~7 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=c9fa9677c1ae7b9be2305cef8f61fa2e0fc14d58;p=github%2Fwallabag%2Fwallabag.git DELETE entry and use of query for fetch entries --- diff --git a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php index 1240844b..c7704aa8 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php @@ -45,12 +45,21 @@ class WallabagRestControllerTest extends WebTestCase { $client = $this->createClient(); $client->request('GET', '/api/salts/admin.json'); - $content = json_decode($client->getResponse()->getContent()); + $salt = json_decode($client->getResponse()->getContent()); - $headers = $this->generateHeaders('admin', 'test', $content[0]); + $headers = $this->generateHeaders('admin', 'test', $salt[0]); - $client->request('GET', '/api/entries/1.json', array(), array(), $headers); - $this->assertContains('This is my content', $client->getResponse()->getContent()); + $entry = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneByIsArchived(false); + + if (!$entry) { + $this->markTestSkipped('No content found in db.'); + } + + $client->request('GET', '/api/entries/'.$entry->getId().'.json', array(), array(), $headers); + $this->assertContains($entry->getTitle(), $client->getResponse()->getContent()); $this->assertTrue( $client->getResponse()->headers->contains( @@ -64,9 +73,9 @@ class WallabagRestControllerTest extends WebTestCase { $client = $this->createClient(); $client->request('GET', '/api/salts/admin.json'); - $content = json_decode($client->getResponse()->getContent()); + $salt = json_decode($client->getResponse()->getContent()); - $headers = $this->generateHeaders('admin', 'test', $content[0]); + $headers = $this->generateHeaders('admin', 'test', $salt[0]); $client->request('GET', '/api/entries', array(), array(), $headers); $this->assertContains('Mailjet', $client->getResponse()->getContent()); @@ -78,4 +87,32 @@ class WallabagRestControllerTest extends WebTestCase ) ); } + + public function testDeleteEntry() + { + $client = $this->createClient(); + $client->request('GET', '/api/salts/admin.json'); + $salt = json_decode($client->getResponse()->getContent()); + + $headers = $this->generateHeaders('admin', 'test', $salt[0]); + + $entry = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneByIsDeleted(false); + + if (!$entry) { + $this->markTestSkipped('No content found in db.'); + } + + $client->request('DELETE', '/api/entries/'.$entry->getId().'.json', array(), array(), $headers); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + $res = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneById($entry->getId()); + $this->assertEquals($res->isDeleted(), true); + } }