Skip to content

Commit 8d1e7b3

Browse files
committed
refactoring
- set empty path for app_forgot_password_request route - add tests for all routes - minor cs issues
1 parent 5a4d25f commit 8d1e7b3

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(ResetPasswordHelperInterface $resetPasswordHelper)
3535
/**
3636
* Display & process form to request a password reset.
3737
*
38-
* @Route(name="app_forgot_password_request")
38+
* @Route("", name="app_forgot_password_request")
3939
*/
4040
public function request(Request $request, MailerInterface $mailer): Response
4141
{

tests/fixtures/MakeResetPassword/src/Entity/User.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
class User implements UserInterface
88
{
9-
109
private $email;
1110

1211
public function getEmail()

tests/fixtures/MakeResetPasswordFunctionalTest/src/Entity/User.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
class User implements UserInterface
88
{
9-
109
private $email;
1110

1211
public function getEmail()

tests/fixtures/MakeResetPasswordFunctionalTest/tests/ResetPasswordFunctionalTest.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,32 @@
22

33
namespace App\Tests;
44

5-
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
65
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
76

87
class ResetPasswordFunctionalTest extends WebTestCase
98
{
10-
public function testResetPassword()
9+
public function testResetRequestRoute()
1110
{
1211
$client = static::createClient();
1312
$client->request('GET', '/reset-password');
1413

1514
$this->assertSame(200, $client->getResponse()->getStatusCode());
1615
}
16+
17+
public function testResetRequestRouteDeniesInvalidToken()
18+
{
19+
$client = static::createClient();
20+
$client->request('GET', '/reset-password/reset/badToken1234');
21+
22+
$this->assertSame(302, $client->getResponse()->getStatusCode());
23+
}
24+
25+
public function testCheckEmailRouteRedirectsToRequestRouteIfUserNotAllowedToCheckEmail()
26+
{
27+
$client = static::createClient();
28+
$client->request('GET', '/reset-password/check-email');
29+
30+
$this->assertSame(302, $client->getResponse()->getStatusCode());
31+
$this->assertResponseRedirects('/reset-password');
32+
}
1733
}

0 commit comments

Comments
 (0)