summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2017-02-15 18:14:29 +0100
committerMorris Jobke <hey@morrisjobke.de>2017-03-20 02:03:03 -0600
commitaacfef463c07f6a1cacfd4b2c014ba582f4811de (patch)
treea7350be5ff3e8a79b68d2d1990c3e205233d5f8a /tests/lib
parent592c04a9db83c27df8155ae97c6693fe2170e543 (diff)
downloadnextcloud-server-aacfef463c07f6a1cacfd4b2c014ba582f4811de.tar.gz
nextcloud-server-aacfef463c07f6a1cacfd4b2c014ba582f4811de.zip
Add tests for database user backend caching
Add comment, closeCursor in user DB query Invalidate user in cache after successful creation Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/User/DatabaseTest.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/lib/User/DatabaseTest.php b/tests/lib/User/DatabaseTest.php
index d7e4b9256cb..0e6900651cd 100644
--- a/tests/lib/User/DatabaseTest.php
+++ b/tests/lib/User/DatabaseTest.php
@@ -87,7 +87,7 @@ class DatabaseTest extends Backend {
$this->eventDispatcher->expects($this->once())->method('dispatch')
->willReturnCallback(
function ($eventName, GenericEvent $event) {
- $this->assertSame('OCP\PasswordPolicy::validate', $eventName);
+ $this->assertSame('OCP\PasswordPolicy::validate', $eventName);
$this->assertSame('newpass', $event->getSubject());
throw new HintException('password change failed', 'password change failed');
}
@@ -96,4 +96,21 @@ class DatabaseTest extends Backend {
$this->backend->setPassword($user, 'newpass');
$this->assertSame($user, $this->backend->checkPassword($user, 'newpass'));
}
+
+ public function testCreateUserInvalidatesCache() {
+ $user1 = $this->getUniqueID('test_');
+ $this->assertFalse($this->backend->userExists($user1));
+ $this->backend->createUser($user1, 'pw');
+ $this->assertTrue($this->backend->userExists($user1));
+ }
+
+ public function testDeleteUserInvalidatesCache() {
+ $user1 = $this->getUniqueID('test_');
+ $this->backend->createUser($user1, 'pw');
+ $this->assertTrue($this->backend->userExists($user1));
+ $this->backend->deleteUser($user1);
+ $this->assertFalse($this->backend->userExists($user1));
+ $this->backend->createUser($user1, 'pw2');
+ $this->assertTrue($this->backend->userExists($user1));
+ }
}