Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Memorekall Member New
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rekall
Memorekall Member New
Commits
b993b5f8
Commit
b993b5f8
authored
Dec 13, 2021
by
Camille Simiand
Browse files
Options
Downloads
Patches
Plain Diff
Add email tests
parent
9080ad06
No related branches found
No related tags found
1 merge request
!23
Tuleap 47 reset my password
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/functional/ResetPasswordControllerTest.php
+52
-0
52 additions, 0 deletions
tests/functional/ResetPasswordControllerTest.php
with
52 additions
and
0 deletions
tests/functional/ResetPasswordControllerTest.php
0 → 100644
+
52
−
0
View file @
b993b5f8
<?php
namespace
App\Tests\Controller
;
use
Symfony\Bundle\FrameworkBundle\KernelBrowser
;
use
Symfony\Bundle\FrameworkBundle\Test\WebTestCase
;
use
Symfony\Component\DomCrawler\Form
;
class
ResetPasswordControllerTest
extends
WebTestCase
{
private
KernelBrowser
$client
;
private
Form
$form
;
private
const
VERIFIED_USER_EMAIL
=
'defaultUser@localhost.com'
;
private
const
UNVERIFIED_USER_EMAIL
=
'notRegistered@localhost.com'
;
protected
function
setUp
():
void
{
$this
->
client
=
static
::
createClient
();
$crawler
=
$this
->
client
->
request
(
'GET'
,
'/reset-password'
);
$this
->
assertResponseIsSuccessful
();
$this
->
client
->
enableProfiler
();
$submit_button
=
$crawler
->
selectButton
(
'Reset password'
);
$this
->
form
=
$submit_button
->
form
();
}
public
function
testVerifiedUserShouldReceiveAnEmailLinkToResetHisPassword
():
void
{
$this
->
form
[
'reset_password_request_form[email]'
]
=
self
::
VERIFIED_USER_EMAIL
;
$this
->
client
->
submit
(
$this
->
form
);
$emailMessage
=
$this
->
getMailerMessage
(
0
);
$this
->
assertEmailCount
(
1
,
null
);
$this
->
assertEmailTextBodyContains
(
$emailMessage
,
'To reset your password, please visit the following link'
);
$this
->
assertEmailAddressContains
(
$emailMessage
,
'To'
,
self
::
VERIFIED_USER_EMAIL
,
'When resetting a password, an already registered user should receive an email with the reset password link'
);
}
public
function
testUnverifiedUserShouldNotReceiveAnEmailLinkToResetHisPassword
():
void
{
$this
->
form
[
'reset_password_request_form[email]'
]
=
self
::
UNVERIFIED_USER_EMAIL
;
$this
->
client
->
submit
(
$this
->
form
);
$this
->
assertEmailCount
(
0
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment