]> source.dussan.org Git - nextcloud-server.git/commitdiff
test(settings): Correctly only return bool for Symfony Input::hasParameterOption... dependabot/composer/stable30/symfony-6.4 48763/head
authorJoas Schilling <coding@schilljs.com>
Fri, 4 Oct 2024 14:24:22 +0000 (16:24 +0200)
committerJoas Schilling <coding@schilljs.com>
Mon, 21 Oct 2024 09:28:55 +0000 (11:28 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
tests/Core/Command/User/SettingTest.php

index 433348a8b9815b6e295c4ee12958b3d64f1a7ec6..4dd78708bbd8545af99ce4ed1f7f464d9912541a 100644 (file)
@@ -193,7 +193,16 @@ class SettingTest extends TestCase {
                        ->willReturnMap($options);
                $this->consoleInput->expects($this->any())
                        ->method('hasParameterOption')
-                       ->willReturnMap($parameterOptions);
+                       ->willReturnCallback(function (string|array $config, bool $default = false) use ($parameterOptions): bool {
+                               foreach ($parameterOptions as $parameterOption) {
+                                       if ($config === $parameterOption[0]
+                                               // Check the default value if the maps has 3 entries
+                                               && (!isset($parameterOption[2]) || $default === $parameterOption[1])) {
+                                               return end($parameterOption);
+                                       }
+                               }
+                               return false;
+                       });
 
                if ($user !== false) {
                        $this->userManager->expects($this->once())
@@ -401,15 +410,16 @@ class SettingTest extends TestCase {
                        if ($defaultValue === null) {
                                $this->consoleInput->expects($this->atLeastOnce())
                                        ->method('hasParameterOption')
-                                       ->willReturnMap([
-                                               ['--default-value', false],
-                                       ]);
+                                       ->willReturn(false);
                        } else {
                                $this->consoleInput->expects($this->atLeastOnce())
                                        ->method('hasParameterOption')
-                                       ->willReturnMap([
-                                               ['--default-value', false, true],
-                                       ]);
+                                       ->willReturnCallback(function (string|array $config, bool $default = false): bool {
+                                               if ($config === '--default-value' && $default === false) {
+                                                       return true;
+                                               }
+                                               return false;
+                                       });
                                $this->consoleInput->expects($this->once())
                                        ->method('getOption')
                                        ->with('default-value')