@@ -250,17 +250,7 @@ public function testDeleteKey(): void {
250250
251251 $ this ->assertFalse ($ config ->hasKey ('testapp ' , 'deletethis ' ));
252252
253- $ sql = $ this ->connection ->getQueryBuilder ();
254- $ sql ->select ('configvalue ' )
255- ->from ('appconfig ' )
256- ->where ($ sql ->expr ()->eq ('appid ' , $ sql ->createParameter ('appid ' )))
257- ->andWhere ($ sql ->expr ()->eq ('configkey ' , $ sql ->createParameter ('configkey ' )))
258- ->setParameter ('appid ' , 'testapp ' )
259- ->setParameter ('configkey ' , 'deletethis ' );
260- $ query = $ sql ->executeQuery ();
261- $ result = $ query ->fetch ();
262- $ query ->closeCursor ();
263- $ this ->assertFalse ($ result );
253+ $ this ->assertFalse ($ this ->loadConfigValueFromDatabase ('testapp ' , 'deletethis ' ));
264254 }
265255
266256 public function testDeleteApp (): void {
@@ -396,7 +386,7 @@ public function testMigratingNonSensitiveValueToSensitiveOne(): void {
396386 $ this ->assertEquals ($ secret , $ actualSecret );
397387 }
398388
399- protected function assertConfigKey (string $ app , string $ key, string $ expected ): void {
389+ protected function loadConfigValueFromDatabase (string $ app , string $ key ): string | false {
400390 $ sql = $ this ->connection ->getQueryBuilder ();
401391 $ sql ->select ('configvalue ' )
402392 ->from ('appconfig ' )
@@ -405,24 +395,17 @@ protected function assertConfigKey(string $app, string $key, string $expected):
405395 ->setParameter ('appid ' , $ app )
406396 ->setParameter ('configkey ' , $ key );
407397 $ query = $ sql ->executeQuery ();
408- $ actual = $ query ->fetch ();
398+ $ actual = $ query ->fetchOne ();
409399 $ query ->closeCursor ();
410400
411- $ this -> assertEquals ( $ expected , $ actual[ ' configvalue ' ]) ;
401+ return $ actual ;
412402 }
413403
414- protected function assertConfigValueNotEquals (string $ app , string $ key , string $ expected ): void {
415- $ sql = $ this ->connection ->getQueryBuilder ();
416- $ sql ->select ('configvalue ' )
417- ->from ('appconfig ' )
418- ->where ($ sql ->expr ()->eq ('appid ' , $ sql ->createParameter ('appid ' )))
419- ->andWhere ($ sql ->expr ()->eq ('configkey ' , $ sql ->createParameter ('configkey ' )))
420- ->setParameter ('appid ' , $ app )
421- ->setParameter ('configkey ' , $ key );
422- $ query = $ sql ->executeQuery ();
423- $ actual = $ query ->fetch ();
424- $ query ->closeCursor ();
404+ protected function assertConfigKey (string $ app , string $ key , string |false $ expected ): void {
405+ $ this ->assertEquals ($ expected , $ this ->loadConfigValueFromDatabase ($ app , $ key ));
406+ }
425407
426- $ this ->assertNotEquals ($ expected , $ actual ['configvalue ' ]);
408+ protected function assertConfigValueNotEquals (string $ app , string $ key , string |false $ expected ): void {
409+ $ this ->assertNotEquals ($ expected , $ this ->loadConfigValueFromDatabase ($ app , $ key ));
427410 }
428411}
0 commit comments