diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-03-06 21:53:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-06 21:53:37 +0100 |
commit | de56915605ed1b714b7d9e6320e22c71da5379fd (patch) | |
tree | b157420938df9c4f40fe16c2a0b1815c6a950ba6 /tests/lib/User | |
parent | c88112bb419e0dd8d640a445dd83cb3305b8481f (diff) | |
parent | 42b3aa3a0a9098a2810ded6f0e0e359a3c9e3337 (diff) | |
download | nextcloud-server-de56915605ed1b714b7d9e6320e22c71da5379fd.tar.gz nextcloud-server-de56915605ed1b714b7d9e6320e22c71da5379fd.zip |
Merge pull request #7419 from Abijeet/feature-7175
Fixes #7175 - Allow to search for email address in user management
Diffstat (limited to 'tests/lib/User')
-rw-r--r-- | tests/lib/User/Backend.php | 12 | ||||
-rw-r--r-- | tests/lib/User/DatabaseTest.php | 36 |
2 files changed, 46 insertions, 2 deletions
diff --git a/tests/lib/User/Backend.php b/tests/lib/User/Backend.php index 85ccbac913c..1c7d482c480 100644 --- a/tests/lib/User/Backend.php +++ b/tests/lib/User/Backend.php @@ -103,15 +103,23 @@ abstract class Backend extends \Test\TestCase { $name1 = 'foobarbaz'; $name2 = 'bazbarfoo'; $name3 = 'notme'; + $name4 = 'under_score'; $this->backend->createUser($name1, 'pass1'); $this->backend->createUser($name2, 'pass2'); $this->backend->createUser($name3, 'pass3'); + $this->backend->createUser($name4, 'pass4'); $result = $this->backend->getUsers('bar'); - $this->assertSame(2, count($result)); + $this->assertCount(2, $result); $result = $this->backend->getDisplayNames('bar'); - $this->assertSame(2, count($result)); + $this->assertCount(2, $result); + + $result = $this->backend->getUsers('under_'); + $this->assertCount(1, $result); + + $result = $this->backend->getUsers('not_'); + $this->assertCount(0, $result); } } diff --git a/tests/lib/User/DatabaseTest.php b/tests/lib/User/DatabaseTest.php index 0e6900651cd..a6fb8047a98 100644 --- a/tests/lib/User/DatabaseTest.php +++ b/tests/lib/User/DatabaseTest.php @@ -24,6 +24,7 @@ namespace Test\User; use OC\HintException; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\GenericEvent; +use OC\User\User; /** * Class DatabaseTest @@ -113,4 +114,39 @@ class DatabaseTest extends Backend { $this->backend->createUser($user1, 'pw2'); $this->assertTrue($this->backend->userExists($user1)); } + + public function testSearch() { + parent::testSearch(); + + $user1 = $this->getUser(); + $this->backend->createUser($user1, 'pass1'); + + $user2 = $this->getUser(); + $this->backend->createUser($user2, 'pass1'); + + $user1Obj = new User($user1, $this->backend); + $user2Obj = new User($user2, $this->backend); + $emailAddr1 = "$user1@nextcloud.com"; + $emailAddr2 = "$user2@nextcloud.com"; + + $user1Obj->setDisplayName('User 1 Display'); + + $result = $this->backend->getDisplayNames('display'); + $this->assertCount(1, $result); + + $result = $this->backend->getDisplayNames(strtoupper($user1)); + $this->assertCount(1, $result); + + $user1Obj->setEMailAddress($emailAddr1); + $user2Obj->setEMailAddress($emailAddr2); + + $result = $this->backend->getUsers('@nextcloud.com'); + $this->assertCount(2, $result); + + $result = $this->backend->getDisplayNames('@nextcloud.com'); + $this->assertCount(2, $result); + + $result = $this->backend->getDisplayNames('@nextcloud.COM'); + $this->assertCount(2, $result); + } } |