summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-12-20 15:51:37 +0100
committerRobin Appelman <robin@icewind.nl>2017-12-20 15:51:37 +0100
commitaad01894e38ff77781934c16b75dac43d49ec74a (patch)
tree2ee2e3354bf6987eea6dfb19a801cb6ac2987d6a /tests
parentac14d02e1e23d8e31e11ed9729285d7fc5924543 (diff)
downloadnextcloud-server-aad01894e38ff77781934c16b75dac43d49ec74a.tar.gz
nextcloud-server-aad01894e38ff77781934c16b75dac43d49ec74a.zip
refactor user searching
add additional user searching tests Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/DB/QueryBuilder/FunctionBuilderTest.php10
-rw-r--r--tests/lib/User/Backend.php12
-rw-r--r--tests/lib/User/DatabaseTest.php15
3 files changed, 33 insertions, 4 deletions
diff --git a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
index e89da0fbc92..869faccc5cc 100644
--- a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
@@ -79,4 +79,14 @@ class FunctionBuilderTest extends TestCase {
$this->assertEquals('oobar', $query->execute()->fetchColumn());
}
+
+ public function testLower() {
+ $query = $this->connection->getQueryBuilder();
+
+ $query->select($query->func()->lower($query->createNamedParameter('FooBar')));
+ $query->from('appconfig')
+ ->setMaxResults(1);
+
+ $this->assertEquals('foobar', $query->execute()->fetchColumn());
+ }
}
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 a1e77dc128d..a6fb8047a98 100644
--- a/tests/lib/User/DatabaseTest.php
+++ b/tests/lib/User/DatabaseTest.php
@@ -129,13 +129,24 @@ class DatabaseTest extends 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->assertSame(2, count($result));
+ $this->assertCount(2, $result);
$result = $this->backend->getDisplayNames('@nextcloud.com');
- $this->assertSame(2, count($result));
+ $this->assertCount(2, $result);
+
+ $result = $this->backend->getDisplayNames('@nextcloud.COM');
+ $this->assertCount(2, $result);
}
}