]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
Merge remote-tracking branch 'origin/master' into 2.4
[github/wallabag/wallabag.git] / tests / Wallabag / ApiBundle / Controller / EntryRestControllerTest.php
index 34de8ec8caa954e317f15fe2550ed6512cd507db..8b7898eea744795543f8b0f47e3d24d5da3921d2 100644 (file)
@@ -133,6 +133,27 @@ class EntryRestControllerTest extends WallabagApiTestCase
         $this->assertSame(1, $content['page']);
         $this->assertGreaterThanOrEqual(1, $content['pages']);
 
+        $this->assertNotNull($content['_embedded']['items'][0]['content']);
+
+        $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+    }
+
+    public function testGetEntriesDetailMetadata()
+    {
+        $this->client->request('GET', '/api/entries?detail=metadata');
+
+        $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+
+        $content = json_decode($this->client->getResponse()->getContent(), true);
+
+        $this->assertGreaterThanOrEqual(1, \count($content));
+        $this->assertNotEmpty($content['_embedded']['items']);
+        $this->assertGreaterThanOrEqual(1, $content['total']);
+        $this->assertSame(1, $content['page']);
+        $this->assertGreaterThanOrEqual(1, $content['pages']);
+
+        $this->assertNull($content['_embedded']['items'][0]['content']);
+
         $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
     }
 
@@ -1076,6 +1097,17 @@ class EntryRestControllerTest extends WallabagApiTestCase
     }
 
     public function testGetEntriesExistsWhichDoesNotExists()
+    {
+        $this->client->request('GET', '/api/entries/exists?url=http://google.com/entry2');
+
+        $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+
+        $content = json_decode($this->client->getResponse()->getContent(), true);
+
+        $this->assertFalse($content['exists']);
+    }
+
+    public function testGetEntriesExistsWhichDoesNotExistsWithHashedUrl()
     {
         $this->client->request('GET', '/api/entries/exists?hashed_url=' . hash('sha1', 'http://google.com/entry2'));
 
@@ -1087,6 +1119,13 @@ class EntryRestControllerTest extends WallabagApiTestCase
     }
 
     public function testGetEntriesExistsWithNoUrl()
+    {
+        $this->client->request('GET', '/api/entries/exists?url=');
+
+        $this->assertSame(403, $this->client->getResponse()->getStatusCode());
+    }
+
+    public function testGetEntriesExistsWithNoHashedUrl()
     {
         $this->client->request('GET', '/api/entries/exists?hashed_url=');