Skip to content

Commit 140c1e7

Browse files
committed
Look users up with capitals in the unit tests, so lower-casing is pinned (#574)
1 parent 1e34ea3 commit 140c1e7

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

‎tests/Repository/User/FindUserByUsernameTraitTest.php‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@
2222
final class FindUserByUsernameTraitTest extends TestCase
2323
{
2424
/**
25-
* @return iterable<string, array{string, bool}>
25+
* @return iterable<string, array{string, string, bool}>
2626
*/
2727
public static function usernames(): iterable
2828
{
29-
yield 'the username' => ['my_username', true];
30-
yield 'the username in capitals with surrounding space' => [' MY_USERNAME ', true];
31-
yield 'the email address the identifier also matches' => ['user@example.com', false];
29+
yield 'the username' => ['my_username', 'my_username', true];
30+
yield 'the username in capitals with surrounding space' => ['my_username', ' MY_USERNAME ', true];
31+
yield 'a username stored in capitals' => ['My_Username', 'my_username', true];
32+
yield 'the email address the identifier also matches' => ['my_username', 'user@example.com', false];
3233
}
3334

3435
#[DataProvider('usernames')]
35-
public function test_only_the_users_own_username_finds_them(string $username, bool $found): void
36+
public function test_only_the_users_own_username_finds_them(string $storedUsername, string $username, bool $found): void
3637
{
37-
$user = new User('my_username', 'user@example.com');
38+
$user = new User($storedUsername, 'user@example.com');
3839
$repository = $this->createStub(UserRepositoryInterface::class);
3940
$repository->method('loadUserByIdentifier')->willReturn($user);
4041

‎tests/Repository/User/UserRepositoryTest.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public static function lookupsWithSurroundingSpace(): iterable
2525
{
2626
yield 'a username identifier' => [static fn (UserRepository $repository) => $repository->loadUserByIdentifier(" My_Username \t")];
2727
yield 'an email address identifier' => [static fn (UserRepository $repository) => $repository->loadUserByIdentifier(' User@Example.com ')];
28-
yield 'a username through the deprecated loader' => [static fn (UserRepository $repository) => $repository->loadUserByUsername('my_username ')];
29-
yield 'an email address' => [static fn (UserRepository $repository) => $repository->findOneByEmail(' user@example.com ')];
30-
yield 'a username with a password reset token' => [static fn (UserRepository $repository) => $repository->findOneWithPasswordResetToken(' my_username ')];
31-
yield 'a username and new email address' => [static fn (UserRepository $repository) => $repository->findOneByUsernameAndNewEmailAddress(' my_username ', ' New@Example.com ')];
28+
yield 'a username through the deprecated loader' => [static fn (UserRepository $repository) => $repository->loadUserByUsername('MY_username ')];
29+
yield 'an email address' => [static fn (UserRepository $repository) => $repository->findOneByEmail(' User@Example.COM ')];
30+
yield 'a username with a password reset token' => [static fn (UserRepository $repository) => $repository->findOneWithPasswordResetToken(' My_Username ')];
31+
yield 'a username and new email address' => [static fn (UserRepository $repository) => $repository->findOneByUsernameAndNewEmailAddress(' My_Username ', ' New@Example.com ')];
3232
}
3333

3434
#[DataProvider('lookupsWithSurroundingSpace')]

0 commit comments

Comments
 (0)