X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FCoreBundle%2FController%2FRssControllerTest.php;h=530c8bbfb016afe4a731da2e14b27e38b55eb3f9;hb=11b8695663b3a649a452b8a4d2ee3ccd70202e9e;hp=5a59654d3601c644c1ed611d5e24354c13a5dbc0;hpb=944b8d61752bedd126e1cdaeb3205177e414cf6b;p=github%2Fwallabag%2Fwallabag.git 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; class RssControllerTest extends WallabagCoreTestCase { - public function validateDom($xml, $type, $nb = null) + public function validateDom($xml, $type, $urlPagination, $nb = null) { $doc = new \DOMDocument(); $doc->loadXML($xml); @@ -23,7 +23,7 @@ class RssControllerTest extends WallabagCoreTestCase $this->assertEquals(1, $xpath->query('/rss/channel')->length); $this->assertEquals(1, $xpath->query('/rss/channel/title')->length); - $this->assertEquals('wallabag — '.$type.' feed', $xpath->query('/rss/channel/title')->item(0)->nodeValue); + $this->assertEquals('wallabag - '.$type.' feed', $xpath->query('/rss/channel/title')->item(0)->nodeValue); $this->assertEquals(1, $xpath->query('/rss/channel/pubDate')->length); @@ -34,10 +34,10 @@ class RssControllerTest extends WallabagCoreTestCase $this->assertEquals('wallabag '.$type.' elements', $xpath->query('/rss/channel/description')->item(0)->nodeValue); $this->assertEquals(1, $xpath->query('/rss/channel/link[@rel="self"]')->length); - $this->assertContains($type.'.xml', $xpath->query('/rss/channel/link[@rel="self"]')->item(0)->getAttribute('href')); + $this->assertContains($urlPagination.'.xml', $xpath->query('/rss/channel/link[@rel="self"]')->item(0)->getAttribute('href')); $this->assertEquals(1, $xpath->query('/rss/channel/link[@rel="last"]')->length); - $this->assertContains($type.'.xml?page=', $xpath->query('/rss/channel/link[@rel="last"]')->item(0)->getAttribute('href')); + $this->assertContains($urlPagination.'.xml?page=', $xpath->query('/rss/channel/link[@rel="last"]')->item(0)->getAttribute('href')); foreach ($xpath->query('//item') as $item) { $this->assertEquals(1, $xpath->query('title', $item)->length); @@ -94,7 +94,7 @@ class RssControllerTest extends WallabagCoreTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->validateDom($client->getResponse()->getContent(), 'unread', 2); + $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread', 2); } public function testStarred() @@ -116,7 +116,7 @@ class RssControllerTest extends WallabagCoreTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode(), 1); - $this->validateDom($client->getResponse()->getContent(), 'starred'); + $this->validateDom($client->getResponse()->getContent(), 'starred', 'starred'); } public function testArchives() @@ -138,7 +138,7 @@ class RssControllerTest extends WallabagCoreTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->validateDom($client->getResponse()->getContent(), 'archive'); + $this->validateDom($client->getResponse()->getContent(), 'archive', 'archive'); } public function testPagination() @@ -159,13 +159,38 @@ class RssControllerTest extends WallabagCoreTestCase $client->request('GET', '/admin/SUPERTOKEN/unread.xml'); $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->validateDom($client->getResponse()->getContent(), 'unread'); + $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread'); $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=2'); $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->validateDom($client->getResponse()->getContent(), 'unread'); + $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread'); $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=3000'); $this->assertEquals(302, $client->getResponse()->getStatusCode()); } + + public function testTags() + { + $client = $this->getClient(); + $em = $client->getContainer()->get('doctrine.orm.entity_manager'); + $user = $em + ->getRepository('WallabagUserBundle:User') + ->findOneByUsername('admin'); + + $config = $user->getConfig(); + $config->setRssToken('SUPERTOKEN'); + $config->setRssLimit(null); + $em->persist($config); + $em->flush(); + + $client = $this->getClient(); + $client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + $this->validateDom($client->getResponse()->getContent(), 'tag (foo bar)', 'tags/foo-bar'); + + $client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml?page=3000'); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + } }