aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests/Controller/RssControllerTest.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-06-23 09:18:18 +0200
committerGitHub <noreply@github.com>2016-06-23 09:18:18 +0200
commitd37bb05c881bfdbeb1144b327edd4dcc2cbb163f (patch)
tree1b90f7e733a83af4741a8cb7f49edf3e303f8677 /src/Wallabag/CoreBundle/Tests/Controller/RssControllerTest.php
parent891a026e31ad54ca90b70f6026f23260cfadb7fd (diff)
parent99451fe4b76051d61922a6beb7ee9e79cc6e7893 (diff)
downloadwallabag-d37bb05c881bfdbeb1144b327edd4dcc2cbb163f.tar.gz
wallabag-d37bb05c881bfdbeb1144b327edd4dcc2cbb163f.tar.zst
wallabag-d37bb05c881bfdbeb1144b327edd4dcc2cbb163f.zip
Merge pull request #2132 from wallabag/sf3.1
Jump to Symfony 3.1
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller/RssControllerTest.php')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/RssControllerTest.php126
1 files changed, 0 insertions, 126 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/RssControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/RssControllerTest.php
deleted file mode 100644
index 87a01b8e..00000000
--- a/src/Wallabag/CoreBundle/Tests/Controller/RssControllerTest.php
+++ /dev/null
@@ -1,126 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Tests\Controller;
4
5use Wallabag\CoreBundle\Tests\WallabagCoreTestCase;
6
7class RssControllerTest extends WallabagCoreTestCase
8{
9 public function validateDom($xml, $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->assertEquals($nb, $xpath->query('//item')->length);
20 }
21
22 $this->assertEquals(1, $xpath->query('/rss')->length);
23 $this->assertEquals(1, $xpath->query('/rss/channel')->length);
24
25 foreach ($xpath->query('//item') as $item) {
26 $this->assertEquals(1, $xpath->query('title', $item)->length);
27 $this->assertEquals(1, $xpath->query('source', $item)->length);
28 $this->assertEquals(1, $xpath->query('link', $item)->length);
29 $this->assertEquals(1, $xpath->query('guid', $item)->length);
30 $this->assertEquals(1, $xpath->query('pubDate', $item)->length);
31 $this->assertEquals(1, $xpath->query('description', $item)->length);
32 }
33 }
34
35 public function dataForBadUrl()
36 {
37 return [
38 [
39 '/admin/YZIOAUZIAO/unread.xml',
40 ],
41 [
42 '/wallace/YZIOAUZIAO/starred.xml',
43 ],
44 [
45 '/wallace/YZIOAUZIAO/archives.xml',
46 ],
47 ];
48 }
49
50 /**
51 * @dataProvider dataForBadUrl
52 */
53 public function testBadUrl($url)
54 {
55 $client = $this->getClient();
56
57 $client->request('GET', $url);
58
59 $this->assertEquals(404, $client->getResponse()->getStatusCode());
60 }
61
62 public function testUnread()
63 {
64 $client = $this->getClient();
65 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
66 $user = $em
67 ->getRepository('WallabagUserBundle:User')
68 ->findOneByUsername('admin');
69
70 $config = $user->getConfig();
71 $config->setRssToken('SUPERTOKEN');
72 $config->setRssLimit(2);
73 $em->persist($config);
74 $em->flush();
75
76 $client->request('GET', '/admin/SUPERTOKEN/unread.xml');
77
78 $this->assertEquals(200, $client->getResponse()->getStatusCode());
79
80 $this->validateDom($client->getResponse()->getContent(), 2);
81 }
82
83 public function testStarred()
84 {
85 $client = $this->getClient();
86 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
87 $user = $em
88 ->getRepository('WallabagUserBundle:User')
89 ->findOneByUsername('admin');
90
91 $config = $user->getConfig();
92 $config->setRssToken('SUPERTOKEN');
93 $config->setRssLimit(1);
94 $em->persist($config);
95 $em->flush();
96
97 $client = $this->getClient();
98 $client->request('GET', '/admin/SUPERTOKEN/starred.xml');
99
100 $this->assertEquals(200, $client->getResponse()->getStatusCode(), 1);
101
102 $this->validateDom($client->getResponse()->getContent());
103 }
104
105 public function testArchives()
106 {
107 $client = $this->getClient();
108 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
109 $user = $em
110 ->getRepository('WallabagUserBundle:User')
111 ->findOneByUsername('admin');
112
113 $config = $user->getConfig();
114 $config->setRssToken('SUPERTOKEN');
115 $config->setRssLimit(null);
116 $em->persist($config);
117 $em->flush();
118
119 $client = $this->getClient();
120 $client->request('GET', '/admin/SUPERTOKEN/archive.xml');
121
122 $this->assertEquals(200, $client->getResponse()->getStatusCode());
123
124 $this->validateDom($client->getResponse()->getContent());
125 }
126}