diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-19 23:45:37 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-19 23:45:37 +0900 |
| commit | 0800c90a7ec0bc7a3d4c13063dfe6d2298a557bc (patch) | |
| tree | ba5602549ce20b8d71136423e85dffc25deafff4 /crates/shirabe/tests/command/global_command_test.rs | |
| parent | 6ed3a85dd636366d194c9810fd777db7f25e263f (diff) | |
| download | php-shirabe-0800c90a7ec0bc7a3d4c13063dfe6d2298a557bc.tar.gz php-shirabe-0800c90a7ec0bc7a3d4c13063dfe6d2298a557bc.tar.zst php-shirabe-0800c90a7ec0bc7a3d4c13063dfe6d2298a557bc.zip | |
fix(input): thread a typed InputValue through the input layer
Options and arguments were stored and passed as PhpMixed even though
Symfony only ever puts a string, a bool, a list of strings or null in
one. get_option already narrowed to InputOptionValue at the boundary;
this widens that enum into InputValue and pushes it through
InputInterface, InputOption/InputArgument defaults, the Input storage,
ArgvInput/ArrayInput/StringInput/CompletionInput, Command::add_option
and add_argument, and the Composer-side wrappers.
Two neighbouring string|int unions get types of their own:
InputDefinition::{get_argument,has_argument} take an ArgumentName, and
ArrayInput keys its parameters by ParameterName. has_parameter_option
and get_parameter_option take the values they look for as &[&str],
which is what PHP's `(array) $values` cast produced anyway.
Two behaviours change along the way. Input::set_option on a negated
option now negates with PHP's loose bool cast rather than treating a
non-bool as false, matching `!$value`. ArrayInput::parse now resolves
an integer key to an argument position instead of looking up an
argument literally named "0".
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/command/global_command_test.rs')
| -rw-r--r-- | crates/shirabe/tests/command/global_command_test.rs | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/crates/shirabe/tests/command/global_command_test.rs b/crates/shirabe/tests/command/global_command_test.rs index 0446a007..cd2b7bc9 100644 --- a/crates/shirabe/tests/command/global_command_test.rs +++ b/crates/shirabe/tests/command/global_command_test.rs @@ -6,7 +6,8 @@ use crate::test_case::{ }; use serial_test::serial; use shirabe::util::platform::Platform; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; use std::path::PathBuf; use tempfile::TempDir; @@ -57,12 +58,15 @@ fn test_global() { let mut app_tester = get_application_tester(); let _ = app_tester.run( vec![ - (PhpMixed::from("command"), PhpMixed::from("global")), + (ParameterName::of("command"), InputValue::from("global")), ( - PhpMixed::from("command-name"), - PhpMixed::from("test-script"), + ParameterName::of("command-name"), + InputValue::from("test-script"), + ), + ( + ParameterName::of("--no-interaction"), + InputValue::from(true), ), - (PhpMixed::from("--no-interaction"), PhpMixed::from(true)), ], RunOptions::default(), ); @@ -96,12 +100,15 @@ fn test_cannot_create_home() { let err = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("global")), + (ParameterName::of("command"), InputValue::from("global")), ( - PhpMixed::from("command-name"), - PhpMixed::from("test-script"), + ParameterName::of("command-name"), + InputValue::from("test-script"), + ), + ( + ParameterName::of("--no-interaction"), + InputValue::from(true), ), - (PhpMixed::from("--no-interaction"), PhpMixed::from(true)), ], RunOptions::default(), ) @@ -154,8 +161,8 @@ fn test_global_show() { app_tester.set_inputs(vec!["".to_string()]); let _ = app_tester.run( vec![ - (PhpMixed::from("command"), PhpMixed::from("global")), - (PhpMixed::from("command-name"), PhpMixed::from("show")), + (ParameterName::of("command"), InputValue::from("global")), + (ParameterName::of("command-name"), InputValue::from("show")), ], RunOptions::default(), ); @@ -186,8 +193,8 @@ fn test_global_show_without_packages() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("global")), - (PhpMixed::from("command-name"), PhpMixed::from("show")), + (ParameterName::of("command"), InputValue::from("global")), + (ParameterName::of("command-name"), InputValue::from("show")), ], RunOptions::default(), ) @@ -234,11 +241,14 @@ fn test_global_require() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("global")), - (PhpMixed::from("command-name"), PhpMixed::from("require")), + (ParameterName::of("command"), InputValue::from("global")), + ( + ParameterName::of("command-name"), + InputValue::from("require"), + ), ( - PhpMixed::from("packages"), - PhpMixed::List(vec![PhpMixed::from("vendor/required-pkg:2.0.0")]), + ParameterName::of("packages"), + InputValue::Array(vec!["vendor/required-pkg:2.0.0".to_string()]), ), ], RunOptions::default(), @@ -295,8 +305,11 @@ fn test_global_update() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("global")), - (PhpMixed::from("command-name"), PhpMixed::from("update")), + (ParameterName::of("command"), InputValue::from("global")), + ( + ParameterName::of("command-name"), + InputValue::from("update"), + ), ], RunOptions::default(), ) @@ -330,9 +343,12 @@ fn test_global_changes_directory() { app_tester.set_inputs(vec!["".to_string()]); let _ = app_tester.run( vec![ - (PhpMixed::from("command"), PhpMixed::from("global")), - (PhpMixed::from("command-name"), PhpMixed::from("config")), - (PhpMixed::from("setting-key"), PhpMixed::from("name")), + (ParameterName::of("command"), InputValue::from("global")), + ( + ParameterName::of("command-name"), + InputValue::from("config"), + ), + (ParameterName::of("setting-key"), InputValue::from("name")), ], RunOptions::default(), ); @@ -364,7 +380,7 @@ fn test_global_missing_command_name() { app_tester.set_inputs(vec!["".to_string()]); let err = app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("global"))], + vec![(ParameterName::of("command"), InputValue::from("global"))], RunOptions::default(), ) .expect_err("expected a RuntimeException for the missing command-name argument"); |
