X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FCoreBundle%2FController%2FEntryControllerTest.php;h=c742c62043c6ef61162154ab7c50dc13f07da59a;hb=2297d60f100effc1bf4300488a170a6bed3ae756;hp=9b03a5193d1c7b8edb6d660f0cb021336061f663;hpb=4ad6f5878a7e7ab6359151b049fb49b9dd2c78ec;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 9b03a519..c742c620 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -359,11 +359,51 @@ class EntryControllerTest extends WallabagCoreTestCase $content = $em ->getRepository('WallabagCoreBundle:Entry') - ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); + ->find($content->getId()); $this->assertNotEmpty($content->getContent()); } + /** + * @depends testPostNewOk + * + * This test will require an internet connection. + */ + public function testReloadWithFetchingFailed() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $em = $client->getContainer() + ->get('doctrine.orm.entity_manager'); + + $content = $em + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); + + // put a known failed url + $content->setUrl('http://0.0.0.0/failed.html'); + $em->persist($content); + $em->flush(); + + $client->request('GET', '/reload/'.$content->getId()); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + // force EntityManager to clear previous entity + // otherwise, retrieve the same entity will retrieve change from the previous request :0 + $em->clear(); + $newContent = $em + ->getRepository('WallabagCoreBundle:Entry') + ->find($content->getId()); + + $newContent->setUrl($this->url); + $em->persist($newContent); + $em->flush(); + + $this->assertNotEquals($client->getContainer()->getParameter('wallabag_core.fetching_error_message'), $newContent->getContent()); + } + public function testEdit() { $this->logInAs('admin');