diff options
Diffstat (limited to 'tests/Wallabag')
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 5c739c78..f9ac28c3 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -698,4 +698,47 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
698 | $crawler = $client->submit($form, $data); | 698 | $crawler = $client->submit($form, $data); |
699 | $this->assertCount(2, $crawler->filter('div[class=entry]')); | 699 | $this->assertCount(2, $crawler->filter('div[class=entry]')); |
700 | } | 700 | } |
701 | |||
702 | public function testCache() | ||
703 | { | ||
704 | $this->logInAs('admin'); | ||
705 | $client = $this->getClient(); | ||
706 | |||
707 | $content = $client->getContainer() | ||
708 | ->get('doctrine.orm.entity_manager') | ||
709 | ->getRepository('WallabagCoreBundle:Entry') | ||
710 | ->findOneByUser($this->getLoggedInUserId()); | ||
711 | |||
712 | // no uuid | ||
713 | $client->request('GET', '/share/'.$content->getUuid()); | ||
714 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | ||
715 | |||
716 | // generating the uuid | ||
717 | $client->request('GET', '/share/'.$content->getId()); | ||
718 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
719 | |||
720 | // follow link with uuid | ||
721 | $crawler = $client->followRedirect(); | ||
722 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
723 | $this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control')); | ||
724 | $this->assertContains('public', $client->getResponse()->headers->get('cache-control')); | ||
725 | $this->assertContains('s-maxage=25200', $client->getResponse()->headers->get('cache-control')); | ||
726 | $this->assertNotContains('no-cache', $client->getResponse()->headers->get('cache-control')); | ||
727 | |||
728 | // sharing is now disabled | ||
729 | $client->getContainer()->get('craue_config')->set('share_public', 0); | ||
730 | $client->request('GET', '/share/'.$content->getUuid()); | ||
731 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | ||
732 | |||
733 | $client->request('GET', '/view/'.$content->getId()); | ||
734 | $this->assertContains('no-cache', $client->getResponse()->headers->get('cache-control')); | ||
735 | |||
736 | // removing the share | ||
737 | $client->request('GET', '/share/delete/'.$content->getId()); | ||
738 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
739 | |||
740 | // share is now disable | ||
741 | $client->request('GET', '/share/'.$content->getUuid()); | ||
742 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | ||
743 | } | ||
701 | } | 744 | } |