X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2FWallabag%2FApiBundle%2FTests%2FController%2FWallabagRestControllerTest.php;h=a705f9dea4f00fdac5c84194f900cdc219151521;hb=d442cf4a92118a96926865447560b89e129d73dd;hp=bdd36e0c6b3fb20063480f87b17b24ea2ed6afd3;hpb=f1eccfd63f214dcc730ab0d18a694a5465f425db;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php index bdd36e0c..a705f9de 100644 --- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php @@ -162,6 +162,24 @@ class WallabagRestControllerTest extends WallabagApiTestCase $this->assertCount(1, $content['tags']); } + public function testPostArchivedEntry() + { + $this->client->request('POST', '/api/entries.json', array( + 'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', + 'archive' => true, + 'starred' => false, + )); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertGreaterThan(0, $content['id']); + $this->assertEquals('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']); + $this->assertEquals(true, $content['is_archived']); + $this->assertEquals(false, $content['is_starred']); + } + public function testPatchEntry() { $entry = $this->client->getContainer() @@ -208,7 +226,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase $tags = array(); foreach ($entry->getTags() as $tag) { - $tags[] = array('id' => $tag->getId(), 'label' => $tag->getLabel()); + $tags[] = array('id' => $tag->getId(), 'label' => $tag->getLabel(), 'slug' => $tag->getSlug()); } $this->client->request('GET', '/api/entries/'.$entry->getId().'/tags'); @@ -309,5 +327,24 @@ class WallabagRestControllerTest extends WallabagApiTestCase $this->assertArrayHasKey('label', $content); $this->assertEquals($tag['label'], $content['label']); + $this->assertEquals($tag['slug'], $content['slug']); + + $entries = $entry = $this->client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findAllByTagId($this->user->getId(), $tag['id']); + + $this->assertCount(0, $entries); + } + + public function testGetVersion() + { + $this->client->request('GET', '/api/version'); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertEquals($this->client->getContainer()->getParameter('wallabag_core.version'), $content); } }