+ $this->assertSame($entry->getId(), $content['id']);
+ $this->assertSame($entry->getUrl(), $content['url']);
+ $this->assertGreaterThanOrEqual(1, \count($content['tags']), 'We force only one tag');
+ $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string');
+ $this->assertSame($previousContent, $content['content'], 'Ensure content has not moved');
+ $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved');
+ }
+
+ public function testPatchEntryWithOriginUrl()
+ {
+ $entry = $this->client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneByUser(1);
+
+ if (!$entry) {
+ $this->markTestSkipped('No content found in db.');
+ }
+
+ $previousContent = $entry->getContent();
+ $previousLanguage = $entry->getLanguage();
+
+ $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
+ 'title' => 'Another awesome title just for profit',
+ 'origin_url' => 'https://myawesomesource.example.com',
+ ]);
+
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertSame($entry->getId(), $content['id']);
+ $this->assertSame($entry->getUrl(), $content['url']);
+ $this->assertSame('https://myawesomesource.example.com', $content['origin_url']);
+ $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string');
+ $this->assertSame($previousContent, $content['content'], 'Ensure content has not moved');
+ $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved');
+ }
+
+ public function testPatchEntryRemoveOriginUrl()
+ {
+ $entry = $this->client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneByUser(1);
+
+ if (!$entry) {
+ $this->markTestSkipped('No content found in db.');
+ }
+
+ $previousContent = $entry->getContent();
+ $previousLanguage = $entry->getLanguage();
+ $previousTitle = $entry->getTitle();
+
+ $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
+ 'origin_url' => '',
+ ]);
+
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertSame($entry->getId(), $content['id']);
+ $this->assertSame($entry->getUrl(), $content['url']);
+ $this->assertEmpty($content['origin_url']);
+ $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string');
+ $this->assertSame($previousContent, $content['content'], 'Ensure content has not moved');
+ $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved');
+ $this->assertSame($previousTitle, $content['title'], 'Ensure title has not moved');
+ }
+
+ public function testPatchEntryNullOriginUrl()
+ {
+ $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', [
+ 'origin_url' => null,
+ ]);
+
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertNull($content['origin_url']);