diff options
author | Kevin Decherf <kevin@kdecherf.com> | 2017-11-19 15:01:06 +0100 |
---|---|---|
committer | Kevin Decherf <kevin@kdecherf.com> | 2017-11-19 15:02:11 +0100 |
commit | 65152fcb899e1d073847718e2f7847180fa26a40 (patch) | |
tree | e6914c556fa1470b9a4f3a1559e447a51e8c15eb /tests | |
parent | 97444566db31c287103468ee64e2b234d223a354 (diff) | |
download | wallabag-65152fcb899e1d073847718e2f7847180fa26a40.tar.gz wallabag-65152fcb899e1d073847718e2f7847180fa26a40.tar.zst wallabag-65152fcb899e1d073847718e2f7847180fa26a40.zip |
Improve EntryRestControllerTest for origin_url
Ensure that origin_url is initially null
Ensure patching entry with origin_url=''
Ensure patching entry with origin_url=null
Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 55 |
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() |