@@ -149,21 +149,6 @@ public function testGetClientRegistrationForNonExistingClient()
149149 $ this ->assertEquals ($ expected , $ actual );
150150 }
151151
152- /**
153- * @testdox BaseServerConfig should complain when asked to save ClientRegistration without origin
154- * @covers ::saveClientRegistration
155- */
156- public function testSaveClientRegistrationWithoutOrigin ()
157- {
158- $ this ->expectException (TypeError::class);
159- $ this ->expectExceptionMessage ('Too few arguments to function ' );
160-
161- $ configMock = $ this ->createMock (IConfig::class);
162- $ baseServerConfig = new BaseServerConfig ($ configMock );
163-
164- $ baseServerConfig ->saveClientRegistration ();
165- }
166-
167152 /**
168153 * @testdox BaseServerConfig should complain when asked to save ClientRegistration without client data
169154 * @covers ::saveClientRegistration
@@ -176,7 +161,7 @@ public function testSaveClientRegistrationWithoutClientData()
176161 $ configMock = $ this ->createMock (IConfig::class);
177162 $ baseServerConfig = new BaseServerConfig ($ configMock );
178163
179- $ baseServerConfig ->saveClientRegistration (self :: MOCK_ORIGIN );
164+ $ baseServerConfig ->saveClientRegistration ();
180165 }
181166
182167 /**
@@ -189,138 +174,22 @@ public function testSaveClientRegistrationForNewClient()
189174
190175 $ configMock ->expects ($ this ->once ())
191176 ->method ('getAppValue ' )
192- ->with (Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ))
193177 ->willReturnArgument (2 );
194178
195- $ expected = [
196- 'client_id ' => md5 (self ::MOCK_ORIGIN ),
197- 'client_name ' => self ::MOCK_ORIGIN ,
198- 'client_secret ' => md5 (self ::MOCK_RANDOM_BYTES ),
199- ];
200-
201- $ configMock ->expects ($ this ->exactly (2 ))
179+ $ configMock ->expects ($ this ->exactly (1 ))
202180 ->method ('setAppValue ' )
203181 ->willReturnMap ([
204182 // Using willReturnMap as withConsecutive is removed since PHPUnit 10
205- [Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ), json_encode ($ expected )],
206- [Application::APP_ID , 'client- ' . self ::MOCK_ORIGIN , json_encode ($ expected )]
207- ]);
208-
209- $ baseServerConfig = new BaseServerConfig ($ configMock );
210-
211- $ actual = $ baseServerConfig ->saveClientRegistration (self ::MOCK_ORIGIN , []);
212-
213- $ this ->assertEquals ($ expected , $ actual );
214- }
215-
216- /**
217- * @testdox BaseServerConfig should save ClientRegistration when asked to save ClientRegistration for existing client
218- * @covers ::saveClientRegistration
219- */
220- public function testSaveClientRegistrationForExistingClient ()
221- {
222- $ configMock = $ this ->createMock (IConfig::class);
223-
224- $ expected = [
225- 'client_id ' => md5 (self ::MOCK_ORIGIN ),
226- 'client_name ' => self ::MOCK_ORIGIN ,
227- 'client_secret ' => md5 (self ::MOCK_RANDOM_BYTES ),
228- 'redirect_uris ' => [self ::MOCK_REDIRECT_URI ],
229- ];
230-
231- $ configMock ->expects ($ this ->once ())
232- ->method ('getAppValue ' )
233- ->with (Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ))
234- ->willReturn (json_encode ($ expected ));
235-
236- $ configMock ->expects ($ this ->exactly (2 ))
237- ->method ('setAppValue ' )
238- ->willReturnMap ([
239- // Using willReturnMap as withConsecutive is deprecated since PHPUnit 10
240- [Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ), json_encode ($ expected )],
241- [Application::APP_ID , 'client- ' . self ::MOCK_ORIGIN , json_encode ($ expected )]
242- ]);
243-
244- $ baseServerConfig = new BaseServerConfig ($ configMock );
245-
246- $ actual = $ baseServerConfig ->saveClientRegistration (self ::MOCK_ORIGIN , []);
247-
248- $ this ->assertEquals ($ expected , $ actual );
249- }
250-
251- /**
252- * @testdox BaseServerConfig should save ClientRegistration when asked to save ClientRegistration for blocked client
253- * @covers ::saveClientRegistration
254- */
255- public function testSaveClientRegistrationForBlockedClient ()
256- {
257- $ configMock = $ this ->createMock (IConfig::class);
258-
259- $ expected = [
260- 'client_id ' => md5 (self ::MOCK_ORIGIN ),
261- 'client_name ' => self ::MOCK_ORIGIN ,
262- 'client_secret ' => md5 (self ::MOCK_RANDOM_BYTES ),
263- 'redirect_uris ' => [self ::MOCK_REDIRECT_URI ],
264- 'blocked ' => true ,
265- ];
266-
267- $ configMock ->expects ($ this ->once ())
268- ->method ('getAppValue ' )
269- ->with (Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ))
270- ->willReturn (json_encode ($ expected ));
271-
272- $ configMock ->expects ($ this ->exactly (2 ))
273- ->method ('setAppValue ' )
274- ->willReturnMap ([
275- // Using willReturnMap as withConsecutive is deprecated since PHPUnit 10
276- [Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ), json_encode ($ expected )],
277- [Application::APP_ID , 'client- ' . self ::MOCK_ORIGIN , json_encode ($ expected )]
278- ]);
279-
280- $ baseServerConfig = new BaseServerConfig ($ configMock );
281-
282- $ actual = $ baseServerConfig ->saveClientRegistration (self ::MOCK_ORIGIN , $ expected );
283-
284- $ this ->assertEquals ($ expected , $ actual );
285- }
286-
287- /**
288- * @testdox BaseServerConfig should always "blocked" to existing value when asked to save ClientRegistration for blocked client
289- * @covers ::saveClientRegistration
290- */
291- public function testSaveClientRegistrationSetsBlocked ()
292- {
293- $ configMock = $ this ->createMock (IConfig::class);
294-
295- $ expected = [
296- 'client_id ' => md5 (self ::MOCK_ORIGIN ),
297- 'client_name ' => self ::MOCK_ORIGIN ,
298- 'client_secret ' => md5 (self ::MOCK_RANDOM_BYTES ),
299- 'redirect_uris ' => [self ::MOCK_REDIRECT_URI ],
300- 'blocked ' => true ,
301- ];
302-
303- $ configMock ->expects ($ this ->once ())
304- ->method ('getAppValue ' )
305- ->with (Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ))
306- ->willReturn (json_encode ($ expected ));
307-
308- $ clientData = $ expected ;
309- $ clientData ['blocked ' ] = false ;
310-
311- $ configMock ->expects ($ this ->exactly (2 ))
312- ->method ('setAppValue ' )
313- ->willReturnMap ([
314- // Using willReturnMap as withConsecutive is deprecated since PHPUnit 10
315- [Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ), json_encode ($ expected )],
316- [Application::APP_ID , 'client- ' . self ::MOCK_ORIGIN , json_encode ($ expected )]
183+ [Application::APP_ID , 'client- ' . self ::MOCK_ORIGIN , json_encode ('{} ' )]
317184 ]);
318185
319186 $ baseServerConfig = new BaseServerConfig ($ configMock );
320187
321- $ actual = $ baseServerConfig ->saveClientRegistration (self :: MOCK_ORIGIN , $ clientData );
188+ $ actual = $ baseServerConfig ->saveClientRegistration ([] );
322189
323- $ this ->assertEquals ($ expected , $ actual );
190+ $ this ->assertArrayHasKey ('client_id ' , $ actual );
191+ $ this ->assertArrayHasKey ('client_secret ' , $ actual );
192+ $ this ->assertArrayHasKey ('client_name ' , $ actual );
324193 }
325194
326195 /**
0 commit comments