Skip to content

Commit d78a3a5

Browse files
committed
Added test for username autocompletion bug #689
1 parent fc61ec9 commit d78a3a5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

_test/types/UserTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,31 @@ public function test_ajax()
8484

8585
$INPUT->set('search', 'test');
8686
$this->assertEquals([], $user->handleAjax());
87+
88+
// Check that numeric usernames are handled properly; PHP's
89+
// strange handling of array keys that look like integers has
90+
// caused bugs with this in the past.
91+
global $auth;
92+
$auth->createUser('12345', 'secret_password', 'Some Person', 'someone@example.com');
93+
$auth->createUser('54321', 'another_password', 'Someone Else', 's.else@example.com');
94+
95+
$user = new User(
96+
[
97+
'autocomplete' => [
98+
'fullname' => true,
99+
'mininput' => 2,
100+
'maxresult' => 5,
101+
],
102+
]
103+
);
104+
105+
$INPUT->set('search', 'Some');
106+
$this->assertEquals(
107+
[
108+
['label' => 'Some Person [12345]', 'value' => '12345'],
109+
['label' => 'Someone Else [54321]', 'value' => '54321']
110+
],
111+
$user->handleAjax()
112+
);
87113
}
88114
}

0 commit comments

Comments
 (0)