aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJeremy <jeremy.benoist@gmail.com>2015-03-08 22:47:32 +0100
committerJeremy <jeremy.benoist@gmail.com>2015-03-08 22:47:32 +0100
commitd0c2243b1099303be961c9d4b33eaaa95e663bef (patch)
tree4c81979adefda73fea12bada41c3e40caef285eb /src
parent6894d48e03c397096bb64420373afa60c397fe97 (diff)
downloadwallabag-d0c2243b1099303be961c9d4b33eaaa95e663bef.tar.gz
wallabag-d0c2243b1099303be961c9d4b33eaaa95e663bef.tar.zst
wallabag-d0c2243b1099303be961c9d4b33eaaa95e663bef.zip
Add some tests
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Controller/SecurityController.php2
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php45
2 files changed, 46 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/SecurityController.php b/src/Wallabag/CoreBundle/Controller/SecurityController.php
index 5007307a..fe511db5 100644
--- a/src/Wallabag/CoreBundle/Controller/SecurityController.php
+++ b/src/Wallabag/CoreBundle/Controller/SecurityController.php
@@ -103,7 +103,7 @@ class SecurityController extends Controller
103 $user = $this->getDoctrine()->getRepository('WallabagCoreBundle:User')->findOneByConfirmationToken($token); 103 $user = $this->getDoctrine()->getRepository('WallabagCoreBundle:User')->findOneByConfirmationToken($token);
104 104
105 if (null === $user) { 105 if (null === $user) {
106 $this->createNotFoundException(sprintf('No user found with token "%s"', $token)); 106 throw $this->createNotFoundException(sprintf('No user found with token "%s"', $token));
107 } 107 }
108 108
109 $form = $this->createForm(new ResetPasswordType()); 109 $form = $this->createForm(new ResetPasswordType());
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
index e02c4d05..1dd05f89 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
@@ -134,4 +134,49 @@ class SecurityControllerTest extends WallabagTestCase
134 ); 134 );
135 } 135 }
136 } 136 }
137
138 public function testReset()
139 {
140 $client = $this->getClient();
141 $user = $client->getContainer()
142 ->get('doctrine.orm.entity_manager')
143 ->getRepository('WallabagCoreBundle:User')
144 ->findOneByEmail('bobby@wallabag.org');
145
146 $crawler = $client->request('GET', '/forgot-password/'.$user->getConfirmationToken());
147
148 $this->assertEquals(200, $client->getResponse()->getStatusCode());
149 $this->assertCount(2, $crawler->filter('input[type=password]'));
150 $this->assertCount(1, $form = $crawler->filter('button[type=submit]'));
151 $this->assertCount(1, $form);
152
153 $data = array(
154 'change_passwd[new_password][first]' => 'mypassword',
155 'change_passwd[new_password][second]' => 'mypassword',
156 );
157
158 $client->submit($form->form(), $data);
159
160 $this->assertEquals(302, $client->getResponse()->getStatusCode());
161 $this->assertContains('login', $client->getResponse()->headers->get('location'));
162 }
163
164 public function testResetBadToken()
165 {
166 $client = $this->getClient();
167
168 $client->request('GET', '/forgot-password/UIZOAU29UE902IEPZO');
169
170 $this->assertEquals(404, $client->getResponse()->getStatusCode());
171 }
172
173 public function testCheckEmailWithoutEmail()
174 {
175 $client = $this->getClient();
176
177 $client->request('GET', '/forgot-password/check-email');
178
179 $this->assertEquals(302, $client->getResponse()->getStatusCode());
180 $this->assertContains('forgot-password', $client->getResponse()->headers->get('location'));
181 }
137} 182}