aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/RssControllerTest.php43
1 files changed, 34 insertions, 9 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
index 5a59654d..530c8bbf 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, $type, $nb = null) 9 public function validateDom($xml, $type, $urlPagination, $nb = null)
10 { 10 {
11 $doc = new \DOMDocument(); 11 $doc = new \DOMDocument();
12 $doc->loadXML($xml); 12 $doc->loadXML($xml);
@@ -23,7 +23,7 @@ class RssControllerTest extends WallabagCoreTestCase
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); 25 $this->assertEquals(1, $xpath->query('/rss/channel/title')->length);
26 $this->assertEquals('wallabag '.$type.' feed', $xpath->query('/rss/channel/title')->item(0)->nodeValue); 26 $this->assertEquals('wallabag - '.$type.' feed', $xpath->query('/rss/channel/title')->item(0)->nodeValue);
27 27
28 $this->assertEquals(1, $xpath->query('/rss/channel/pubDate')->length); 28 $this->assertEquals(1, $xpath->query('/rss/channel/pubDate')->length);
29 29
@@ -34,10 +34,10 @@ class RssControllerTest extends WallabagCoreTestCase
34 $this->assertEquals('wallabag '.$type.' elements', $xpath->query('/rss/channel/description')->item(0)->nodeValue); 34 $this->assertEquals('wallabag '.$type.' elements', $xpath->query('/rss/channel/description')->item(0)->nodeValue);
35 35
36 $this->assertEquals(1, $xpath->query('/rss/channel/link[@rel="self"]')->length); 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')); 37 $this->assertContains($urlPagination.'.xml', $xpath->query('/rss/channel/link[@rel="self"]')->item(0)->getAttribute('href'));
38 38
39 $this->assertEquals(1, $xpath->query('/rss/channel/link[@rel="last"]')->length); 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')); 40 $this->assertContains($urlPagination.'.xml?page=', $xpath->query('/rss/channel/link[@rel="last"]')->item(0)->getAttribute('href'));
41 41
42 foreach ($xpath->query('//item') as $item) { 42 foreach ($xpath->query('//item') as $item) {
43 $this->assertEquals(1, $xpath->query('title', $item)->length); 43 $this->assertEquals(1, $xpath->query('title', $item)->length);
@@ -94,7 +94,7 @@ class RssControllerTest extends WallabagCoreTestCase
94 94
95 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 95 $this->assertEquals(200, $client->getResponse()->getStatusCode());
96 96
97 $this->validateDom($client->getResponse()->getContent(), 'unread', 2); 97 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread', 2);
98 } 98 }
99 99
100 public function testStarred() 100 public function testStarred()
@@ -116,7 +116,7 @@ class RssControllerTest extends WallabagCoreTestCase
116 116
117 $this->assertEquals(200, $client->getResponse()->getStatusCode(), 1); 117 $this->assertEquals(200, $client->getResponse()->getStatusCode(), 1);
118 118
119 $this->validateDom($client->getResponse()->getContent(), 'starred'); 119 $this->validateDom($client->getResponse()->getContent(), 'starred', 'starred');
120 } 120 }
121 121
122 public function testArchives() 122 public function testArchives()
@@ -138,7 +138,7 @@ class RssControllerTest extends WallabagCoreTestCase
138 138
139 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 139 $this->assertEquals(200, $client->getResponse()->getStatusCode());
140 140
141 $this->validateDom($client->getResponse()->getContent(), 'archive'); 141 $this->validateDom($client->getResponse()->getContent(), 'archive', 'archive');
142 } 142 }
143 143
144 public function testPagination() 144 public function testPagination()
@@ -159,13 +159,38 @@ class RssControllerTest extends WallabagCoreTestCase
159 159
160 $client->request('GET', '/admin/SUPERTOKEN/unread.xml'); 160 $client->request('GET', '/admin/SUPERTOKEN/unread.xml');
161 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 161 $this->assertEquals(200, $client->getResponse()->getStatusCode());
162 $this->validateDom($client->getResponse()->getContent(), 'unread'); 162 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread');
163 163
164 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=2'); 164 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=2');
165 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 165 $this->assertEquals(200, $client->getResponse()->getStatusCode());
166 $this->validateDom($client->getResponse()->getContent(), 'unread'); 166 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread');
167 167
168 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=3000'); 168 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=3000');
169 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 169 $this->assertEquals(302, $client->getResponse()->getStatusCode());
170 } 170 }
171
172 public function testTags()
173 {
174 $client = $this->getClient();
175 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
176 $user = $em
177 ->getRepository('WallabagUserBundle:User')
178 ->findOneByUsername('admin');
179
180 $config = $user->getConfig();
181 $config->setRssToken('SUPERTOKEN');
182 $config->setRssLimit(null);
183 $em->persist($config);
184 $em->flush();
185
186 $client = $this->getClient();
187 $client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml');
188
189 $this->assertEquals(200, $client->getResponse()->getStatusCode());
190
191 $this->validateDom($client->getResponse()->getContent(), 'tag (foo bar)', 'tags/foo-bar');
192
193 $client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml?page=3000');
194 $this->assertEquals(302, $client->getResponse()->getStatusCode());
195 }
171} 196}