From 0d3043a29c4aba541d6a18c2d5cc7ebffc6ddc78 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 15 Mar 2016 18:50:13 +0100 Subject: fix api properties and typo --- .../ApiBundle/Tests/Controller/WallabagRestControllerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/ApiBundle/Tests/Controller') diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php index 2e78d8b2..f5a9748c 100644 --- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php @@ -188,8 +188,8 @@ class WallabagRestControllerTest extends WallabagApiTestCase { $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' => true, + 'archive' => 'true', + 'starred' => 'true', )); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); -- cgit v1.2.3 From 189ef6342a3f9befec379c406821ed10730cacd2 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 16 Mar 2016 20:41:29 +0100 Subject: use integers for archived/starred status --- .../ApiBundle/Tests/Controller/WallabagRestControllerTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Wallabag/ApiBundle/Tests/Controller') diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php index f5a9748c..6bc7afa6 100644 --- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php @@ -188,8 +188,8 @@ class WallabagRestControllerTest extends WallabagApiTestCase { $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' => 'true', + 'archive' => '1', + 'starred' => '1', )); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); @@ -220,8 +220,8 @@ class WallabagRestControllerTest extends WallabagApiTestCase $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', array( 'title' => 'New awesome title', 'tags' => 'new tag '.uniqid(), - 'star' => true, - 'archive' => false, + 'starred' => '1', + 'archive' => '0', )); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); -- cgit v1.2.3 From 2f60e5ea7566e4b2904f274bc94efea390d9ecd8 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 16 Mar 2016 21:38:50 +0100 Subject: check if archive/star parameters without quotes work --- .../Controller/WallabagRestControllerTest.php | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/Wallabag/ApiBundle/Tests/Controller') diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php index 6bc7afa6..ccb72d23 100644 --- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php @@ -203,6 +203,24 @@ class WallabagRestControllerTest extends WallabagApiTestCase $this->assertEquals(1, $content['user_id']); } + public function testPostArchivedAndStarredEntryWithoutQuotes() + { + $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' => 0, + 'starred' => 1, + )); + + $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(false, $content['is_archived']); + $this->assertEquals(true, $content['is_starred']); + } + public function testPatchEntry() { $entry = $this->client->getContainer() @@ -235,6 +253,37 @@ class WallabagRestControllerTest extends WallabagApiTestCase $this->assertEquals(1, $content['user_id']); } + public function testPatchEntryWithoutQuotes() + { + $entry = $this->client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneByUser(1); + + if (!$entry) { + $this->markTestSkipped('No content found in db.'); + } + + // hydrate the tags relations + $nbTags = count($entry->getTags()); + + $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', array( + 'title' => 'New awesome title', + 'tags' => 'new tag '.uniqid(), + 'starred' => 1, + 'archive' => 0, + )); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertEquals($entry->getId(), $content['id']); + $this->assertEquals($entry->getUrl(), $content['url']); + $this->assertEquals('New awesome title', $content['title']); + $this->assertGreaterThan($nbTags, count($content['tags'])); + } + public function testGetTagsEntry() { $entry = $this->client->getContainer() -- cgit v1.2.3