X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FTests%2FController%2FEntryControllerTest.php;h=5ce893c14fef9073b129d6e9b6da25931b3068ff;hb=5ecdfcd041767c9e3244a92bb0a6cc3c3f80fea3;hp=46fbaf918f6e936f9f5fd7a2e48ff8db1b10b262;hpb=77b9db87b84e20a6042444e3b18665bc66d4f1f2;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 46fbaf91..5ce893c1 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -28,7 +28,7 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->followRedirect(); $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); $this->assertContains('quickstart.intro.paragraph_1', $body[0]); // Test if quickstart is disabled when user has 1 entry @@ -38,16 +38,16 @@ class EntryControllerTest extends WallabagCoreTestCase $form = $crawler->filter('form[name=entry]')->form(); - $data = array( + $data = [ 'entry[url]' => $this->url, - ); + ]; $client->submit($form, $data); $this->assertEquals(302, $client->getResponse()->getStatusCode()); $client->followRedirect(); $crawler = $client->request('GET', '/unread/list'); - $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); $this->assertContains('entry.list.number_on_the_page', $body[0]); } @@ -74,7 +74,7 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertCount(4, $crawler->filter('div[class=entry]')); // Good URL - $client->request('GET', '/bookmarklet', array('url' => $this->url)); + $client->request('GET', '/bookmarklet', ['url' => $this->url]); $this->assertEquals(302, $client->getResponse()->getStatusCode()); $client->followRedirect(); $crawler = $client->request('GET', '/'); @@ -103,7 +103,7 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->submit($form); $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(array('_text'))); + $this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(['_text'])); $this->assertEquals('This value should not be blank.', $alert[0]); } @@ -121,9 +121,9 @@ class EntryControllerTest extends WallabagCoreTestCase $form = $crawler->filter('form[name=entry]')->form(); - $data = array( + $data = [ 'entry[url]' => $this->url, - ); + ]; $client->submit($form, $data); @@ -150,9 +150,9 @@ class EntryControllerTest extends WallabagCoreTestCase $form = $crawler->filter('form[name=entry]')->form(); - $data = array( + $data = [ 'entry[url]' => $this->url, - ); + ]; $client->submit($form, $data); @@ -163,7 +163,7 @@ class EntryControllerTest extends WallabagCoreTestCase /** * This test will require an internet connection. */ - public function testPostNewThatWillBeTaggued() + public function testPostNewThatWillBeTagged() { $this->logInAs('admin'); $client = $this->getClient(); @@ -174,15 +174,14 @@ class EntryControllerTest extends WallabagCoreTestCase $form = $crawler->filter('form[name=entry]')->form(); - $data = array( + $data = [ 'entry[url]' => $url = 'https://github.com/wallabag/wallabag', - ); + ]; $client->submit($form, $data); $this->assertEquals(302, $client->getResponse()->getStatusCode()); - - $client->followRedirect(); + $this->assertContains('/', $client->getResponse()->getTargetUrl()); $em = $client->getContainer() ->get('doctrine.orm.entity_manager'); @@ -196,6 +195,35 @@ class EntryControllerTest extends WallabagCoreTestCase $em->remove($entry); $em->flush(); + + // and now re-submit it to test the cascade persistence for tags after entry removal + // related https://github.com/wallabag/wallabag/issues/2121 + $crawler = $client->request('GET', '/new'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + $form = $crawler->filter('form[name=entry]')->form(); + + $data = [ + 'entry[url]' => $url = 'https://github.com/wallabag/wallabag/tree/master', + ]; + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $this->assertContains('/', $client->getResponse()->getTargetUrl()); + + $entry = $em + ->getRepository('WallabagCoreBundle:Entry') + ->findOneByUrl($url); + + $tags = $entry->getTags(); + + $this->assertCount(1, $tags); + $this->assertEquals('wallabag', $tags[0]->getLabel()); + + $em->remove($entry); + $em->flush(); } public function testArchive() @@ -245,7 +273,7 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/view/'.$content->getId()); $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); $this->assertContains($content->getTitle(), $body[0]); } @@ -315,9 +343,9 @@ class EntryControllerTest extends WallabagCoreTestCase $form = $crawler->filter('button[type=submit]')->form(); - $data = array( + $data = [ 'entry[title]' => 'My updated title hehe :)', - ); + ]; $client->submit($form, $data); @@ -325,7 +353,7 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->followRedirect(); - $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(array('_text'))); + $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(['_text'])); $this->assertContains('My updated title hehe :)', $alert[0]); } @@ -461,16 +489,34 @@ class EntryControllerTest extends WallabagCoreTestCase $form = $crawler->filter('button[id=submit-filter]')->form(); - $data = array( - 'entry_filter[readingTime][right_number]' => 11, - 'entry_filter[readingTime][left_number]' => 11, - ); + $data = [ + 'entry_filter[readingTime][right_number]' => 22, + 'entry_filter[readingTime][left_number]' => 22, + ]; $crawler = $client->submit($form, $data); $this->assertCount(1, $crawler->filter('div[class=entry]')); } + public function testFilterOnUnreadStatus() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/all/list'); + + $form = $crawler->filter('button[id=submit-filter]')->form(); + + $data = [ + 'entry_filter[isUnread]' => true, + ]; + + $crawler = $client->submit($form, $data); + + $this->assertCount(4, $crawler->filter('div[class=entry]')); + } + public function testFilterOnCreationDate() { $this->logInAs('admin'); @@ -480,28 +526,28 @@ class EntryControllerTest extends WallabagCoreTestCase $form = $crawler->filter('button[id=submit-filter]')->form(); - $data = array( + $data = [ 'entry_filter[createdAt][left_date]' => date('d/m/Y'), 'entry_filter[createdAt][right_date]' => date('d/m/Y', strtotime('+1 day')), - ); + ]; $crawler = $client->submit($form, $data); $this->assertCount(5, $crawler->filter('div[class=entry]')); - $data = array( + $data = [ 'entry_filter[createdAt][left_date]' => date('d/m/Y'), 'entry_filter[createdAt][right_date]' => date('d/m/Y'), - ); + ]; $crawler = $client->submit($form, $data); $this->assertCount(5, $crawler->filter('div[class=entry]')); - $data = array( + $data = [ 'entry_filter[createdAt][left_date]' => '01/01/1970', 'entry_filter[createdAt][right_date]' => '01/01/1970', - ); + ]; $crawler = $client->submit($form, $data); @@ -516,13 +562,13 @@ class EntryControllerTest extends WallabagCoreTestCase $form = $crawler->filter('button[id=config_save]')->form(); - $data = array( + $data = [ 'config[items_per_page]' => '1', - ); + ]; $client->submit($form, $data); - $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D='; + $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D='; $client->request('GET', 'unread/list'.$parameters); @@ -531,9 +577,9 @@ class EntryControllerTest extends WallabagCoreTestCase // reset pagination $crawler = $client->request('GET', '/config'); $form = $crawler->filter('button[id=config_save]')->form(); - $data = array( + $data = [ 'config[items_per_page]' => '12', - ); + ]; $client->submit($form, $data); } @@ -544,17 +590,17 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/unread/list'); $form = $crawler->filter('button[id=submit-filter]')->form(); - $data = array( + $data = [ 'entry_filter[domainName]' => 'domain', - ); + ]; $crawler = $client->submit($form, $data); $this->assertCount(5, $crawler->filter('div[class=entry]')); $form = $crawler->filter('button[id=submit-filter]')->form(); - $data = array( + $data = [ 'entry_filter[domainName]' => 'wallabag', - ); + ]; $crawler = $client->submit($form, $data); $this->assertCount(0, $crawler->filter('div[class=entry]')); @@ -601,17 +647,17 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/unread/list'); $form = $crawler->filter('button[id=submit-filter]')->form(); - $data = array( + $data = [ 'entry_filter[language]' => 'fr', - ); + ]; $crawler = $client->submit($form, $data); $this->assertCount(2, $crawler->filter('div[class=entry]')); $form = $crawler->filter('button[id=submit-filter]')->form(); - $data = array( + $data = [ 'entry_filter[language]' => 'en', - ); + ]; $crawler = $client->submit($form, $data); $this->assertCount(2, $crawler->filter('div[class=entry]'));