diff options
| author | 2025-03-22 23:17:52 +0100 | |
|---|---|---|
| committer | 2025-03-22 23:17:52 +0100 | |
| commit | 64bbb42553c925ebf7177945d048c18675188584 (patch) | |
| tree | e9f11e54b44512628304bcd83a1f6f418529099f /tests | |
| parent | 72ad6e528cc7d65d4d4f401a705cd9e2e6183c1a (diff) | |
Fix CLI flag parsing (#7430)
* Fix CLI flag parsing
fix https://github.com/FreshRSS/FreshRSS/issues/7428
* Fix other places
* Forgotten debugging
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cli/CliOptionsParserTest.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/cli/CliOptionsParserTest.php b/tests/cli/CliOptionsParserTest.php index 7aa9cdac3..6a67fa761 100644 --- a/tests/cli/CliOptionsParserTest.php +++ b/tests/cli/CliOptionsParserTest.php @@ -15,6 +15,7 @@ final class CliOptionsOptionalTest extends CliOptionsParser { public string $optionalValue = ''; public bool $optionalValueWithDefault = false; public string $defaultInputAndOptionalValueWithDefault = ''; + public bool $flag = false; public function __construct() { $this->addOption('string', (new CliOption('string', 's'))->deprecatedAs('deprecated-string')); @@ -38,7 +39,7 @@ final class CliOptionsOptionalAndRequiredTest extends CliOptionsParser { public string $string = ''; public int $int = 0; public bool $bool = false; - public string $flag = ''; + public bool $flag = false; public function __construct() { $this->addRequiredOption('required', new CliOption('required')); @@ -160,6 +161,16 @@ class CliOptionsParserTest extends TestCase { self::assertSame('optional', $result->defaultInputAndOptionalValueWithDefault); } + public static function testOptionWithFlag(): void { + $result = self::runOptionalOptions('--flag'); + self::assertTrue($result->flag); + } + + public static function testOptionWithNoFlag(): void { + $result = self::runOptionalOptions(''); + self::assertFalse($result->flag); + } + public static function testRequiredOptionNotSetReturnsError(): void { $result = self::runOptionalAndRequiredOptions(''); self::assertSame(['required' => 'invalid input: required cannot be empty'], $result->errors); |
