aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php40
-rw-r--r--tests/Wallabag/CoreBundle/Controller/RssControllerTest.php53
2 files changed, 89 insertions, 4 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index 566e9493..432ce7d8 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -678,4 +678,44 @@ class EntryRestControllerTest extends WallabagApiTestCase
678 678
679 $this->assertEquals(403, $this->client->getResponse()->getStatusCode()); 679 $this->assertEquals(403, $this->client->getResponse()->getStatusCode());
680 } 680 }
681
682 public function testReloadEntryErrorWhileFetching()
683 {
684 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
685 ->getRepository('WallabagCoreBundle:Entry')
686 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1);
687
688 if (!$entry) {
689 $this->markTestSkipped('No content found in db.');
690 }
691
692 $this->client->request('PATCH', '/api/entries/'.$entry->getId().'/reload.json');
693 $this->assertEquals(400, $this->client->getResponse()->getStatusCode());
694
695 $this->assertContains('Error while trying to extract content', $this->client->getResponse()->getContent());
696
697 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
698 }
699
700 public function testReloadEntry()
701 {
702 $this->client->request('POST', '/api/entries.json', [
703 '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',
704 'archive' => '1',
705 'tags' => 'google, apple',
706 ]);
707
708 $json = json_decode($this->client->getResponse()->getContent(), true);
709
710 $this->setUp();
711
712 $this->client->request('PATCH', '/api/entries/'.$json['id'].'/reload.json');
713 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
714
715 $content = json_decode($this->client->getResponse()->getContent(), true);
716
717 $this->assertNotEmpty($content['title']);
718
719 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
720 }
681} 721}
diff --git a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
index fb6fe06a..5a59654d 100644
--- a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
@@ -6,7 +6,7 @@ use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6 6
7class RssControllerTest extends WallabagCoreTestCase 7class RssControllerTest extends WallabagCoreTestCase
8{ 8{
9 public function validateDom($xml, $nb = null) 9 public function validateDom($xml, $type, $nb = null)
10 { 10 {
11 $doc = new \DOMDocument(); 11 $doc = new \DOMDocument();
12 $doc->loadXML($xml); 12 $doc->loadXML($xml);
@@ -22,6 +22,23 @@ class RssControllerTest extends WallabagCoreTestCase
22 $this->assertEquals(1, $xpath->query('/rss')->length); 22 $this->assertEquals(1, $xpath->query('/rss')->length);
23 $this->assertEquals(1, $xpath->query('/rss/channel')->length); 23 $this->assertEquals(1, $xpath->query('/rss/channel')->length);
24 24
25 $this->assertEquals(1, $xpath->query('/rss/channel/title')->length);
26 $this->assertEquals('wallabag — '.$type.' feed', $xpath->query('/rss/channel/title')->item(0)->nodeValue);
27
28 $this->assertEquals(1, $xpath->query('/rss/channel/pubDate')->length);
29
30 $this->assertEquals(1, $xpath->query('/rss/channel/generator')->length);
31 $this->assertEquals('wallabag', $xpath->query('/rss/channel/generator')->item(0)->nodeValue);
32
33 $this->assertEquals(1, $xpath->query('/rss/channel/description')->length);
34 $this->assertEquals('wallabag '.$type.' elements', $xpath->query('/rss/channel/description')->item(0)->nodeValue);
35
36 $this->assertEquals(1, $xpath->query('/rss/channel/link[@rel="self"]')->length);
37 $this->assertContains($type.'.xml', $xpath->query('/rss/channel/link[@rel="self"]')->item(0)->getAttribute('href'));
38
39 $this->assertEquals(1, $xpath->query('/rss/channel/link[@rel="last"]')->length);
40 $this->assertContains($type.'.xml?page=', $xpath->query('/rss/channel/link[@rel="last"]')->item(0)->getAttribute('href'));
41
25 foreach ($xpath->query('//item') as $item) { 42 foreach ($xpath->query('//item') as $item) {
26 $this->assertEquals(1, $xpath->query('title', $item)->length); 43 $this->assertEquals(1, $xpath->query('title', $item)->length);
27 $this->assertEquals(1, $xpath->query('source', $item)->length); 44 $this->assertEquals(1, $xpath->query('source', $item)->length);
@@ -77,7 +94,7 @@ class RssControllerTest extends WallabagCoreTestCase
77 94
78 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 95 $this->assertEquals(200, $client->getResponse()->getStatusCode());
79 96
80 $this->validateDom($client->getResponse()->getContent(), 2); 97 $this->validateDom($client->getResponse()->getContent(), 'unread', 2);
81 } 98 }
82 99
83 public function testStarred() 100 public function testStarred()
@@ -99,7 +116,7 @@ class RssControllerTest extends WallabagCoreTestCase
99 116
100 $this->assertEquals(200, $client->getResponse()->getStatusCode(), 1); 117 $this->assertEquals(200, $client->getResponse()->getStatusCode(), 1);
101 118
102 $this->validateDom($client->getResponse()->getContent()); 119 $this->validateDom($client->getResponse()->getContent(), 'starred');
103 } 120 }
104 121
105 public function testArchives() 122 public function testArchives()
@@ -121,6 +138,34 @@ class RssControllerTest extends WallabagCoreTestCase
121 138
122 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 139 $this->assertEquals(200, $client->getResponse()->getStatusCode());
123 140
124 $this->validateDom($client->getResponse()->getContent()); 141 $this->validateDom($client->getResponse()->getContent(), 'archive');
142 }
143
144 public function testPagination()
145 {
146 $client = $this->getClient();
147 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
148 $user = $em
149 ->getRepository('WallabagUserBundle:User')
150 ->findOneByUsername('admin');
151
152 $config = $user->getConfig();
153 $config->setRssToken('SUPERTOKEN');
154 $config->setRssLimit(1);
155 $em->persist($config);
156 $em->flush();
157
158 $client = $this->getClient();
159
160 $client->request('GET', '/admin/SUPERTOKEN/unread.xml');
161 $this->assertEquals(200, $client->getResponse()->getStatusCode());
162 $this->validateDom($client->getResponse()->getContent(), 'unread');
163
164 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=2');
165 $this->assertEquals(200, $client->getResponse()->getStatusCode());
166 $this->validateDom($client->getResponse()->getContent(), 'unread');
167
168 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=3000');
169 $this->assertEquals(302, $client->getResponse()->getStatusCode());
125 } 170 }
126} 171}