forked from mautic/mautic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
13730: Fixing "Error when creating a user without password" (mautic#1…
…4107) * 13730: Fixing "Error when creating a user without password" * 13730-Added more coverage
- Loading branch information
1 parent
f346a80
commit 93db721
Showing
2 changed files
with
116 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,112 @@ public function testEditActionFormSubmissionInvalid(): void | |
$this->assertStringContainsString('The email entered is invalid.', $this->client->getResponse()->getContent()); | ||
} | ||
|
||
/** | ||
* @param array<string, string> $data | ||
* | ||
* @dataProvider dataNewUserForPasswordField | ||
*/ | ||
public function testNewUserForPasswordField(array $data, string $message): void | ||
{ | ||
$crawler = $this->client->request('GET', '/s/users/new'); | ||
|
||
$formData = [ | ||
'user[firstName]' => 'John', | ||
'user[lastName]' => 'Doe', | ||
'user[email]' => '[email protected]', | ||
]; | ||
|
||
$form = $crawler->selectButton('Save')->form($formData + $data); | ||
|
||
$this->client->submit($form); | ||
|
||
$this->assertSame(Response::HTTP_OK, $this->client->getResponse()->getStatusCode()); | ||
$this->assertStringContainsString($message, $this->client->getResponse()->getContent()); | ||
} | ||
|
||
/** | ||
* @return iterable<string, array<int, string|array<string, string>>> | ||
*/ | ||
public function dataNewUserForPasswordField(): iterable | ||
{ | ||
yield 'Blank' => [ | ||
[ | ||
'user[plainPassword][password]' => '', | ||
'user[plainPassword][confirm]' => '', | ||
], | ||
'Password cannot be blank.', | ||
]; | ||
|
||
yield 'Do not match with confirm' => [ | ||
[ | ||
'user[plainPassword][password]' => 'same', | ||
], | ||
'Passwords do not match.', | ||
]; | ||
|
||
yield 'Minimum length' => [ | ||
[ | ||
'user[plainPassword][password]' => 'same', | ||
'user[plainPassword][confirm]' => 'same', | ||
], | ||
'Password must be at least 6 characters.', | ||
]; | ||
|
||
yield 'No stronger' => [ | ||
[ | ||
'user[plainPassword][password]' => 'same123', | ||
'user[plainPassword][confirm]' => 'same123', | ||
], | ||
'Please enter a stronger password. Your password must use a combination of upper and lower case, special characters and numbers.', | ||
]; | ||
} | ||
|
||
/** | ||
* @param array<string, string> $data | ||
* | ||
* @dataProvider dataForEditUserForPasswordField | ||
*/ | ||
public function testEditUserForPasswordField(array $data, string $message): void | ||
{ | ||
$crawler = $this->client->request('GET', '/s/users/edit/1'); | ||
|
||
$form = $crawler->selectButton('Save')->form($data); | ||
|
||
$this->client->submit($form); | ||
|
||
$this->assertSame(Response::HTTP_OK, $this->client->getResponse()->getStatusCode()); | ||
$this->assertStringContainsString($message, $this->client->getResponse()->getContent()); | ||
} | ||
|
||
/** | ||
* @return iterable<string, array<int, string|array<string, string>>> | ||
*/ | ||
public function dataForEditUserForPasswordField(): iterable | ||
{ | ||
yield 'Do not match with confirm' => [ | ||
[ | ||
'user[plainPassword][password]' => 'same', | ||
], | ||
'Passwords do not match.', | ||
]; | ||
|
||
yield 'Minimum length' => [ | ||
[ | ||
'user[plainPassword][password]' => 'same', | ||
'user[plainPassword][confirm]' => 'same', | ||
], | ||
'Password must be at least 6 characters.', | ||
]; | ||
|
||
yield 'No stronger' => [ | ||
[ | ||
'user[plainPassword][password]' => 'same123', | ||
'user[plainPassword][confirm]' => 'same123', | ||
], | ||
'Please enter a stronger password. Your password must use a combination of upper and lower case, special characters and numbers.', | ||
]; | ||
} | ||
|
||
/** | ||
* @param array<mixed> $details | ||
*/ | ||
|