diff options
Diffstat (limited to 'tests/Wallabag')
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/RssControllerTest.php | 53 |
1 files changed, 49 insertions, 4 deletions
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 | ||
7 | class RssControllerTest extends WallabagCoreTestCase | 7 | class 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 | } |