aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php32
-rw-r--r--tests/Wallabag/CoreBundle/Controller/FeedControllerTest.php228
-rw-r--r--tests/Wallabag/CoreBundle/Controller/RssControllerTest.php221
-rw-r--r--tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverterTest.php (renamed from tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php)24
-rw-r--r--tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php25
-rw-r--r--tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php2
7 files changed, 283 insertions, 251 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
index 1090a686..d8478ce3 100644
--- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
@@ -33,7 +33,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
33 $this->assertCount(1, $crawler->filter('button[id=config_save]')); 33 $this->assertCount(1, $crawler->filter('button[id=config_save]'));
34 $this->assertCount(1, $crawler->filter('button[id=change_passwd_save]')); 34 $this->assertCount(1, $crawler->filter('button[id=change_passwd_save]'));
35 $this->assertCount(1, $crawler->filter('button[id=update_user_save]')); 35 $this->assertCount(1, $crawler->filter('button[id=update_user_save]'));
36 $this->assertCount(1, $crawler->filter('button[id=rss_config_save]')); 36 $this->assertCount(1, $crawler->filter('button[id=feed_config_save]'));
37 } 37 }
38 38
39 public function testUpdate() 39 public function testUpdate()
@@ -297,7 +297,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
297 $this->assertContains('flashes.config.notice.user_updated', $alert[0]); 297 $this->assertContains('flashes.config.notice.user_updated', $alert[0]);
298 } 298 }
299 299
300 public function testRssUpdateResetToken() 300 public function testFeedUpdateResetToken()
301 { 301 {
302 $this->logInAs('admin'); 302 $this->logInAs('admin');
303 $client = $this->getClient(); 303 $client = $this->getClient();
@@ -313,7 +313,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
313 } 313 }
314 314
315 $config = $user->getConfig(); 315 $config = $user->getConfig();
316 $config->setRssToken(null); 316 $config->setFeedToken(null);
317 $em->persist($config); 317 $em->persist($config);
318 $em->flush(); 318 $em->flush();
319 319
@@ -322,7 +322,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
322 $this->assertSame(200, $client->getResponse()->getStatusCode()); 322 $this->assertSame(200, $client->getResponse()->getStatusCode());
323 323
324 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 324 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
325 $this->assertContains('config.form_rss.no_token', $body[0]); 325 $this->assertContains('config.form_feed.no_token', $body[0]);
326 326
327 $client->request('GET', '/generate-token'); 327 $client->request('GET', '/generate-token');
328 $this->assertSame(302, $client->getResponse()->getStatusCode()); 328 $this->assertSame(302, $client->getResponse()->getStatusCode());
@@ -330,7 +330,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
330 $crawler = $client->followRedirect(); 330 $crawler = $client->followRedirect();
331 331
332 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 332 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
333 $this->assertNotContains('config.form_rss.no_token', $body[0]); 333 $this->assertNotContains('config.form_feed.no_token', $body[0]);
334 } 334 }
335 335
336 public function testGenerateTokenAjax() 336 public function testGenerateTokenAjax()
@@ -351,7 +351,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
351 $this->assertArrayHasKey('token', $content); 351 $this->assertArrayHasKey('token', $content);
352 } 352 }
353 353
354 public function testRssUpdate() 354 public function testFeedUpdate()
355 { 355 {
356 $this->logInAs('admin'); 356 $this->logInAs('admin');
357 $client = $this->getClient(); 357 $client = $this->getClient();
@@ -360,10 +360,10 @@ class ConfigControllerTest extends WallabagCoreTestCase
360 360
361 $this->assertSame(200, $client->getResponse()->getStatusCode()); 361 $this->assertSame(200, $client->getResponse()->getStatusCode());
362 362
363 $form = $crawler->filter('button[id=rss_config_save]')->form(); 363 $form = $crawler->filter('button[id=feed_config_save]')->form();
364 364
365 $data = [ 365 $data = [
366 'rss_config[rss_limit]' => 12, 366 'feed_config[feed_limit]' => 12,
367 ]; 367 ];
368 368
369 $client->submit($form, $data); 369 $client->submit($form, $data);
@@ -372,31 +372,31 @@ class ConfigControllerTest extends WallabagCoreTestCase
372 372
373 $crawler = $client->followRedirect(); 373 $crawler = $client->followRedirect();
374 374
375 $this->assertContains('flashes.config.notice.rss_updated', $crawler->filter('body')->extract(['_text'])[0]); 375 $this->assertContains('flashes.config.notice.feed_updated', $crawler->filter('body')->extract(['_text'])[0]);
376 } 376 }
377 377
378 public function dataForRssFailed() 378 public function dataForFeedFailed()
379 { 379 {
380 return [ 380 return [
381 [ 381 [
382 [ 382 [
383 'rss_config[rss_limit]' => 0, 383 'feed_config[feed_limit]' => 0,
384 ], 384 ],
385 'This value should be 1 or more.', 385 'This value should be 1 or more.',
386 ], 386 ],
387 [ 387 [
388 [ 388 [
389 'rss_config[rss_limit]' => 1000000000000, 389 'feed_config[feed_limit]' => 1000000000000,
390 ], 390 ],
391 'validator.rss_limit_too_high', 391 'validator.feed_limit_too_high',
392 ], 392 ],
393 ]; 393 ];
394 } 394 }
395 395
396 /** 396 /**
397 * @dataProvider dataForRssFailed 397 * @dataProvider dataForFeedFailed
398 */ 398 */
399 public function testRssFailed($data, $expectedMessage) 399 public function testFeedFailed($data, $expectedMessage)
400 { 400 {
401 $this->logInAs('admin'); 401 $this->logInAs('admin');
402 $client = $this->getClient(); 402 $client = $this->getClient();
@@ -405,7 +405,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
405 405
406 $this->assertSame(200, $client->getResponse()->getStatusCode()); 406 $this->assertSame(200, $client->getResponse()->getStatusCode());
407 407
408 $form = $crawler->filter('button[id=rss_config_save]')->form(); 408 $form = $crawler->filter('button[id=feed_config_save]')->form();
409 409
410 $crawler = $client->submit($form, $data); 410 $crawler = $client->submit($form, $data);
411 411
diff --git a/tests/Wallabag/CoreBundle/Controller/FeedControllerTest.php b/tests/Wallabag/CoreBundle/Controller/FeedControllerTest.php
new file mode 100644
index 00000000..7442e8a4
--- /dev/null
+++ b/tests/Wallabag/CoreBundle/Controller/FeedControllerTest.php
@@ -0,0 +1,228 @@
1<?php
2
3namespace Tests\Wallabag\CoreBundle\Controller;
4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6
7class FeedControllerTest extends WallabagCoreTestCase
8{
9 public function validateDom($xml, $type, $nb = null, $tagValue = null)
10 {
11 $doc = new \DOMDocument();
12 $doc->loadXML($xml);
13
14 $xpath = new \DOMXpath($doc);
15 $xpath->registerNamespace('a', 'http://www.w3.org/2005/Atom');
16
17 if (null === $nb) {
18 $this->assertGreaterThan(0, $xpath->query('//a:entry')->length);
19 } else {
20 $this->assertEquals($nb, $xpath->query('//a:entry')->length);
21 }
22
23 $this->assertEquals(1, $xpath->query('/a:feed')->length);
24
25 $this->assertEquals(1, $xpath->query('/a:feed/a:title')->length);
26 $this->assertContains('favicon.ico', $xpath->query('/a:feed/a:icon')->item(0)->nodeValue);
27 $this->assertContains('logo-square.png', $xpath->query('/a:feed/a:logo')->item(0)->nodeValue);
28
29 $this->assertEquals(1, $xpath->query('/a:feed/a:updated')->length);
30
31 $this->assertEquals(1, $xpath->query('/a:feed/a:generator')->length);
32 $this->assertEquals('wallabag', $xpath->query('/a:feed/a:generator')->item(0)->nodeValue);
33 $this->assertEquals('admin', $xpath->query('/a:feed/a:author/a:name')->item(0)->nodeValue);
34
35 $this->assertEquals(1, $xpath->query('/a:feed/a:subtitle')->length);
36 if (null !== $tagValue && 0 === strpos($type, 'tag')) {
37 $this->assertEquals('wallabag — '.$type.' '.$tagValue.' feed', $xpath->query('/a:feed/a:title')->item(0)->nodeValue);
38 $this->assertEquals('Atom feed for entries tagged with ' . $tagValue, $xpath->query('/a:feed/a:subtitle')->item(0)->nodeValue);
39 } else {
40 $this->assertEquals('wallabag — '.$type.' feed', $xpath->query('/a:feed/a:title')->item(0)->nodeValue);
41 $this->assertEquals('Atom feed for ' . $type . ' entries', $xpath->query('/a:feed/a:subtitle')->item(0)->nodeValue);
42 }
43
44 $this->assertEquals(1, $xpath->query('/a:feed/a:link[@rel="self"]')->length);
45 $this->assertContains($type, $xpath->query('/a:feed/a:link[@rel="self"]')->item(0)->getAttribute('href'));
46
47 $this->assertEquals(1, $xpath->query('/a:feed/a:link[@rel="last"]')->length);
48
49 foreach ($xpath->query('//a:entry') as $item) {
50 $this->assertEquals(1, $xpath->query('a:title', $item)->length);
51 $this->assertEquals(1, $xpath->query('a:link[@rel="via"]', $item)->length);
52 $this->assertEquals(1, $xpath->query('a:link[@rel="alternate"]', $item)->length);
53 $this->assertEquals(1, $xpath->query('a:id', $item)->length);
54 $this->assertEquals(1, $xpath->query('a:published', $item)->length);
55 $this->assertEquals(1, $xpath->query('a:content', $item)->length);
56 }
57 }
58
59 public function dataForBadUrl()
60 {
61 return [
62 [
63 '/feed/admin/YZIOAUZIAO/unread',
64 ],
65 [
66 '/feed/wallace/YZIOAUZIAO/starred',
67 ],
68 [
69 '/feed/wallace/YZIOAUZIAO/archives',
70 ],
71 [
72 '/feed/wallace/YZIOAUZIAO/all',
73 ],
74 ];
75 }
76
77 /**
78 * @dataProvider dataForBadUrl
79 */
80 public function testBadUrl($url)
81 {
82 $client = $this->getClient();
83
84 $client->request('GET', $url);
85
86 $this->assertSame(404, $client->getResponse()->getStatusCode());
87 }
88
89 public function testUnread()
90 {
91 $client = $this->getClient();
92 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
93 $user = $em
94 ->getRepository('WallabagUserBundle:User')
95 ->findOneByUsername('admin');
96
97 $config = $user->getConfig();
98 $config->setFeedToken('SUPERTOKEN');
99 $config->setFeedLimit(2);
100 $em->persist($config);
101 $em->flush();
102
103 $client->request('GET', '/feed/admin/SUPERTOKEN/unread');
104
105 $this->assertSame(200, $client->getResponse()->getStatusCode());
106
107 $this->validateDom($client->getResponse()->getContent(), 'unread', 2);
108 }
109
110 public function testStarred()
111 {
112 $client = $this->getClient();
113 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
114 $user = $em
115 ->getRepository('WallabagUserBundle:User')
116 ->findOneByUsername('admin');
117
118 $config = $user->getConfig();
119 $config->setFeedToken('SUPERTOKEN');
120 $config->setFeedLimit(1);
121 $em->persist($config);
122 $em->flush();
123
124 $client = $this->getClient();
125 $client->request('GET', '/feed/admin/SUPERTOKEN/starred');
126
127 $this->assertSame(200, $client->getResponse()->getStatusCode(), 1);
128
129 $this->validateDom($client->getResponse()->getContent(), 'starred');
130 }
131
132 public function testArchives()
133 {
134 $client = $this->getClient();
135 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
136 $user = $em
137 ->getRepository('WallabagUserBundle:User')
138 ->findOneByUsername('admin');
139
140 $config = $user->getConfig();
141 $config->setFeedToken('SUPERTOKEN');
142 $config->setFeedLimit(null);
143 $em->persist($config);
144 $em->flush();
145
146 $client = $this->getClient();
147 $client->request('GET', '/feed/admin/SUPERTOKEN/archive');
148
149 $this->assertSame(200, $client->getResponse()->getStatusCode());
150
151 $this->validateDom($client->getResponse()->getContent(), 'archive');
152 }
153
154 public function testAll()
155 {
156 $client = $this->getClient();
157 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
158 $user = $em
159 ->getRepository('WallabagUserBundle:User')
160 ->findOneByUsername('admin');
161
162 $config = $user->getConfig();
163 $config->setFeedToken('SUPERTOKEN');
164 $config->setFeedLimit(null);
165 $em->persist($config);
166 $em->flush();
167
168 $client = $this->getClient();
169 $client->request('GET', '/feed/admin/SUPERTOKEN/all');
170
171 $this->assertSame(200, $client->getResponse()->getStatusCode());
172
173 $this->validateDom($client->getResponse()->getContent(), 'all');
174 }
175
176 public function testPagination()
177 {
178 $client = $this->getClient();
179 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
180 $user = $em
181 ->getRepository('WallabagUserBundle:User')
182 ->findOneByUsername('admin');
183
184 $config = $user->getConfig();
185 $config->setFeedToken('SUPERTOKEN');
186 $config->setFeedLimit(1);
187 $em->persist($config);
188 $em->flush();
189
190 $client = $this->getClient();
191
192 $client->request('GET', '/feed/admin/SUPERTOKEN/unread');
193 $this->assertEquals(200, $client->getResponse()->getStatusCode());
194 $this->validateDom($client->getResponse()->getContent(), 'unread');
195
196 $client->request('GET', '/feed/admin/SUPERTOKEN/unread/2');
197 $this->assertEquals(200, $client->getResponse()->getStatusCode());
198 $this->validateDom($client->getResponse()->getContent(), 'unread');
199
200 $client->request('GET', '/feed/admin/SUPERTOKEN/unread/3000');
201 $this->assertEquals(302, $client->getResponse()->getStatusCode());
202 }
203
204 public function testTags()
205 {
206 $client = $this->getClient();
207 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
208 $user = $em
209 ->getRepository('WallabagUserBundle:User')
210 ->findOneByUsername('admin');
211
212 $config = $user->getConfig();
213 $config->setFeedToken('SUPERTOKEN');
214 $config->setFeedLimit(null);
215 $em->persist($config);
216 $em->flush();
217
218 $client = $this->getClient();
219 $client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml');
220
221 $this->assertSame(200, $client->getResponse()->getStatusCode());
222
223 $this->validateDom($client->getResponse()->getContent(), 'tag', 2, 'foo-bar');
224
225 $client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml?page=3000');
226 $this->assertSame(302, $client->getResponse()->getStatusCode());
227 }
228}
diff --git a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
deleted file mode 100644
index afa90621..00000000
--- a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
+++ /dev/null
@@ -1,221 +0,0 @@
1<?php
2
3namespace Tests\Wallabag\CoreBundle\Controller;
4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6
7class RssControllerTest extends WallabagCoreTestCase
8{
9 public function validateDom($xml, $type, $urlPagination, $nb = null)
10 {
11 $doc = new \DOMDocument();
12 $doc->loadXML($xml);
13
14 $xpath = new \DOMXPath($doc);
15
16 if (null === $nb) {
17 $this->assertGreaterThan(0, $xpath->query('//item')->length);
18 } else {
19 $this->assertSame($nb, $xpath->query('//item')->length);
20 }
21
22 $this->assertSame(1, $xpath->query('/rss')->length);
23 $this->assertSame(1, $xpath->query('/rss/channel')->length);
24
25 $this->assertSame(1, $xpath->query('/rss/channel/title')->length);
26 $this->assertSame('wallabag - ' . $type . ' feed', $xpath->query('/rss/channel/title')->item(0)->nodeValue);
27
28 $this->assertSame(1, $xpath->query('/rss/channel/pubDate')->length);
29
30 $this->assertSame(1, $xpath->query('/rss/channel/generator')->length);
31 $this->assertSame('wallabag', $xpath->query('/rss/channel/generator')->item(0)->nodeValue);
32
33 $this->assertSame(1, $xpath->query('/rss/channel/description')->length);
34 $this->assertSame('wallabag ' . $type . ' elements', $xpath->query('/rss/channel/description')->item(0)->nodeValue);
35
36 $this->assertSame(1, $xpath->query('/rss/channel/link[@rel="self"]')->length);
37 $this->assertContains($urlPagination . '.xml', $xpath->query('/rss/channel/link[@rel="self"]')->item(0)->getAttribute('href'));
38
39 $this->assertSame(1, $xpath->query('/rss/channel/link[@rel="last"]')->length);
40 $this->assertContains($urlPagination . '.xml?page=', $xpath->query('/rss/channel/link[@rel="last"]')->item(0)->getAttribute('href'));
41
42 foreach ($xpath->query('//item') as $item) {
43 $this->assertSame(1, $xpath->query('title', $item)->length);
44 $this->assertSame(1, $xpath->query('source', $item)->length);
45 $this->assertSame(1, $xpath->query('link', $item)->length);
46 $this->assertSame(1, $xpath->query('guid', $item)->length);
47 $this->assertSame(1, $xpath->query('pubDate', $item)->length);
48 $this->assertSame(1, $xpath->query('description', $item)->length);
49 }
50 }
51
52 public function dataForBadUrl()
53 {
54 return [
55 [
56 '/admin/YZIOAUZIAO/unread.xml',
57 ],
58 [
59 '/wallace/YZIOAUZIAO/starred.xml',
60 ],
61 [
62 '/wallace/YZIOAUZIAO/archives.xml',
63 ],
64 [
65 '/wallace/YZIOAUZIAO/all.xml',
66 ],
67 ];
68 }
69
70 /**
71 * @dataProvider dataForBadUrl
72 */
73 public function testBadUrl($url)
74 {
75 $client = $this->getClient();
76
77 $client->request('GET', $url);
78
79 $this->assertSame(404, $client->getResponse()->getStatusCode());
80 }
81
82 public function testUnread()
83 {
84 $client = $this->getClient();
85 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
86 $user = $em
87 ->getRepository('WallabagUserBundle:User')
88 ->findOneByUsername('admin');
89
90 $config = $user->getConfig();
91 $config->setRssToken('SUPERTOKEN');
92 $config->setRssLimit(2);
93 $em->persist($config);
94 $em->flush();
95
96 $client->request('GET', '/admin/SUPERTOKEN/unread.xml');
97
98 $this->assertSame(200, $client->getResponse()->getStatusCode());
99
100 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread', 2);
101 }
102
103 public function testStarred()
104 {
105 $client = $this->getClient();
106 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
107 $user = $em
108 ->getRepository('WallabagUserBundle:User')
109 ->findOneByUsername('admin');
110
111 $config = $user->getConfig();
112 $config->setRssToken('SUPERTOKEN');
113 $config->setRssLimit(1);
114 $em->persist($config);
115 $em->flush();
116
117 $client = $this->getClient();
118 $client->request('GET', '/admin/SUPERTOKEN/starred.xml');
119
120 $this->assertSame(200, $client->getResponse()->getStatusCode(), 1);
121
122 $this->validateDom($client->getResponse()->getContent(), 'starred', 'starred');
123 }
124
125 public function testArchives()
126 {
127 $client = $this->getClient();
128 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
129 $user = $em
130 ->getRepository('WallabagUserBundle:User')
131 ->findOneByUsername('admin');
132
133 $config = $user->getConfig();
134 $config->setRssToken('SUPERTOKEN');
135 $config->setRssLimit(null);
136 $em->persist($config);
137 $em->flush();
138
139 $client = $this->getClient();
140 $client->request('GET', '/admin/SUPERTOKEN/archive.xml');
141
142 $this->assertSame(200, $client->getResponse()->getStatusCode());
143
144 $this->validateDom($client->getResponse()->getContent(), 'archive', 'archive');
145 }
146
147 public function testAll()
148 {
149 $client = $this->getClient();
150 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
151 $user = $em
152 ->getRepository('WallabagUserBundle:User')
153 ->findOneByUsername('admin');
154
155 $config = $user->getConfig();
156 $config->setRssToken('SUPERTOKEN');
157 $config->setRssLimit(null);
158 $em->persist($config);
159 $em->flush();
160
161 $client = $this->getClient();
162 $client->request('GET', '/admin/SUPERTOKEN/all.xml');
163
164 $this->assertSame(200, $client->getResponse()->getStatusCode());
165
166 $this->validateDom($client->getResponse()->getContent(), 'all', 'all');
167 }
168
169 public function testPagination()
170 {
171 $client = $this->getClient();
172 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
173 $user = $em
174 ->getRepository('WallabagUserBundle:User')
175 ->findOneByUsername('admin');
176
177 $config = $user->getConfig();
178 $config->setRssToken('SUPERTOKEN');
179 $config->setRssLimit(1);
180 $em->persist($config);
181 $em->flush();
182
183 $client = $this->getClient();
184
185 $client->request('GET', '/admin/SUPERTOKEN/unread.xml');
186 $this->assertSame(200, $client->getResponse()->getStatusCode());
187 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread');
188
189 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=2');
190 $this->assertSame(200, $client->getResponse()->getStatusCode());
191 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread');
192
193 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=3000');
194 $this->assertSame(302, $client->getResponse()->getStatusCode());
195 }
196
197 public function testTags()
198 {
199 $client = $this->getClient();
200 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
201 $user = $em
202 ->getRepository('WallabagUserBundle:User')
203 ->findOneByUsername('admin');
204
205 $config = $user->getConfig();
206 $config->setRssToken('SUPERTOKEN');
207 $config->setRssLimit(null);
208 $em->persist($config);
209 $em->flush();
210
211 $client = $this->getClient();
212 $client->request('GET', '/admin/SUPERTOKEN/tags/foo.xml');
213
214 $this->assertSame(200, $client->getResponse()->getStatusCode());
215
216 $this->validateDom($client->getResponse()->getContent(), 'tag (foo)', 'tags/foo');
217
218 $client->request('GET', '/admin/SUPERTOKEN/tags/foo.xml?page=3000');
219 $this->assertSame(302, $client->getResponse()->getStatusCode());
220 }
221}
diff --git a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
index b03c7550..3c3354d7 100644
--- a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
@@ -23,7 +23,7 @@ class SecurityControllerTest extends WallabagCoreTestCase
23 $client->followRedirects(); 23 $client->followRedirects();
24 24
25 $crawler = $client->request('GET', '/config'); 25 $crawler = $client->request('GET', '/config');
26 $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(['_text'])[0]); 26 $this->assertContains('config.form_feed.description', $crawler->filter('body')->extract(['_text'])[0]);
27 } 27 }
28 28
29 public function testLoginWith2FactorEmail() 29 public function testLoginWith2FactorEmail()
diff --git a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php b/tests/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverterTest.php
index 800af5c9..92fe38cd 100644
--- a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php
+++ b/tests/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverterTest.php
@@ -5,15 +5,15 @@ namespace Tests\Wallabag\CoreBundle\ParamConverter;
5use PHPUnit\Framework\TestCase; 5use PHPUnit\Framework\TestCase;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; 6use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\CoreBundle\ParamConverter\UsernameRssTokenConverter; 8use Wallabag\CoreBundle\ParamConverter\UsernameFeedTokenConverter;
9use Wallabag\UserBundle\Entity\User; 9use Wallabag\UserBundle\Entity\User;
10 10
11class UsernameRssTokenConverterTest extends TestCase 11class UsernameFeedTokenConverterTest extends TestCase
12{ 12{
13 public function testSupportsWithNoRegistry() 13 public function testSupportsWithNoRegistry()
14 { 14 {
15 $params = new ParamConverter([]); 15 $params = new ParamConverter([]);
16 $converter = new UsernameRssTokenConverter(); 16 $converter = new UsernameFeedTokenConverter();
17 17
18 $this->assertFalse($converter->supports($params)); 18 $this->assertFalse($converter->supports($params));
19 } 19 }
@@ -29,7 +29,7 @@ class UsernameRssTokenConverterTest extends TestCase
29 ->will($this->returnValue([])); 29 ->will($this->returnValue([]));
30 30
31 $params = new ParamConverter([]); 31 $params = new ParamConverter([]);
32 $converter = new UsernameRssTokenConverter($registry); 32 $converter = new UsernameFeedTokenConverter($registry);
33 33
34 $this->assertFalse($converter->supports($params)); 34 $this->assertFalse($converter->supports($params));
35 } 35 }
@@ -45,7 +45,7 @@ class UsernameRssTokenConverterTest extends TestCase
45 ->will($this->returnValue(['default' => null])); 45 ->will($this->returnValue(['default' => null]));
46 46
47 $params = new ParamConverter([]); 47 $params = new ParamConverter([]);
48 $converter = new UsernameRssTokenConverter($registry); 48 $converter = new UsernameFeedTokenConverter($registry);
49 49
50 $this->assertFalse($converter->supports($params)); 50 $this->assertFalse($converter->supports($params));
51 } 51 }
@@ -83,7 +83,7 @@ class UsernameRssTokenConverterTest extends TestCase
83 ->will($this->returnValue($em)); 83 ->will($this->returnValue($em));
84 84
85 $params = new ParamConverter(['class' => 'superclass']); 85 $params = new ParamConverter(['class' => 'superclass']);
86 $converter = new UsernameRssTokenConverter($registry); 86 $converter = new UsernameFeedTokenConverter($registry);
87 87
88 $this->assertFalse($converter->supports($params)); 88 $this->assertFalse($converter->supports($params));
89 } 89 }
@@ -121,7 +121,7 @@ class UsernameRssTokenConverterTest extends TestCase
121 ->will($this->returnValue($em)); 121 ->will($this->returnValue($em));
122 122
123 $params = new ParamConverter(['class' => 'WallabagUserBundle:User']); 123 $params = new ParamConverter(['class' => 'WallabagUserBundle:User']);
124 $converter = new UsernameRssTokenConverter($registry); 124 $converter = new UsernameFeedTokenConverter($registry);
125 125
126 $this->assertTrue($converter->supports($params)); 126 $this->assertTrue($converter->supports($params));
127 } 127 }
@@ -129,7 +129,7 @@ class UsernameRssTokenConverterTest extends TestCase
129 public function testApplyEmptyRequest() 129 public function testApplyEmptyRequest()
130 { 130 {
131 $params = new ParamConverter([]); 131 $params = new ParamConverter([]);
132 $converter = new UsernameRssTokenConverter(); 132 $converter = new UsernameFeedTokenConverter();
133 133
134 $res = $converter->apply(new Request(), $params); 134 $res = $converter->apply(new Request(), $params);
135 135
@@ -147,7 +147,7 @@ class UsernameRssTokenConverterTest extends TestCase
147 ->getMock(); 147 ->getMock();
148 148
149 $repo->expects($this->once()) 149 $repo->expects($this->once())
150 ->method('findOneByUsernameAndRsstoken') 150 ->method('findOneByUsernameAndFeedToken')
151 ->with('test', 'test') 151 ->with('test', 'test')
152 ->will($this->returnValue(null)); 152 ->will($this->returnValue(null));
153 153
@@ -170,7 +170,7 @@ class UsernameRssTokenConverterTest extends TestCase
170 ->will($this->returnValue($em)); 170 ->will($this->returnValue($em));
171 171
172 $params = new ParamConverter(['class' => 'WallabagUserBundle:User']); 172 $params = new ParamConverter(['class' => 'WallabagUserBundle:User']);
173 $converter = new UsernameRssTokenConverter($registry); 173 $converter = new UsernameFeedTokenConverter($registry);
174 $request = new Request([], [], ['username' => 'test', 'token' => 'test']); 174 $request = new Request([], [], ['username' => 'test', 'token' => 'test']);
175 175
176 $converter->apply($request, $params); 176 $converter->apply($request, $params);
@@ -185,7 +185,7 @@ class UsernameRssTokenConverterTest extends TestCase
185 ->getMock(); 185 ->getMock();
186 186
187 $repo->expects($this->once()) 187 $repo->expects($this->once())
188 ->method('findOneByUsernameAndRsstoken') 188 ->method('findOneByUsernameAndFeedtoken')
189 ->with('test', 'test') 189 ->with('test', 'test')
190 ->will($this->returnValue($user)); 190 ->will($this->returnValue($user));
191 191
@@ -208,7 +208,7 @@ class UsernameRssTokenConverterTest extends TestCase
208 ->will($this->returnValue($em)); 208 ->will($this->returnValue($em));
209 209
210 $params = new ParamConverter(['class' => 'WallabagUserBundle:User', 'name' => 'user']); 210 $params = new ParamConverter(['class' => 'WallabagUserBundle:User', 'name' => 'user']);
211 $converter = new UsernameRssTokenConverter($registry); 211 $converter = new UsernameFeedTokenConverter($registry);
212 $request = new Request([], [], ['username' => 'test', 'token' => 'test']); 212 $request = new Request([], [], ['username' => 'test', 'token' => 'test']);
213 213
214 $converter->apply($request, $params); 214 $converter->apply($request, $params);
diff --git a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
index bb92f745..3fd90fda 100644
--- a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
+++ b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
@@ -32,6 +32,31 @@ class WallabagExtensionTest extends TestCase
32 $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com')); 32 $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com'));
33 } 33 }
34 34
35 public function testRemoveScheme()
36 {
37 $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
38 ->disableOriginalConstructor()
39 ->getMock();
40
41 $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
42 ->disableOriginalConstructor()
43 ->getMock();
44
45 $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
46 ->disableOriginalConstructor()
47 ->getMock();
48
49 $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
50 ->disableOriginalConstructor()
51 ->getMock();
52
53 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
54
55 $this->assertEquals('lemonde.fr', $extension->removeScheme('lemonde.fr'));
56 $this->assertEquals('gist.github.com', $extension->removeScheme('gist.github.com'));
57 $this->assertEquals('gist.github.com', $extension->removeScheme('https://gist.github.com'));
58 }
59
35 public function testRemoveSchemeAndWww() 60 public function testRemoveSchemeAndWww()
36 { 61 {
37 $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 62 $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
diff --git a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
index c13bfbea..fd32f380 100644
--- a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
+++ b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
@@ -62,7 +62,7 @@ class CreateConfigListenerTest extends TestCase
62 $config = new Config($user); 62 $config = new Config($user);
63 $config->setTheme('baggy'); 63 $config->setTheme('baggy');
64 $config->setItemsPerPage(20); 64 $config->setItemsPerPage(20);
65 $config->setRssLimit(50); 65 $config->setFeedLimit(50);
66 $config->setLanguage('fr'); 66 $config->setLanguage('fr');
67 $config->setReadingSpeed(1); 67 $config->setReadingSpeed(1);
68 68