$this->client->request('POST', '/api/entries.json', [
'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html',
'tags' => 'google',
+ 'title' => 'New title for my article',
]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
$this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']);
$this->assertEquals(false, $content['is_archived']);
$this->assertEquals(false, $content['is_starred']);
+ $this->assertEquals('New title for my article', $content['title']);
$this->assertEquals(1, $content['user_id']);
$this->assertCount(1, $content['tags']);
}
$this->assertEquals($this->client->getContainer()->getParameter('wallabag_core.version'), $content);
}
+
+ public function testSaveIsArchivedAfterPost()
+ {
+ $entry = $this->client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneBy(['user' => 1, 'isArchived' => true]);
+
+ if (!$entry) {
+ $this->markTestSkipped('No content found in db.');
+ }
+
+ $this->client->request('POST', '/api/entries.json', [
+ 'url' => $entry->getUrl(),
+ ]);
+
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertEquals(true, $content['is_archived']);
+ }
+
+ public function testSaveIsStarredAfterPost()
+ {
+ $entry = $this->client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneBy(['user' => 1, 'isStarred' => true]);
+
+ if (!$entry) {
+ $this->markTestSkipped('No content found in db.');
+ }
+
+ $this->client->request('POST', '/api/entries.json', [
+ 'url' => $entry->getUrl(),
+ ]);
+
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertEquals(true, $content['is_starred']);
+ }
+
+ public function testSaveIsArchivedAfterPatch()
+ {
+ $entry = $this->client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneBy(['user' => 1, 'isArchived' => true]);
+
+ if (!$entry) {
+ $this->markTestSkipped('No content found in db.');
+ }
+
+ $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
+ 'title' => $entry->getTitle().'++',
+ ]);
+
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertEquals(true, $content['is_archived']);
+ }
+
+ public function testSaveIsStarredAfterPatch()
+ {
+ $entry = $this->client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneBy(['user' => 1, 'isStarred' => true]);
+
+ if (!$entry) {
+ $this->markTestSkipped('No content found in db.');
+ }
+ $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
+ 'title' => $entry->getTitle().'++',
+ ]);
+
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertEquals(true, $content['is_starred']);
+ }
}