summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/tests/ConfigurationTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/tests/ConfigurationTest.php')
-rw-r--r--apps/user_ldap/tests/ConfigurationTest.php45
1 files changed, 42 insertions, 3 deletions
diff --git a/apps/user_ldap/tests/ConfigurationTest.php b/apps/user_ldap/tests/ConfigurationTest.php
index 797d2598be4..ab1312860fa 100644
--- a/apps/user_ldap/tests/ConfigurationTest.php
+++ b/apps/user_ldap/tests/ConfigurationTest.php
@@ -23,7 +23,16 @@
namespace OCA\User_LDAP\Tests;
+use OCA\User_LDAP\Configuration;
+
class ConfigurationTest extends \Test\TestCase {
+ /** @var Configuration */
+ protected $configuration;
+
+ public function setUp() {
+ parent::setUp();
+ $this->configuration = new Configuration('t01', false);
+ }
public function configurationDataProvider() {
$inputWithDN = array(
@@ -84,6 +93,10 @@ class ConfigurationTest extends \Test\TestCase {
// default behaviour, one case is enough, special needs must be tested
// individually
'set string value' => array('ldapHost', $inputString, $expectedString),
+
+ 'set avatar rule, default' => ['ldapUserAvatarRule', 'default', 'default'],
+ 'set avatar rule, none' => ['ldapUserAvatarRule', 'none', 'none'],
+ 'set avatar rule, data attribute' => ['ldapUserAvatarRule', 'data:jpegPhoto', 'data:jpegPhoto'],
);
}
@@ -91,10 +104,36 @@ class ConfigurationTest extends \Test\TestCase {
* @dataProvider configurationDataProvider
*/
public function testSetValue($key, $input, $expected) {
- $configuration = new \OCA\User_LDAP\Configuration('t01', false);
+ $this->configuration->setConfiguration([$key => $input]);
+ $this->assertSame($this->configuration->$key, $expected);
+ }
+
+ public function avatarRuleValueProvider() {
+ return [
+ ['none', []],
+ ['data:selfie', ['selfie']],
+ ['data:sELFie', ['selfie']],
+ ['data:', ['jpegphoto', 'thumbnailphoto']],
+ ['default', ['jpegphoto', 'thumbnailphoto']],
+ ['invalid#', ['jpegphoto', 'thumbnailphoto']],
+ ];
+ }
- $configuration->setConfiguration([$key => $input]);
- $this->assertSame($configuration->$key, $expected);
+ /**
+ * @dataProvider avatarRuleValueProvider
+ */
+ public function testGetAvatarAttributes($setting, $expected) {
+ $this->configuration->setConfiguration(['ldapUserAvatarRule' => $setting]);
+ $this->assertSame($expected, $this->configuration->getAvatarAttributes());
+ }
+
+ /**
+ * @dataProvider avatarRuleValueProvider
+ */
+ public function testResolveRule($setting, $expected) {
+ $this->configuration->setConfiguration(['ldapUserAvatarRule' => $setting]);
+ // so far the only thing that can get resolved :)
+ $this->assertSame($expected, $this->configuration->resolveRule('avatar'));
}
}