X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FTests%2FController%2FEntryControllerTest.php;h=32d6a57537e253088ff6feb31badfaab8e29eea1;hb=refs%2Fpull%2F1699%2Fhead;hp=3a77518245e068bbb985ff6cba5adbb20a2a2107;hpb=1930c19d8214c05ceefac5ac011a6b6e7e4a983d;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 3a775182..32d6a575 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -38,7 +38,7 @@ class EntryControllerTest extends WallabagCoreTestCase $form = $crawler->filter('button[type=submit]')->form(); $data = array( - 'entry[url]' => 'https://www.wallabag.org/blog/2016/01/08/wallabag-alpha1-v2', + 'entry[url]' => $this->url, ); $client->submit($form, $data); @@ -82,7 +82,7 @@ class EntryControllerTest extends WallabagCoreTestCase ->get('doctrine.orm.entity_manager'); $entry = $em ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUrl($this->url); + ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); $em->remove($entry); $em->flush(); } @@ -127,10 +127,35 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertEquals(302, $client->getResponse()->getStatusCode()); - $crawler = $client->followRedirect(); + $content = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); + + $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); + $this->assertEquals($this->url, $content->getUrl()); + $this->assertContains('Google', $content->getTitle()); + } + + public function testPostNewOkUrlExist() + { + $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]' => $this->url, + ); - $this->assertGreaterThan(1, $alert = $crawler->filter('h2 a')->extract(array('_text'))); - $this->assertContains('Google', $alert[0]); + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $this->assertContains('/view/', $client->getResponse()->getTargetUrl()); } /** @@ -202,7 +227,7 @@ class EntryControllerTest extends WallabagCoreTestCase $content = $client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUrl($this->url); + ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); $client->request('GET', '/view/'.$content->getId()); @@ -223,7 +248,7 @@ class EntryControllerTest extends WallabagCoreTestCase $content = $client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUrl($this->url); + ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); // empty content $content->setContent(''); @@ -237,7 +262,7 @@ class EntryControllerTest extends WallabagCoreTestCase $content = $client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUrl($this->url); + ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); $this->assertNotEmpty($content->getContent()); } @@ -250,7 +275,7 @@ class EntryControllerTest extends WallabagCoreTestCase $content = $client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUrl($this->url); + ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); $crawler = $client->request('GET', '/edit/'.$content->getId()); @@ -268,7 +293,7 @@ class EntryControllerTest extends WallabagCoreTestCase $content = $client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUrl($this->url); + ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); $crawler = $client->request('GET', '/edit/'.$content->getId()); @@ -298,7 +323,7 @@ class EntryControllerTest extends WallabagCoreTestCase $content = $client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUrl($this->url); + ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); $client->request('GET', '/archive/'.$content->getId()); @@ -320,7 +345,7 @@ class EntryControllerTest extends WallabagCoreTestCase $content = $client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUrl($this->url); + ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); $client->request('GET', '/star/'.$content->getId()); @@ -342,7 +367,7 @@ class EntryControllerTest extends WallabagCoreTestCase $content = $client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUrl($this->url); + ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); $client->request('GET', '/delete/'.$content->getId());