aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/RssControllerTest.php71
-rw-r--r--tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php25
2 files changed, 60 insertions, 36 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
index 6167fe2d..0e4a5afa 100644
--- a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
@@ -12,40 +12,39 @@ class RssControllerTest extends WallabagCoreTestCase
12 $doc->loadXML($xml); 12 $doc->loadXML($xml);
13 13
14 $xpath = new \DOMXpath($doc); 14 $xpath = new \DOMXpath($doc);
15 $xpath->registerNamespace('a', 'http://www.w3.org/2005/Atom');
15 16
16 if (null === $nb) { 17 if (null === $nb) {
17 $this->assertGreaterThan(0, $xpath->query('//item')->length); 18 $this->assertGreaterThan(0, $xpath->query('//a:entry')->length);
18 } else { 19 } else {
19 $this->assertSame($nb, $xpath->query('//item')->length); 20 $this->assertEquals($nb, $xpath->query('//a:entry')->length);
20 } 21 }
21 22
22 $this->assertSame(1, $xpath->query('/rss')->length); 23 $this->assertEquals(1, $xpath->query('/a:feed')->length);
23 $this->assertSame(1, $xpath->query('/rss/channel')->length);
24 24
25 $this->assertSame(1, $xpath->query('/rss/channel/title')->length); 25 $this->assertEquals(1, $xpath->query('/a:feed/a:title')->length);
26 $this->assertSame('wallabag - ' . $type . ' feed', $xpath->query('/rss/channel/title')->item(0)->nodeValue); 26 $this->assertEquals('wallabag '.$type.' feed', $xpath->query('/a:feed/a:title')->item(0)->nodeValue);
27 27
28 $this->assertSame(1, $xpath->query('/rss/channel/pubDate')->length); 28 $this->assertEquals(1, $xpath->query('/a:feed/a:updated')->length);
29 29
30 $this->assertSame(1, $xpath->query('/rss/channel/generator')->length); 30 $this->assertEquals(1, $xpath->query('/a:feed/a:generator')->length);
31 $this->assertSame('wallabag', $xpath->query('/rss/channel/generator')->item(0)->nodeValue); 31 $this->assertEquals('wallabag', $xpath->query('/a:feed/a:generator')->item(0)->nodeValue);
32 32
33 $this->assertSame(1, $xpath->query('/rss/channel/description')->length); 33 $this->assertEquals(1, $xpath->query('/a:feed/a:subtitle')->length);
34 $this->assertSame('wallabag ' . $type . ' elements', $xpath->query('/rss/channel/description')->item(0)->nodeValue); 34 $this->assertEquals('RSS feed for '.$type.' entries', $xpath->query('/a:feed/a:subtitle')->item(0)->nodeValue);
35 35
36 $this->assertSame(1, $xpath->query('/rss/channel/link[@rel="self"]')->length); 36 $this->assertEquals(1, $xpath->query('/a:feed/a:link[@rel="self"]')->length);
37 $this->assertContains($urlPagination . '.xml', $xpath->query('/rss/channel/link[@rel="self"]')->item(0)->getAttribute('href')); 37 $this->assertContains($type, $xpath->query('/a:feed/a:link[@rel="self"]')->item(0)->getAttribute('href'));
38 38
39 $this->assertSame(1, $xpath->query('/rss/channel/link[@rel="last"]')->length); 39 $this->assertEquals(1, $xpath->query('/a:feed/a:link[@rel="last"]')->length);
40 $this->assertContains($urlPagination . '.xml?page=', $xpath->query('/rss/channel/link[@rel="last"]')->item(0)->getAttribute('href'));
41 40
42 foreach ($xpath->query('//item') as $item) { 41 foreach ($xpath->query('//a:entry') as $item) {
43 $this->assertSame(1, $xpath->query('title', $item)->length); 42 $this->assertEquals(1, $xpath->query('a:title', $item)->length);
44 $this->assertSame(1, $xpath->query('source', $item)->length); 43 $this->assertEquals(1, $xpath->query('a:link[@rel="via"]', $item)->length);
45 $this->assertSame(1, $xpath->query('link', $item)->length); 44 $this->assertEquals(1, $xpath->query('a:link[@rel="alternate"]', $item)->length);
46 $this->assertSame(1, $xpath->query('guid', $item)->length); 45 $this->assertEquals(1, $xpath->query('a:id', $item)->length);
47 $this->assertSame(1, $xpath->query('pubDate', $item)->length); 46 $this->assertEquals(1, $xpath->query('a:published', $item)->length);
48 $this->assertSame(1, $xpath->query('description', $item)->length); 47 $this->assertEquals(1, $xpath->query('a:content', $item)->length);
49 } 48 }
50 } 49 }
51 50
@@ -53,13 +52,13 @@ class RssControllerTest extends WallabagCoreTestCase
53 { 52 {
54 return [ 53 return [
55 [ 54 [
56 '/admin/YZIOAUZIAO/unread.xml', 55 '/feed/admin/YZIOAUZIAO/unread',
57 ], 56 ],
58 [ 57 [
59 '/wallace/YZIOAUZIAO/starred.xml', 58 '/feed/wallace/YZIOAUZIAO/starred',
60 ], 59 ],
61 [ 60 [
62 '/wallace/YZIOAUZIAO/archives.xml', 61 '/feed/wallace/YZIOAUZIAO/archives',
63 ], 62 ],
64 ]; 63 ];
65 } 64 }
@@ -90,7 +89,7 @@ class RssControllerTest extends WallabagCoreTestCase
90 $em->persist($config); 89 $em->persist($config);
91 $em->flush(); 90 $em->flush();
92 91
93 $client->request('GET', '/admin/SUPERTOKEN/unread.xml'); 92 $client->request('GET', '/feed/admin/SUPERTOKEN/unread');
94 93
95 $this->assertSame(200, $client->getResponse()->getStatusCode()); 94 $this->assertSame(200, $client->getResponse()->getStatusCode());
96 95
@@ -112,7 +111,7 @@ class RssControllerTest extends WallabagCoreTestCase
112 $em->flush(); 111 $em->flush();
113 112
114 $client = $this->getClient(); 113 $client = $this->getClient();
115 $client->request('GET', '/admin/SUPERTOKEN/starred.xml'); 114 $client->request('GET', '/feed/admin/SUPERTOKEN/starred');
116 115
117 $this->assertSame(200, $client->getResponse()->getStatusCode(), 1); 116 $this->assertSame(200, $client->getResponse()->getStatusCode(), 1);
118 117
@@ -134,7 +133,7 @@ class RssControllerTest extends WallabagCoreTestCase
134 $em->flush(); 133 $em->flush();
135 134
136 $client = $this->getClient(); 135 $client = $this->getClient();
137 $client->request('GET', '/admin/SUPERTOKEN/archive.xml'); 136 $client->request('GET', '/feed/admin/SUPERTOKEN/archive');
138 137
139 $this->assertSame(200, $client->getResponse()->getStatusCode()); 138 $this->assertSame(200, $client->getResponse()->getStatusCode());
140 139
@@ -157,16 +156,16 @@ class RssControllerTest extends WallabagCoreTestCase
157 156
158 $client = $this->getClient(); 157 $client = $this->getClient();
159 158
160 $client->request('GET', '/admin/SUPERTOKEN/unread.xml'); 159 $client->request('GET', '/feed/admin/SUPERTOKEN/unread');
161 $this->assertSame(200, $client->getResponse()->getStatusCode()); 160 $this->assertEquals(200, $client->getResponse()->getStatusCode());
162 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread'); 161 $this->validateDom($client->getResponse()->getContent(), 'unread');
163 162
164 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=2'); 163 $client->request('GET', '/feed/admin/SUPERTOKEN/unread/2');
165 $this->assertSame(200, $client->getResponse()->getStatusCode()); 164 $this->assertEquals(200, $client->getResponse()->getStatusCode());
166 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread'); 165 $this->validateDom($client->getResponse()->getContent(), 'unread');
167 166
168 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=3000'); 167 $client->request('GET', '/feed/admin/SUPERTOKEN/unread/3000');
169 $this->assertSame(302, $client->getResponse()->getStatusCode()); 168 $this->assertEquals(302, $client->getResponse()->getStatusCode());
170 } 169 }
171 170
172 public function testTags() 171 public function testTags()
diff --git a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
index ceec4b37..4cb84ef1 100644
--- a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
+++ b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
@@ -30,4 +30,29 @@ class WallabagExtensionTest extends \PHPUnit_Framework_TestCase
30 $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr')); 30 $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
31 $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com')); 31 $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com'));
32 } 32 }
33
34 public function testRemoveScheme()
35 {
36 $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
37 ->disableOriginalConstructor()
38 ->getMock();
39
40 $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
41 ->disableOriginalConstructor()
42 ->getMock();
43
44 $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
45 ->disableOriginalConstructor()
46 ->getMock();
47
48 $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
49 ->disableOriginalConstructor()
50 ->getMock();
51
52 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
53
54 $this->assertEquals('lemonde.fr', $extension->removeScheme('lemonde.fr'));
55 $this->assertEquals('gist.github.com', $extension->removeScheme('gist.github.com'));
56 $this->assertEquals('gist.github.com', $extension->removeScheme('https://gist.github.com'));
57 }
33} 58}