Skip to content

Commit

Permalink
test(settings): Correctly only return bool for Symfony Input::hasPara…
Browse files Browse the repository at this point in the history
…meterOption calls

Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Oct 7, 2024
1 parent e6cd105 commit 315e465
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions tests/Core/Command/User/SettingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,16 @@ public function testCheckInput($arguments, $options, $parameterOptions, $user, $
->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())
Expand Down Expand Up @@ -401,15 +410,16 @@ public function testExecuteGet($value, $defaultValue, $expectedLine, $expectedRe
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')
Expand Down

0 comments on commit 315e465

Please sign in to comment.