From 5fe9aadc0e84bac277db7e6ab78b8731c2ba31fc Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 31 Mar 2017 14:54:34 +0200 Subject: Set progress --- .../Controller/EntryRestControllerTest.php | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/Wallabag/ApiBundle/Controller') diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 067aed2c..35a21afc 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php @@ -32,6 +32,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertEquals($entry->getUserName(), $content['user_name']); $this->assertEquals($entry->getUserEmail(), $content['user_email']); $this->assertEquals($entry->getUserId(), $content['user_id']); + $this->assertEquals($entry->getProgress(), $content['progress']); $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); } @@ -417,6 +418,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertContains('bob', $content['published_by']); $this->assertContains('helen', $content['published_by']); $this->assertTrue($content['is_public'], 'A public link has been generated for that entry'); + $this->assertEquals(0, $content['progress']); } public function testPostSameEntry() @@ -532,6 +534,7 @@ class EntryRestControllerTest extends WallabagApiTestCase 'authors' => 'bob,sponge', 'content' => 'awesome', 'public' => 0, + 'progress' => '70', ]); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); @@ -549,6 +552,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertContains('bob', $content['published_by']); $this->assertEquals('awesome', $content['content']); $this->assertFalse($content['is_public'], 'Entry is no more shared'); + $this->assertEquals(70, $content['progress']); } public function testPatchEntryWithoutQuotes() @@ -759,6 +763,28 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertEquals(true, $content['is_starred']); } + public function testChangeProgress() + { + $entry = $this->client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneByUser(1); + + if (!$entry) { + $this->markTestSkipped('No content found in db.'); + } + + $this->client->request('PATCH', '/api/entries/'.$entry->getId().'json', [ + 'progress' => 69, + ]); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertEquals(69, $content['progress']); + } + public function testGetEntriesExists() { $this->client->request('GET', '/api/entries/exists?url=http://0.0.0.0/entry2'); -- cgit v1.2.3