aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index ed104df3..8f0effee 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -440,6 +440,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
440 $this->assertSame('New title for my article', $content['title']); 440 $this->assertSame('New title for my article', $content['title']);
441 $this->assertSame(1, $content['user_id']); 441 $this->assertSame(1, $content['user_id']);
442 $this->assertCount(2, $content['tags']); 442 $this->assertCount(2, $content['tags']);
443 $this->assertNull($content['origin_url']);
443 $this->assertSame('my content', $content['content']); 444 $this->assertSame('my content', $content['content']);
444 $this->assertSame('de', $content['language']); 445 $this->assertSame('de', $content['language']);
445 $this->assertSame('2016-09-08T11:55:58+0200', $content['published_at']); 446 $this->assertSame('2016-09-08T11:55:58+0200', $content['published_at']);
@@ -680,6 +681,60 @@ class EntryRestControllerTest extends WallabagApiTestCase
680 $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved'); 681 $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved');
681 } 682 }
682 683
684 public function testPatchEntryRemoveOriginUrl()
685 {
686 $entry = $this->client->getContainer()
687 ->get('doctrine.orm.entity_manager')
688 ->getRepository('WallabagCoreBundle:Entry')
689 ->findOneByUser(1);
690
691 if (!$entry) {
692 $this->markTestSkipped('No content found in db.');
693 }
694
695 $previousContent = $entry->getContent();
696 $previousLanguage = $entry->getLanguage();
697 $previousTitle = $entry->getTitle();
698
699 $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
700 'origin_url' => '',
701 ]);
702
703 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
704
705 $content = json_decode($this->client->getResponse()->getContent(), true);
706
707 $this->assertSame($entry->getId(), $content['id']);
708 $this->assertSame($entry->getUrl(), $content['url']);
709 $this->assertEmpty($content['origin_url']);
710 $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string');
711 $this->assertSame($previousContent, $content['content'], 'Ensure content has not moved');
712 $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved');
713 $this->assertSame($previousTitle, $content['title'], 'Ensure title has not moved');
714 }
715
716 public function testPatchEntryNullOriginUrl()
717 {
718 $entry = $this->client->getContainer()
719 ->get('doctrine.orm.entity_manager')
720 ->getRepository('WallabagCoreBundle:Entry')
721 ->findOneByUser(1);
722
723 if (!$entry) {
724 $this->markTestSkipped('No content found in db.');
725 }
726
727 $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
728 'origin_url' => null,
729 ]);
730
731 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
732
733 $content = json_decode($this->client->getResponse()->getContent(), true);
734
735 $this->assertNull($content['origin_url']);
736 }
737
683 public function testGetTagsEntry() 738 public function testGetTagsEntry()
684 { 739 {
685 $entry = $this->client->getContainer() 740 $entry = $this->client->getContainer()