]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
Entry data should have unique url
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Tests / Controller / EntryControllerTest.php
index 0bd7d4fe66de9d09076b0842a9bbc783c9a27d77..af62aee8d85f80fd2d1018a858cc14677583bf5e 100644 (file)
@@ -75,7 +75,7 @@ class EntryControllerTest extends WallabagCoreTestCase
     }
 
     /**
-     * This test will require an internet connection
+     * This test will require an internet connection.
      */
     public function testPostNewOk()
     {
@@ -102,6 +102,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');