summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-10-16 09:14:25 +0200
committerGitHub <noreply@github.com>2018-10-16 09:14:25 +0200
commitad66b0f9ab010ee00d249d6f8512d30332e8a0af (patch)
tree335df48bf6b0cf335ee0f79965e8a129a7525055 /tests/lib
parentafaee648dd056d382adc2701dc487fc82fac49ea (diff)
parent2db26d87c444ba385850d63e8d27f3b759102cfe (diff)
downloadnextcloud-server-ad66b0f9ab010ee00d249d6f8512d30332e8a0af.tar.gz
nextcloud-server-ad66b0f9ab010ee00d249d6f8512d30332e8a0af.zip
Merge pull request #11830 from nextcloud/bugfix/9326/make_sure_usermanager_getByEmail_only_returns_IUser
filter null values for UserManager::getByEmail
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/User/ManagerTest.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php
index d2e48ffa538..e0b6aadf2ac 100644
--- a/tests/lib/User/ManagerTest.php
+++ b/tests/lib/User/ManagerTest.php
@@ -668,4 +668,37 @@ class ManagerTest extends TestCase {
$manager->get('foo')->delete();
$this->assertFalse($manager->userExists('foo'));
}
+
+ public function testGetByEmail() {
+ $config = $this->getMockBuilder(IConfig::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $config
+ ->expects($this->at(0))
+ ->method('getUsersForUserValue')
+ ->with('settings', 'email', 'test@example.com')
+ ->will($this->returnValue(['uid1', 'uid99', 'uid2']));
+
+ $backend = $this->createMock(\Test\Util\User\Dummy::class);
+ $backend->expects($this->at(0))
+ ->method('userExists')
+ ->with($this->equalTo('uid1'))
+ ->will($this->returnValue(true));
+ $backend->expects($this->at(1))
+ ->method('userExists')
+ ->with($this->equalTo('uid99'))
+ ->will($this->returnValue(false));
+ $backend->expects($this->at(2))
+ ->method('userExists')
+ ->with($this->equalTo('uid2'))
+ ->will($this->returnValue(true));
+
+ $manager = new \OC\User\Manager($config);
+ $manager->registerBackend($backend);
+
+ $users = $manager->getByEmail('test@example.com');
+ $this->assertCount(2, $users);
+ $this->assertEquals('uid1', $users[0]->getUID());
+ $this->assertEquals('uid2', $users[1]->getUID());
+ }
}