diff options
Diffstat (limited to 'tests/Wallabag/ApiBundle')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 95c64501..ed104df3 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -36,6 +36,25 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
36 | $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type')); | 36 | $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
37 | } | 37 | } |
38 | 38 | ||
39 | public function testGetOneEntryWithOriginUrl() | ||
40 | { | ||
41 | $entry = $this->client->getContainer() | ||
42 | ->get('doctrine.orm.entity_manager') | ||
43 | ->getRepository('WallabagCoreBundle:Entry') | ||
44 | ->findOneBy(['user' => 1, 'url' => 'http://0.0.0.0/entry2']); | ||
45 | |||
46 | if (!$entry) { | ||
47 | $this->markTestSkipped('No content found in db.'); | ||
48 | } | ||
49 | |||
50 | $this->client->request('GET', '/api/entries/' . $entry->getId() . '.json'); | ||
51 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | ||
52 | |||
53 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
54 | |||
55 | $this->assertSame($entry->getOriginUrl(), $content['origin_url']); | ||
56 | } | ||
57 | |||
39 | public function testExportEntry() | 58 | public function testExportEntry() |
40 | { | 59 | { |
41 | $entry = $this->client->getContainer() | 60 | $entry = $this->client->getContainer() |
@@ -531,6 +550,29 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
531 | $this->assertSame(1, $content['is_starred']); | 550 | $this->assertSame(1, $content['is_starred']); |
532 | } | 551 | } |
533 | 552 | ||
553 | public function testPostEntryWithOriginUrl() | ||
554 | { | ||
555 | $this->client->request('POST', '/api/entries.json', [ | ||
556 | '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', | ||
557 | 'tags' => 'google', | ||
558 | 'title' => 'New title for my article', | ||
559 | 'content' => 'my content', | ||
560 | 'language' => 'de', | ||
561 | 'published_at' => '2016-09-08T11:55:58+0200', | ||
562 | 'authors' => 'bob,helen', | ||
563 | 'public' => 1, | ||
564 | 'origin_url' => 'http://mysource.tld', | ||
565 | ]); | ||
566 | |||
567 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | ||
568 | |||
569 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
570 | |||
571 | $this->assertGreaterThan(0, $content['id']); | ||
572 | $this->assertSame('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']); | ||
573 | $this->assertSame('http://mysource.tld', $content['origin_url']); | ||
574 | } | ||
575 | |||
534 | public function testPatchEntry() | 576 | public function testPatchEntry() |
535 | { | 577 | { |
536 | $entry = $this->client->getContainer() | 578 | $entry = $this->client->getContainer() |
@@ -607,6 +649,37 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
607 | $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved'); | 649 | $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved'); |
608 | } | 650 | } |
609 | 651 | ||
652 | public function testPatchEntryWithOriginUrl() | ||
653 | { | ||
654 | $entry = $this->client->getContainer() | ||
655 | ->get('doctrine.orm.entity_manager') | ||
656 | ->getRepository('WallabagCoreBundle:Entry') | ||
657 | ->findOneByUser(1); | ||
658 | |||
659 | if (!$entry) { | ||
660 | $this->markTestSkipped('No content found in db.'); | ||
661 | } | ||
662 | |||
663 | $previousContent = $entry->getContent(); | ||
664 | $previousLanguage = $entry->getLanguage(); | ||
665 | |||
666 | $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [ | ||
667 | 'title' => 'Another awesome title just for profit', | ||
668 | 'origin_url' => 'https://myawesomesource.example.com', | ||
669 | ]); | ||
670 | |||
671 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | ||
672 | |||
673 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
674 | |||
675 | $this->assertSame($entry->getId(), $content['id']); | ||
676 | $this->assertSame($entry->getUrl(), $content['url']); | ||
677 | $this->assertSame('https://myawesomesource.example.com', $content['origin_url']); | ||
678 | $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string'); | ||
679 | $this->assertSame($previousContent, $content['content'], 'Ensure content has not moved'); | ||
680 | $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved'); | ||
681 | } | ||
682 | |||
610 | public function testGetTagsEntry() | 683 | public function testGetTagsEntry() |
611 | { | 684 | { |
612 | $entry = $this->client->getContainer() | 685 | $entry = $this->client->getContainer() |