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') 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 From 9095497191684707ce35aafe9b31822b8cf96a0f Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 20 Oct 2016 23:03:37 +0200 Subject: Fix test --- tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php index 5e8ee41d..01a92ad2 100644 --- a/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php +++ b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php @@ -219,7 +219,7 @@ JSON; $res = $consumer->manage($body); - $this->assertFalse($res); + $this->assertTrue($res); $this->assertFalse($consumer->isStopJob($body)); } } -- cgit v1.2.3 From f6798f69c3f3d6f4f8295f8168785ade6f1f125a Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 20 Oct 2016 23:26:16 +0200 Subject: =?UTF-8?q?This=20test=20doesn=E2=80=99t=20require=20an=20internet?= =?UTF-8?q?=20connection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index c742c620..05113650 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -366,8 +366,6 @@ class EntryControllerTest extends WallabagCoreTestCase /** * @depends testPostNewOk - * - * This test will require an internet connection. */ public function testReloadWithFetchingFailed() { -- cgit v1.2.3