]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
Set progress
[github/wallabag/wallabag.git] / tests / Wallabag / ApiBundle / Controller / EntryRestControllerTest.php
index 067aed2c8dd97bffc6300c9b17ea9f5b75ced15c..35a21afc3cbe45f588d6ee07920448e565770824 100644 (file)
@@ -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');