From 2297d60f100effc1bf4300488a170a6bed3ae756 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 20 Oct 2016 22:49:46 +0200 Subject: =?UTF-8?q?If=20reload=20content=20failed,=20don=E2=80=99t=20updat?= =?UTF-8?q?e=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case user wants a fresh version of the current one and the website isn’t available, don’t erase it with a boring message saying wallabag wasn’t able to refresh the content. --- .../CoreBundle/Controller/EntryControllerTest.php | 42 +++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'tests/Wallabag/CoreBundle') 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'); -- cgit v1.2.3