From 879237f32ac4af820fddd2d07ca342000f5723eb Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 5 Jun 2014 11:49:13 +0200 Subject: Add method to get users by their preference --- tests/lib/preferences.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/lib/preferences.php b/tests/lib/preferences.php index 499be914fb7..a4259a8f349 100644 --- a/tests/lib/preferences.php +++ b/tests/lib/preferences.php @@ -221,6 +221,22 @@ class Test_Preferences_Object extends PHPUnit_Framework_TestCase { $this->assertEquals('someothervalue', $values['AnotherUser']); } + public function testGetValueUsers() + { + // Prepare data + $query = \OC_DB::prepare('INSERT INTO `*PREFIX*preferences` VALUES(?, ?, ?, ?)'); + $query->execute(array('SomeUser', 'testGetUsersForValue', 'somekey', 'somevalue')); + $query->execute(array('AnotherUser', 'testGetUsersForValue', 'somekey', 'someothervalue')); + $query->execute(array('AUser', 'testGetUsersForValue', 'somekey', 'somevalue')); + + $preferences = new OC\Preferences(\OC_DB::getConnection()); + $this->assertEquals(array('SomeUser', 'AUser'), $preferences->getUsersForValue('testGetUsersForValue', 'somekey', 'somevalue')); + + // Clean DB after the test + $query = \OC_DB::prepare('DELETE FROM `*PREFIX*preferences` WHERE `appid` = ?'); + $query->execute(array('testGetUsersForValue')); + } + public function testDeleteKey() { $connectionMock = $this->getMock('\OC\DB\Connection', array(), array(), '', false); -- cgit v1.2.3