diff options
Diffstat (limited to 'tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 63 |
1 files changed, 55 insertions, 8 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index ae4af4cd..c76be13d 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -519,9 +519,6 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
519 | $this->markTestSkipped('No content found in db.'); | 519 | $this->markTestSkipped('No content found in db.'); |
520 | } | 520 | } |
521 | 521 | ||
522 | // hydrate the tags relations | ||
523 | $nbTags = count($entry->getTags()); | ||
524 | |||
525 | $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [ | 522 | $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [ |
526 | 'title' => 'New awesome title', | 523 | 'title' => 'New awesome title', |
527 | 'tags' => 'new tag ' . uniqid(), | 524 | 'tags' => 'new tag ' . uniqid(), |
@@ -532,6 +529,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
532 | 'authors' => 'bob,sponge', | 529 | 'authors' => 'bob,sponge', |
533 | 'content' => 'awesome', | 530 | 'content' => 'awesome', |
534 | 'public' => 0, | 531 | 'public' => 0, |
532 | 'published_at' => 1488833381, | ||
535 | ]); | 533 | ]); |
536 | 534 | ||
537 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | 535 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); |
@@ -541,7 +539,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
541 | $this->assertSame($entry->getId(), $content['id']); | 539 | $this->assertSame($entry->getId(), $content['id']); |
542 | $this->assertSame($entry->getUrl(), $content['url']); | 540 | $this->assertSame($entry->getUrl(), $content['url']); |
543 | $this->assertSame('New awesome title', $content['title']); | 541 | $this->assertSame('New awesome title', $content['title']); |
544 | $this->assertGreaterThan($nbTags, count($content['tags'])); | 542 | $this->assertGreaterThanOrEqual(1, count($content['tags']), 'We force only one tag'); |
545 | $this->assertSame(1, $content['user_id']); | 543 | $this->assertSame(1, $content['user_id']); |
546 | $this->assertSame('de_AT', $content['language']); | 544 | $this->assertSame('de_AT', $content['language']); |
547 | $this->assertSame('http://preview.io/picture.jpg', $content['preview_picture']); | 545 | $this->assertSame('http://preview.io/picture.jpg', $content['preview_picture']); |
@@ -549,6 +547,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
549 | $this->assertContains('bob', $content['published_by']); | 547 | $this->assertContains('bob', $content['published_by']); |
550 | $this->assertSame('awesome', $content['content']); | 548 | $this->assertSame('awesome', $content['content']); |
551 | $this->assertFalse($content['is_public'], 'Entry is no more shared'); | 549 | $this->assertFalse($content['is_public'], 'Entry is no more shared'); |
550 | $this->assertContains('2017-03-06', $content['published_at']); | ||
552 | } | 551 | } |
553 | 552 | ||
554 | public function testPatchEntryWithoutQuotes() | 553 | public function testPatchEntryWithoutQuotes() |
@@ -562,8 +561,8 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
562 | $this->markTestSkipped('No content found in db.'); | 561 | $this->markTestSkipped('No content found in db.'); |
563 | } | 562 | } |
564 | 563 | ||
565 | // hydrate the tags relations | 564 | $previousContent = $entry->getContent(); |
566 | $nbTags = count($entry->getTags()); | 565 | $previousLanguage = $entry->getLanguage(); |
567 | 566 | ||
568 | $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [ | 567 | $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [ |
569 | 'title' => 'New awesome title', | 568 | 'title' => 'New awesome title', |
@@ -579,9 +578,10 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
579 | 578 | ||
580 | $this->assertSame($entry->getId(), $content['id']); | 579 | $this->assertSame($entry->getId(), $content['id']); |
581 | $this->assertSame($entry->getUrl(), $content['url']); | 580 | $this->assertSame($entry->getUrl(), $content['url']); |
582 | $this->assertSame('New awesome title', $content['title']); | 581 | $this->assertGreaterThanOrEqual(1, count($content['tags']), 'We force only one tag'); |
583 | $this->assertGreaterThan($nbTags, count($content['tags'])); | ||
584 | $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string'); | 582 | $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string'); |
583 | $this->assertSame($previousContent, $content['content'], 'Ensure content has not moved'); | ||
584 | $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved'); | ||
585 | } | 585 | } |
586 | 586 | ||
587 | public function testGetTagsEntry() | 587 | public function testGetTagsEntry() |
@@ -727,6 +727,8 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
727 | $this->markTestSkipped('No content found in db.'); | 727 | $this->markTestSkipped('No content found in db.'); |
728 | } | 728 | } |
729 | 729 | ||
730 | $previousTitle = $entry->getTitle(); | ||
731 | |||
730 | $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [ | 732 | $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [ |
731 | 'title' => $entry->getTitle() . '++', | 733 | 'title' => $entry->getTitle() . '++', |
732 | ]); | 734 | ]); |
@@ -736,6 +738,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
736 | $content = json_decode($this->client->getResponse()->getContent(), true); | 738 | $content = json_decode($this->client->getResponse()->getContent(), true); |
737 | 739 | ||
738 | $this->assertSame(1, $content['is_archived']); | 740 | $this->assertSame(1, $content['is_archived']); |
741 | $this->assertSame($previousTitle . '++', $content['title']); | ||
739 | } | 742 | } |
740 | 743 | ||
741 | public function testSaveIsStarredAfterPatch() | 744 | public function testSaveIsStarredAfterPatch() |
@@ -907,6 +910,17 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
907 | $this->assertCount(4, $tags); | 910 | $this->assertCount(4, $tags); |
908 | } | 911 | } |
909 | 912 | ||
913 | public function testPostEntriesTagsListActionNoList() | ||
914 | { | ||
915 | $this->client->request('POST', '/api/entries/tags/lists?list=' . json_encode([])); | ||
916 | |||
917 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | ||
918 | |||
919 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
920 | |||
921 | $this->assertEmpty($content); | ||
922 | } | ||
923 | |||
910 | public function testDeleteEntriesTagsListAction() | 924 | public function testDeleteEntriesTagsListAction() |
911 | { | 925 | { |
912 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | 926 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); |
@@ -933,6 +947,17 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
933 | $this->assertCount(0, $entry->getTags()); | 947 | $this->assertCount(0, $entry->getTags()); |
934 | } | 948 | } |
935 | 949 | ||
950 | public function testDeleteEntriesTagsListActionNoList() | ||
951 | { | ||
952 | $this->client->request('DELETE', '/api/entries/tags/list?list=' . json_encode([])); | ||
953 | |||
954 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | ||
955 | |||
956 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
957 | |||
958 | $this->assertEmpty($content); | ||
959 | } | ||
960 | |||
936 | public function testPostEntriesListAction() | 961 | public function testPostEntriesListAction() |
937 | { | 962 | { |
938 | $list = [ | 963 | $list = [ |
@@ -953,6 +978,17 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
953 | $this->assertSame('http://0.0.0.0/entry2', $content[1]['url']); | 978 | $this->assertSame('http://0.0.0.0/entry2', $content[1]['url']); |
954 | } | 979 | } |
955 | 980 | ||
981 | public function testPostEntriesListActionWithNoUrls() | ||
982 | { | ||
983 | $this->client->request('POST', '/api/entries/lists?urls=' . json_encode([])); | ||
984 | |||
985 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | ||
986 | |||
987 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
988 | |||
989 | $this->assertEmpty($content); | ||
990 | } | ||
991 | |||
956 | public function testDeleteEntriesListAction() | 992 | public function testDeleteEntriesListAction() |
957 | { | 993 | { |
958 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | 994 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); |
@@ -978,6 +1014,17 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
978 | $this->assertSame('http://0.0.0.0/test-entry-not-exist', $content[1]['url']); | 1014 | $this->assertSame('http://0.0.0.0/test-entry-not-exist', $content[1]['url']); |
979 | } | 1015 | } |
980 | 1016 | ||
1017 | public function testDeleteEntriesListActionWithNoUrls() | ||
1018 | { | ||
1019 | $this->client->request('DELETE', '/api/entries/list?urls=' . json_encode([])); | ||
1020 | |||
1021 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | ||
1022 | |||
1023 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
1024 | |||
1025 | $this->assertEmpty($content); | ||
1026 | } | ||
1027 | |||
981 | public function testLimitBulkAction() | 1028 | public function testLimitBulkAction() |
982 | { | 1029 | { |
983 | $list = [ | 1030 | $list = [ |