Completed
Push — master ( d156bb...f314d9 )
by
unknown
26:01 queued 13s
created
apps/user_ldap/tests/HelperTest.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -17,131 +17,131 @@
 block discarded – undo
17 17
  * @group DB
18 18
  */
19 19
 class HelperTest extends \Test\TestCase {
20
-	private IAppConfig&MockObject $appConfig;
21
-
22
-	private Helper $helper;
23
-
24
-	protected function setUp(): void {
25
-		parent::setUp();
26
-
27
-		$this->appConfig = $this->createMock(IAppConfig::class);
28
-		$this->helper = new Helper(
29
-			$this->appConfig,
30
-			Server::get(IDBConnection::class)
31
-		);
32
-	}
33
-
34
-	public function testGetServerConfigurationPrefixes(): void {
35
-		$this->appConfig->method('getKeys')
36
-			->with('user_ldap')
37
-			->willReturn([
38
-				'foo',
39
-				'ldap_configuration_active',
40
-				's1ldap_configuration_active',
41
-			]);
42
-
43
-		$this->appConfig->method('getValueArray')
44
-			->with('user_ldap', 'configuration_prefixes')
45
-			-> willReturnArgument(2);
46
-
47
-		$result = $this->helper->getServerConfigurationPrefixes(false);
48
-
49
-		$this->assertEquals(['', 's1'], $result);
50
-	}
51
-
52
-	public function testGetServerConfigurationPrefixesActive(): void {
53
-		$this->appConfig->method('getKeys')
54
-			->with('user_ldap')
55
-			->willReturn([
56
-				'foo',
57
-				'ldap_configuration_active',
58
-				's1ldap_configuration_active',
59
-			]);
60
-
61
-		$this->appConfig->method('getValueArray')
62
-			->with('user_ldap', 'configuration_prefixes')
63
-			-> willReturnArgument(2);
64
-
65
-		$this->appConfig->method('getValueString')
66
-			->willReturnCallback(function ($app, $key, $default) {
67
-				if ($key === 's1ldap_configuration_active') {
68
-					return '1';
69
-				}
70
-				return $default;
71
-			});
72
-
73
-		$result = $this->helper->getServerConfigurationPrefixes(true);
74
-
75
-		$this->assertEquals(['s1'], $result);
76
-	}
77
-
78
-	public function testGetServerConfigurationHostFromAppKeys(): void {
79
-		$this->appConfig->method('getKeys')
80
-			->with('user_ldap')
81
-			->willReturn([
82
-				'foo',
83
-				'ldap_host',
84
-				's1ldap_host',
85
-				's02ldap_host',
86
-				'ldap_configuration_active',
87
-				's1ldap_configuration_active',
88
-				's02ldap_configuration_active',
89
-			]);
90
-
91
-		$this->appConfig->method('getValueArray')
92
-			->with('user_ldap', 'configuration_prefixes')
93
-			-> willReturnArgument(2);
94
-
95
-		$this->appConfig->method('getValueString')
96
-			->willReturnCallback(function ($app, $key, $default) {
97
-				if ($key === 'ldap_host') {
98
-					return 'example.com';
99
-				}
100
-				if ($key === 's1ldap_host') {
101
-					return 'foo.bar.com';
102
-				}
103
-				return $default;
104
-			});
105
-
106
-		$result = $this->helper->getServerConfigurationHosts();
107
-
108
-		$this->assertEquals([
109
-			'' => 'example.com',
110
-			's1' => 'foo.bar.com',
111
-			's02' => '',
112
-		], $result);
113
-	}
114
-
115
-	public function testGetServerConfigurationHost(): void {
116
-		$this->appConfig
117
-			->expects(self::never())
118
-			->method('getKeys');
119
-
120
-		$this->appConfig->method('getValueArray')
121
-			->with('user_ldap', 'configuration_prefixes')
122
-			-> willReturn([
123
-				'',
124
-				's1',
125
-				's02',
126
-			]);
127
-
128
-		$this->appConfig->method('getValueString')
129
-			->willReturnCallback(function ($app, $key, $default) {
130
-				if ($key === 'ldap_host') {
131
-					return 'example.com';
132
-				}
133
-				if ($key === 's1ldap_host') {
134
-					return 'foo.bar.com';
135
-				}
136
-				return $default;
137
-			});
138
-
139
-		$result = $this->helper->getServerConfigurationHosts();
140
-
141
-		$this->assertEquals([
142
-			'' => 'example.com',
143
-			's1' => 'foo.bar.com',
144
-			's02' => '',
145
-		], $result);
146
-	}
20
+    private IAppConfig&MockObject $appConfig;
21
+
22
+    private Helper $helper;
23
+
24
+    protected function setUp(): void {
25
+        parent::setUp();
26
+
27
+        $this->appConfig = $this->createMock(IAppConfig::class);
28
+        $this->helper = new Helper(
29
+            $this->appConfig,
30
+            Server::get(IDBConnection::class)
31
+        );
32
+    }
33
+
34
+    public function testGetServerConfigurationPrefixes(): void {
35
+        $this->appConfig->method('getKeys')
36
+            ->with('user_ldap')
37
+            ->willReturn([
38
+                'foo',
39
+                'ldap_configuration_active',
40
+                's1ldap_configuration_active',
41
+            ]);
42
+
43
+        $this->appConfig->method('getValueArray')
44
+            ->with('user_ldap', 'configuration_prefixes')
45
+            -> willReturnArgument(2);
46
+
47
+        $result = $this->helper->getServerConfigurationPrefixes(false);
48
+
49
+        $this->assertEquals(['', 's1'], $result);
50
+    }
51
+
52
+    public function testGetServerConfigurationPrefixesActive(): void {
53
+        $this->appConfig->method('getKeys')
54
+            ->with('user_ldap')
55
+            ->willReturn([
56
+                'foo',
57
+                'ldap_configuration_active',
58
+                's1ldap_configuration_active',
59
+            ]);
60
+
61
+        $this->appConfig->method('getValueArray')
62
+            ->with('user_ldap', 'configuration_prefixes')
63
+            -> willReturnArgument(2);
64
+
65
+        $this->appConfig->method('getValueString')
66
+            ->willReturnCallback(function ($app, $key, $default) {
67
+                if ($key === 's1ldap_configuration_active') {
68
+                    return '1';
69
+                }
70
+                return $default;
71
+            });
72
+
73
+        $result = $this->helper->getServerConfigurationPrefixes(true);
74
+
75
+        $this->assertEquals(['s1'], $result);
76
+    }
77
+
78
+    public function testGetServerConfigurationHostFromAppKeys(): void {
79
+        $this->appConfig->method('getKeys')
80
+            ->with('user_ldap')
81
+            ->willReturn([
82
+                'foo',
83
+                'ldap_host',
84
+                's1ldap_host',
85
+                's02ldap_host',
86
+                'ldap_configuration_active',
87
+                's1ldap_configuration_active',
88
+                's02ldap_configuration_active',
89
+            ]);
90
+
91
+        $this->appConfig->method('getValueArray')
92
+            ->with('user_ldap', 'configuration_prefixes')
93
+            -> willReturnArgument(2);
94
+
95
+        $this->appConfig->method('getValueString')
96
+            ->willReturnCallback(function ($app, $key, $default) {
97
+                if ($key === 'ldap_host') {
98
+                    return 'example.com';
99
+                }
100
+                if ($key === 's1ldap_host') {
101
+                    return 'foo.bar.com';
102
+                }
103
+                return $default;
104
+            });
105
+
106
+        $result = $this->helper->getServerConfigurationHosts();
107
+
108
+        $this->assertEquals([
109
+            '' => 'example.com',
110
+            's1' => 'foo.bar.com',
111
+            's02' => '',
112
+        ], $result);
113
+    }
114
+
115
+    public function testGetServerConfigurationHost(): void {
116
+        $this->appConfig
117
+            ->expects(self::never())
118
+            ->method('getKeys');
119
+
120
+        $this->appConfig->method('getValueArray')
121
+            ->with('user_ldap', 'configuration_prefixes')
122
+            -> willReturn([
123
+                '',
124
+                's1',
125
+                's02',
126
+            ]);
127
+
128
+        $this->appConfig->method('getValueString')
129
+            ->willReturnCallback(function ($app, $key, $default) {
130
+                if ($key === 'ldap_host') {
131
+                    return 'example.com';
132
+                }
133
+                if ($key === 's1ldap_host') {
134
+                    return 'foo.bar.com';
135
+                }
136
+                return $default;
137
+            });
138
+
139
+        $result = $this->helper->getServerConfigurationHosts();
140
+
141
+        $this->assertEquals([
142
+            '' => 'example.com',
143
+            's1' => 'foo.bar.com',
144
+            's02' => '',
145
+        ], $result);
146
+    }
147 147
 }
Please login to merge, or discard this patch.