]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Add some tests 1152/head
authorJeremy <jeremy.benoist@gmail.com>
Sun, 8 Mar 2015 21:47:32 +0000 (22:47 +0100)
committerJeremy <jeremy.benoist@gmail.com>
Sun, 8 Mar 2015 21:47:32 +0000 (22:47 +0100)
src/Wallabag/CoreBundle/Controller/SecurityController.php
src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php

index 5007307afcafa26dbab50ec6082e79036a5314ca..fe511db5ce6100a853fb881e26c54548e4bb7782 100644 (file)
@@ -103,7 +103,7 @@ class SecurityController extends Controller
         $user = $this->getDoctrine()->getRepository('WallabagCoreBundle:User')->findOneByConfirmationToken($token);
 
         if (null === $user) {
-            $this->createNotFoundException(sprintf('No user found with token "%s"', $token));
+            throw $this->createNotFoundException(sprintf('No user found with token "%s"', $token));
         }
 
         $form = $this->createForm(new ResetPasswordType());
index e02c4d0533fe04614b6c014c414f724d7a9aa048..1dd05f89ba624fa83f5f03044b73fb379293cfe3 100644 (file)
@@ -134,4 +134,49 @@ class SecurityControllerTest extends WallabagTestCase
             );
         }
     }
+
+    public function testReset()
+    {
+        $client = $this->getClient();
+        $user = $client->getContainer()
+            ->get('doctrine.orm.entity_manager')
+            ->getRepository('WallabagCoreBundle:User')
+            ->findOneByEmail('bobby@wallabag.org');
+
+        $crawler = $client->request('GET', '/forgot-password/'.$user->getConfirmationToken());
+
+        $this->assertEquals(200, $client->getResponse()->getStatusCode());
+        $this->assertCount(2, $crawler->filter('input[type=password]'));
+        $this->assertCount(1, $form = $crawler->filter('button[type=submit]'));
+        $this->assertCount(1, $form);
+
+        $data = array(
+            'change_passwd[new_password][first]' => 'mypassword',
+            'change_passwd[new_password][second]' => 'mypassword',
+        );
+
+        $client->submit($form->form(), $data);
+
+        $this->assertEquals(302, $client->getResponse()->getStatusCode());
+        $this->assertContains('login', $client->getResponse()->headers->get('location'));
+    }
+
+    public function testResetBadToken()
+    {
+        $client = $this->getClient();
+
+        $client->request('GET', '/forgot-password/UIZOAU29UE902IEPZO');
+
+        $this->assertEquals(404, $client->getResponse()->getStatusCode());
+    }
+
+    public function testCheckEmailWithoutEmail()
+    {
+        $client = $this->getClient();
+
+        $client->request('GET', '/forgot-password/check-email');
+
+        $this->assertEquals(302, $client->getResponse()->getStatusCode());
+        $this->assertContains('forgot-password', $client->getResponse()->headers->get('location'));
+    }
 }