From 97444566db31c287103468ee64e2b234d223a354 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sun, 19 Nov 2017 14:50:21 +0100 Subject: [PATCH 1/1] Update EntryControllerTest to handle origin_url Set an origin_url in testEditUpdate Test origin_url deletion in testEditRemoveOriginUrl Signed-off-by: Kevin Decherf --- .../Controller/EntryControllerTest.php | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 6e806553..e2fb8d78 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -475,6 +475,7 @@ class EntryControllerTest extends WallabagCoreTestCase $data = [ 'entry[title]' => 'My updated title hehe :)', + 'entry[origin_url]' => 'https://example.io', ]; $client->submit($form, $data); @@ -483,8 +484,43 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->followRedirect(); - $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(['_text'])); - $this->assertContains('My updated title hehe :)', $alert[0]); + $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); + $this->assertContains('My updated title hehe :)', $title[0]); + $this->assertGreaterThan(1, $stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text'])); + $this->assertContains('example.io', trim($stats[1])); + } + + public function testEditRemoveOriginUrl() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $entry = new Entry($this->getLoggedInUser()); + $entry->setUrl($this->url); + $this->getEntityManager()->persist($entry); + $this->getEntityManager()->flush(); + + $crawler = $client->request('GET', '/edit/' . $entry->getId()); + + $this->assertSame(200, $client->getResponse()->getStatusCode()); + + $form = $crawler->filter('button[type=submit]')->form(); + + $data = [ + 'entry[title]' => 'My updated title hehe :)', + 'entry[origin_url]' => '', + ]; + + $client->submit($form, $data); + + $this->assertSame(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); + $this->assertContains('My updated title hehe :)', $title[0]); + $this->assertSame(1, sizeof($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']))); + $this->assertNotContains('example.io', trim($stats[0])); } public function testToggleArchive() -- 2.41.0