diff options
| author | Frederic Guillot <fred@kanboard.net> | 2016-05-07 10:36:46 -0400 |
|---|---|---|
| committer | Frederic Guillot <fred@kanboard.net> | 2016-05-07 10:36:46 -0400 |
| commit | 94989663eca0d0dc2e9adb6d3190f0ab3cca9d2a (patch) | |
| tree | 3a3e529a34ccf0a8b6de623962a2319446c0f651 /tests/units/Core/User/UserPropertyTest.php | |
| parent | 400e230881bc71e052ee41da660ec5ff8dd3130d (diff) | |
User roles are now synced with LDAP at each login
Diffstat (limited to 'tests/units/Core/User/UserPropertyTest.php')
| -rw-r--r-- | tests/units/Core/User/UserPropertyTest.php | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/tests/units/Core/User/UserPropertyTest.php b/tests/units/Core/User/UserPropertyTest.php index 170eab4c..a2f052f4 100644 --- a/tests/units/Core/User/UserPropertyTest.php +++ b/tests/units/Core/User/UserPropertyTest.php @@ -31,7 +31,7 @@ class UserPropertyTest extends Base $this->assertEquals($expected, UserProperty::getProperties($user)); } - public function testFilterProperties() + public function testFilterPropertiesDoNotOverrideExistingValue() { $profile = array( 'id' => 123, @@ -57,4 +57,58 @@ class UserPropertyTest extends Base $this->assertEquals($expected, UserProperty::filterProperties($profile, $properties)); } + + public function testFilterPropertiesOverrideExistingValueWhenNecessary() + { + $profile = array( + 'id' => 123, + 'username' => 'bob', + 'name' => null, + 'email' => '', + 'other_column' => 'myvalue', + 'role' => Role::APP_USER, + ); + + $properties = array( + 'external_id' => '456', + 'username' => 'bobby', + 'name' => 'Bobby', + 'email' => 'admin@localhost', + 'role' => Role::APP_MANAGER, + ); + + $expected = array( + 'name' => 'Bobby', + 'email' => 'admin@localhost', + 'role' => Role::APP_MANAGER, + ); + + $this->assertEquals($expected, UserProperty::filterProperties($profile, $properties)); + } + + public function testFilterPropertiesDoNotOverrideSameValue() + { + $profile = array( + 'id' => 123, + 'username' => 'bob', + 'name' => 'Bobby', + 'email' => 'admin@example.org', + 'other_column' => 'myvalue', + 'role' => Role::APP_MANAGER, + ); + + $properties = array( + 'external_id' => '456', + 'username' => 'bobby', + 'name' => 'Bobby', + 'email' => 'admin@localhost', + 'role' => Role::APP_MANAGER, + ); + + $expected = array( + 'email' => 'admin@localhost', + ); + + $this->assertEquals($expected, UserProperty::filterProperties($profile, $properties)); + } } |
