X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FTests%2FController%2FEntryControllerTest.php;h=9f2bcd6cf3c4a40a282672832aa8bbf5e872bd7c;hb=958671a7ae2f19c4b919ed4ba0161e7d300411b4;hp=2862417e304627dc7dc690183484f54d370d76f5;hpb=0e8f77819951bf8c6fa47fba7c0e004bdb7e7a41;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 2862417e..9f2bcd6c 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -31,6 +31,31 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertCount(1, $crawler->filter('button[type=submit]')); } + public function testPostNewViaBookmarklet() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/'); + + $this->assertCount(4, $crawler->filter('div[class=entry]')); + + // Good URL + $crawler = $client->request('GET', '/bookmarklet', array('url' => $this->url)); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $crawler = $client->followRedirect(); + $crawler = $client->request('GET', '/'); + $this->assertCount(5, $crawler->filter('div[class=entry]')); + + $em = $client->getContainer() + ->get('doctrine.orm.entity_manager'); + $entry = $em + ->getRepository('WallabagCoreBundle:Entry') + ->findOneByUrl($this->url); + $em->remove($entry); + $em->flush(); + } + public function testPostNewEmpty() { $this->logInAs('admin'); @@ -49,6 +74,9 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertEquals('This value should not be blank.', $alert[0]); } + /** + * This test will require an internet connection. + */ public function testPostNewOk() { $this->logInAs('admin'); @@ -74,6 +102,41 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertContains('Google', $alert[0]); } + /** + * This test will require an internet connection. + */ + public function testPostNewThatWillBeTaggued() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/new'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + $form = $crawler->filter('button[type=submit]')->form(); + + $data = array( + 'entry[url]' => $url = 'https://github.com/wallabag/wallabag', + ); + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $em = $client->getContainer() + ->get('doctrine.orm.entity_manager'); + $entry = $em + ->getRepository('WallabagCoreBundle:Entry') + ->findOneByUrl($url); + $this->assertCount(1, $entry->getTags()); + + $em->remove($entry); + $em->flush(); + } + public function testArchive() { $this->logInAs('admin'); @@ -94,6 +157,9 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode()); } + /** + * @depends testPostNewOk + */ public function testView() { $this->logInAs('admin');