X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2FWallabag%2FCoreBundle%2FTests%2FController%2FEntryControllerTest.php;h=9f585d85d722ecf13c89a5d6a287cccd9c0acbca;hb=2863bf2ab58a4903128f60751aa416130db93e52;hp=56b4c9e41af815259f43ca815f7efa9486138536;hpb=75c48e3ae0e7b23a246216b98f9b1368b9cdd69b;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 56b4c9e4..9f585d85 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -3,6 +3,7 @@ namespace Wallabag\CoreBundle\Tests\Controller; use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; +use Wallabag\CoreBundle\Entity\Entry; class EntryControllerTest extends WallabagCoreTestCase { @@ -102,6 +103,44 @@ 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); + $tags = $entry->getTags(); + + $this->assertCount(1, $tags); + $this->assertEquals('wallabag', $tags[0]->getLabel()); + + $em->remove($entry); + $em->flush(); + } + public function testArchive() { $this->logInAs('admin'); @@ -252,6 +291,51 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertEquals(404, $client->getResponse()->getStatusCode()); } + /** + * It will create a new entry. + * Browse to it. + * Then remove it. + * + * And it'll check that user won't be redirected to the view page of the content when it had been removed + */ + public function testViewAndDelete() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + // add a new content to be removed later + $user = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagUserBundle:User') + ->findOneByUserName('admin'); + + $content = new Entry($user); + $content->setUrl('http://1.1.1.1/entry'); + $content->setReadingTime(12); + $content->setDomainName('domain.io'); + $content->setMimetype('text/html'); + $content->setTitle('test title entry'); + $content->setContent('This is my content /o/'); + $content->setArchived(true); + $content->setLanguage('fr'); + + $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->persist($content); + $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->flush(); + + $client->request('GET', '/view/'.$content->getId()); + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + $client->request('GET', '/delete/'.$content->getId()); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $client->followRedirect(); + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + } + public function testViewOtherUserEntry() { $this->logInAs('admin');