diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-12-16 05:15:19 +0300 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-12-16 05:15:19 +0300 |
commit | 6775356fac499e3f56e70d170d91750dd20ce314 (patch) | |
tree | a88da10e7b6c9f4543c167d6d790100176e9d4a4 /plugins/UsersManager/tests/Integration/APITest.php | |
parent | 6156633bf22de4e336dd459c7f5e10d6f136a33c (diff) |
New method getAllUsersPreferences and test
Diffstat (limited to 'plugins/UsersManager/tests/Integration/APITest.php')
-rw-r--r-- | plugins/UsersManager/tests/Integration/APITest.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/plugins/UsersManager/tests/Integration/APITest.php b/plugins/UsersManager/tests/Integration/APITest.php index 1cf2cf71bb..67a6e9f12e 100644 --- a/plugins/UsersManager/tests/Integration/APITest.php +++ b/plugins/UsersManager/tests/Integration/APITest.php @@ -69,4 +69,43 @@ class APITest extends IntegrationTestCase $this->assertFalse($eventTriggered, 'UsersManager.removeSiteAccess event was triggered but should not'); } + public function test_getAllUsersPreferences_isEmpty_whenNoPreference() + { + $preferences = $this->api->getAllUsersPreferences(array('preferenceName')); + $this->assertEmpty($preferences); + } + + public function test_getAllUsersPreferences_isEmpty_whenNoPreferenceAndMultipleRequested() + { + $preferences = $this->api->getAllUsersPreferences(array('preferenceName', 'otherOne')); + $this->assertEmpty($preferences); + } + + public function test_getAllUsersPreferences_shouldGetMultiplePreferences() + { + $user2 = 'userLogin2'; + $user3 = 'userLogin3'; + $this->api->addUser($user2, 'password', 'userlogin2@password.de'); + $this->api->setUserPreference($user2, 'myPreferenceName', 'valueForUser2'); + $this->api->setUserPreference($user2, 'Random_NOT_REQUESTED', 'Random_NOT_REQUESTED'); + + $this->api->addUser($user3, 'password', 'userlogin3@password.de'); + $this->api->setUserPreference($user3, 'myPreferenceName', 'valueForUser3'); + $this->api->setUserPreference($user3, 'otherPreferenceHere', 'otherPreferenceVALUE'); + $this->api->setUserPreference($user3, 'Random_NOT_REQUESTED', 'Random_NOT_REQUESTED'); + + $expected = array( + $user2 => array( + 'myPreferenceName' => 'valueForUser2' + ), + $user3 => array( + 'myPreferenceName' => 'valueForUser3', + 'otherPreferenceHere' => 'otherPreferenceVALUE', + ), + ); + $result = $this->api->getAllUsersPreferences(array('myPreferenceName', 'otherPreferenceHere', 'randomDoesNotExist')); + + $this->assertSame($expected, $result); + } + } |