Skip to content

Commit

Permalink
unit test for unique_identifier_field lostpassword form
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewandante committed Jan 28, 2025
1 parent 194bcbe commit 8798fa1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/php/Security/MemberTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,6 @@
delocalemember:
Email: [email protected]
Locale: de_DE
username-member:
Email: [email protected]
Username: username1234
22 changes: 22 additions & 0 deletions tests/php/Security/SecurityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,28 @@ public function testChangePasswordForLoggedInUsers()
$this->assertEquals($this->idFromFixture(Member::class, 'test'), $this->session()->get('loggedInAs'));
}

public function testLostPasswordFormWithUniqueFieldIdentifier()
{
// override the unique identifier field
Member::config()->set('unique_identifier_field', 'Username');

/** @var Member $admin */
$member = $this->objFromFixture(Member::class, 'username-member');
$member->FailedLoginCount = 99;
$member->LockedOutUntil = DBDatetime::now()->getValue();
$member->write();

// load lostpassword form
$this->get('Security/lostpassword');
$labelElement = $this->cssParser()->getBySelector('#LostPasswordForm_lostPasswordForm_Email_Holder > label');

$this->assertEquals(1, count($labelElement ?? []));
$this->assertStringContainsString(
'<label class="left" for="LostPasswordForm_lostPasswordForm_Email">Username</label>',
(string)$labelElement[0]->asXML()
);
}

public function testChangePasswordFromLostPassword()
{
/** @var Member $admin */
Expand Down

0 comments on commit 8798fa1

Please sign in to comment.