From 1eca7831a69b9470b92dcc72e1ce51b42b291338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 24 Apr 2017 10:22:57 +0200 Subject: Added API endpoint to handle a list of URL By passing an array, you can add / delete URL in mass (bulk request) --- .../Controller/EntryRestControllerTest.php | 46 ++++++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'tests/Wallabag/ApiBundle/Controller') diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 19fb5170..c37d08cb 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php @@ -766,20 +766,50 @@ class EntryRestControllerTest extends WallabagApiTestCase ], ]; - $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list)); + $this->client->request('DELETE', '/api/entries/tags/list?list=' . json_encode($list)); + } + + public function testPostMassEntriesAction() + { + $list = [ + [ + 'url' => 'http://0.0.0.0/entry2', + 'action' => 'delete', + ], + [ + 'url' => 'http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', + 'action' => 'add', + ], + [ + 'url' => 'http://0.0.0.0/entry3', + 'action' => 'delete', + ], + [ + 'url' => 'http://0.0.0.0/entry6', + 'action' => 'add', + ], + ]; + + $this->client->request('POST', '/api/entries/lists?list='.json_encode($list)); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); - $this->assertInternalType('int', $content[0]['entry']); - $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']); + $this->assertTrue($content[0]['entry']); + $this->assertEquals('http://0.0.0.0/entry2', $content[0]['url']); + $this->assertEquals('delete', $content[0]['action']); - $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') - ->getRepository('WallabagCoreBundle:Entry') - ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); + $this->assertInternalType('int', $content[1]['entry']); + $this->assertEquals('http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', $content[1]['url']); + $this->assertEquals('add', $content[1]['action']); - $tags = $entry->getTags(); - $this->assertCount(2, $tags); + $this->assertFalse($content[2]['entry']); + $this->assertEquals('http://0.0.0.0/entry3', $content[2]['url']); + $this->assertEquals('delete', $content[2]['action']); + + $this->assertInternalType('int', $content[3]['entry']); + $this->assertEquals('http://0.0.0.0/entry6', $content[3]['url']); + $this->assertEquals('add', $content[3]['action']); } } -- cgit v1.2.3