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 | |
| 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')
29 files changed, 833 insertions, 709 deletions
diff --git a/crates/shirabe/tests/command/about_command_test.rs b/crates/shirabe/tests/command/about_command_test.rs index 52e42a1d..86f6f35b 100644 --- a/crates/shirabe/tests/command/about_command_test.rs +++ b/crates/shirabe/tests/command/about_command_test.rs @@ -3,7 +3,8 @@ use crate::test_case::{RunOptions, get_application_tester}; use serial_test::serial; use shirabe::composer; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; #[test] #[serial] @@ -13,7 +14,7 @@ fn test_about() { let mut app_tester = get_application_tester(); let status_code = app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("about"))], + vec![(ParameterName::of("command"), InputValue::from("about"))], RunOptions::default(), ) .unwrap(); diff --git a/crates/shirabe/tests/command/archive_command_test.rs b/crates/shirabe/tests/command/archive_command_test.rs index 90e13e5d..e5beb9ce 100644 --- a/crates/shirabe/tests/command/archive_command_test.rs +++ b/crates/shirabe/tests/command/archive_command_test.rs @@ -20,6 +20,8 @@ use shirabe_semver::VersionParser; use shirabe_symfony_console::command::Command; use shirabe_symfony_console::input::ArrayInput; use shirabe_symfony_console::input::InputInterface; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; use shirabe_symfony_console::output::BufferedOutput; use shirabe_symfony_console::output::OutputInterface; @@ -202,7 +204,7 @@ fn test_uses_config_from_composer_object_with_package_name() { let input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>> = std::rc::Rc::new(std::cell::RefCell::new( ArrayInput::new( - vec![(PhpMixed::from("package"), PhpMixed::from("foo/bar"))], + vec![(ParameterName::of("package"), InputValue::from("foo/bar"))], None, ) .unwrap(), diff --git a/crates/shirabe/tests/command/audit_command_test.rs b/crates/shirabe/tests/command/audit_command_test.rs index 617479f3..9d7a64ef 100644 --- a/crates/shirabe/tests/command/audit_command_test.rs +++ b/crates/shirabe/tests/command/audit_command_test.rs @@ -6,7 +6,8 @@ use crate::test_case::{ }; use serial_test::serial; use shirabe::package::handle::PackageInterfaceHandle; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; #[test] #[serial] @@ -16,7 +17,7 @@ fn test_successful_response_code_when_no_packages_are_required() { let mut app_tester = get_application_tester(); app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("audit"))], + vec![(ParameterName::of("command"), InputValue::from("audit"))], RunOptions::default(), ) .unwrap(); @@ -41,8 +42,8 @@ fn test_error_auditing_lock_file_when_it_is_missing() { let err = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("audit")), - (PhpMixed::from("--locked"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("audit")), + (ParameterName::of("--locked"), InputValue::from(true)), ], RunOptions::default(), ) @@ -69,8 +70,8 @@ fn test_audit_package_with_no_security_vulnerabilities() { app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("audit")), - (PhpMixed::from("--locked"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("audit")), + (ParameterName::of("--locked"), InputValue::from(true)), ], RunOptions::default(), ) @@ -100,8 +101,8 @@ fn test_audit_package_with_no_dev_option_passed() { app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("audit")), - (PhpMixed::from("--no-dev"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("audit")), + (ParameterName::of("--no-dev"), InputValue::from(true)), ], RunOptions::default(), ) diff --git a/crates/shirabe/tests/command/base_dependency_command_test.rs b/crates/shirabe/tests/command/base_dependency_command_test.rs index ace43ae7..41aeec56 100644 --- a/crates/shirabe/tests/command/base_dependency_command_test.rs +++ b/crates/shirabe/tests/command/base_dependency_command_test.rs @@ -7,8 +7,9 @@ use crate::test_case::{ use serial_test::serial; use shirabe::package::Link; use shirabe::package::handle::PackageInterfaceHandle; -use shirabe_php_shim::PhpMixed; use shirabe_semver::constraint::{AnyConstraint, MatchAllConstraint, MultiConstraint}; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; /// ref: TestCase::trimLines — strip trailing spaces from each line, then trim the whole string. fn trim_lines(s: &str) -> String { @@ -29,7 +30,7 @@ fn match_all() -> AnyConstraint { #[serial] fn test_exception_when_no_required_parameters() { // noParametersCaseProvider - let cases: Vec<(&str, Vec<(&str, PhpMixed)>, &str)> = vec![ + let cases: Vec<(&str, Vec<(&str, InputValue)>, &str)> = vec![ ( "why", vec![], @@ -42,21 +43,21 @@ fn test_exception_when_no_required_parameters() { ), ( "why-not", - vec![("version", PhpMixed::from("*"))], + vec![("version", InputValue::from("*"))], "Not enough arguments (missing: \"package\").", ), ( "why-not", - vec![("package", PhpMixed::from("vendor1/package1"))], + vec![("package", InputValue::from("vendor1/package1"))], "Not enough arguments (missing: \"version\").", ), ]; for (command, parameters, expected_message) in cases { - let mut input: Vec<(PhpMixed, PhpMixed)> = - vec![(PhpMixed::from("command"), PhpMixed::from(command))]; + let mut input: Vec<(ParameterName, InputValue)> = + vec![(ParameterName::of("command"), InputValue::from(command))]; for (k, v) in parameters { - input.push((PhpMixed::from(k), v)); + input.push((ParameterName::of(k), v)); } let mut app_tester = get_application_tester(); @@ -77,13 +78,16 @@ fn test_exception_when_no_required_parameters() { #[serial] fn test_exception_when_running_locked_without_lock_file() { // caseProvider - let cases: Vec<(&str, Vec<(&str, PhpMixed)>)> = vec![ - ("why", vec![("package", PhpMixed::from("vendor1/package1"))]), + let cases: Vec<(&str, Vec<(&str, InputValue)>)> = vec![ + ( + "why", + vec![("package", InputValue::from("vendor1/package1"))], + ), ( "why-not", vec![ - ("package", PhpMixed::from("vendor1/package1")), - ("version", PhpMixed::from("1.*")), + ("package", InputValue::from("vendor1/package1")), + ("version", InputValue::from("1.*")), ], ), ]; @@ -91,12 +95,12 @@ fn test_exception_when_running_locked_without_lock_file() { for (command, parameters) in cases { let tear_down = init_temp_composer(None, None, None, true); - let mut input: Vec<(PhpMixed, PhpMixed)> = - vec![(PhpMixed::from("command"), PhpMixed::from(command))]; + let mut input: Vec<(ParameterName, InputValue)> = + vec![(ParameterName::of("command"), InputValue::from(command))]; for (k, v) in parameters { - input.push((PhpMixed::from(k), v)); + input.push((ParameterName::of(k), v)); } - input.push((PhpMixed::from("--locked"), PhpMixed::from(true))); + input.push((ParameterName::of("--locked"), InputValue::from(true))); let mut app_tester = get_application_tester(); let err = app_tester @@ -119,13 +123,16 @@ fn test_exception_when_running_locked_without_lock_file() { #[serial] fn test_exception_when_it_could_not_found_the_package() { // caseProvider - let cases: Vec<(&str, Vec<(&str, PhpMixed)>)> = vec![ - ("why", vec![("package", PhpMixed::from("vendor1/package1"))]), + let cases: Vec<(&str, Vec<(&str, InputValue)>)> = vec![ + ( + "why", + vec![("package", InputValue::from("vendor1/package1"))], + ), ( "why-not", vec![ - ("package", PhpMixed::from("vendor1/package1")), - ("version", PhpMixed::from("1.*")), + ("package", InputValue::from("vendor1/package1")), + ("version", InputValue::from("1.*")), ], ), ]; @@ -135,10 +142,10 @@ fn test_exception_when_it_could_not_found_the_package() { let tear_down = init_temp_composer(None, None, None, true); - let mut input: Vec<(PhpMixed, PhpMixed)> = - vec![(PhpMixed::from("command"), PhpMixed::from(command))]; + let mut input: Vec<(ParameterName, InputValue)> = + vec![(ParameterName::of("command"), InputValue::from(command))]; for (k, v) in parameters { - input.push((PhpMixed::from(k), v)); + input.push((ParameterName::of(k), v)); } let mut app_tester = get_application_tester(); @@ -165,13 +172,16 @@ fn test_exception_when_it_could_not_found_the_package() { #[serial] fn test_exception_when_package_was_not_found_in_project() { // caseProvider - let cases: Vec<(&str, Vec<(&str, PhpMixed)>)> = vec![ - ("why", vec![("package", PhpMixed::from("vendor1/package1"))]), + let cases: Vec<(&str, Vec<(&str, InputValue)>)> = vec![ + ( + "why", + vec![("package", InputValue::from("vendor1/package1"))], + ), ( "why-not", vec![ - ("package", PhpMixed::from("vendor1/package1")), - ("version", PhpMixed::from("1.*")), + ("package", InputValue::from("vendor1/package1")), + ("version", InputValue::from("1.*")), ], ), ]; @@ -201,10 +211,10 @@ fn test_exception_when_package_was_not_found_in_project() { create_installed_json(&packages, &[], false); create_composer_lock(&packages, &[]); - let mut input: Vec<(PhpMixed, PhpMixed)> = - vec![(PhpMixed::from("command"), PhpMixed::from(command))]; + let mut input: Vec<(ParameterName, InputValue)> = + vec![(ParameterName::of("command"), InputValue::from(command))]; for (k, v) in parameters { - input.push((PhpMixed::from(k), v)); + input.push((ParameterName::of(k), v)); } let mut app_tester = get_application_tester(); @@ -233,13 +243,16 @@ fn test_warning_when_dependencies_are_not_installed() { let expected_warning_message = "<warning>No dependencies installed. Try running composer install or update, or use --locked.</warning>"; // caseProvider - let cases: Vec<(&str, Vec<(&str, PhpMixed)>)> = vec![ - ("why", vec![("package", PhpMixed::from("vendor1/package1"))]), + let cases: Vec<(&str, Vec<(&str, InputValue)>)> = vec![ + ( + "why", + vec![("package", InputValue::from("vendor1/package1"))], + ), ( "why-not", vec![ - ("package", PhpMixed::from("vendor1/package1")), - ("version", PhpMixed::from("1.*")), + ("package", InputValue::from("vendor1/package1")), + ("version", InputValue::from("1.*")), ], ), ]; @@ -267,10 +280,10 @@ fn test_warning_when_dependencies_are_not_installed() { std::slice::from_ref(&some_dev_required_package), ); - let mut input: Vec<(PhpMixed, PhpMixed)> = - vec![(PhpMixed::from("command"), PhpMixed::from(command))]; + let mut input: Vec<(ParameterName, InputValue)> = + vec![(ParameterName::of("command"), InputValue::from(command))]; for (k, v) in parameters { - input.push((PhpMixed::from(k), v)); + input.push((ParameterName::of(k), v)); } let mut app_tester = get_application_tester(); @@ -415,18 +428,21 @@ fn test_why_command_outputs() { true, ); - let input: Vec<(PhpMixed, PhpMixed)> = vec![ - (PhpMixed::from("command"), PhpMixed::from("why")), + let input: Vec<(ParameterName, InputValue)> = vec![ + (ParameterName::of("command"), InputValue::from("why")), + ( + ParameterName::of("package"), + InputValue::from(package_to_be_inspected), + ), ( - PhpMixed::from("package"), - PhpMixed::from(package_to_be_inspected), + ParameterName::of("--tree"), + InputValue::from(render_as_tree), ), - (PhpMixed::from("--tree"), PhpMixed::from(render_as_tree)), ( - PhpMixed::from("--recursive"), - PhpMixed::from(render_recursively), + ParameterName::of("--recursive"), + InputValue::from(render_recursively), ), - (PhpMixed::from("--locked"), PhpMixed::from(true)), + (ParameterName::of("--locked"), InputValue::from(true)), ]; let mut app_tester = get_application_tester(); @@ -586,15 +602,15 @@ fn test_why_not_command_outputs() { true, ); - let input: Vec<(PhpMixed, PhpMixed)> = vec![ - (PhpMixed::from("command"), PhpMixed::from("why-not")), + let input: Vec<(ParameterName, InputValue)> = vec![ + (ParameterName::of("command"), InputValue::from("why-not")), ( - PhpMixed::from("package"), - PhpMixed::from(package_to_be_inspected), + ParameterName::of("package"), + InputValue::from(package_to_be_inspected), ), ( - PhpMixed::from("version"), - PhpMixed::from(package_version_to_be_inspected), + ParameterName::of("version"), + InputValue::from(package_version_to_be_inspected), ), ]; diff --git a/crates/shirabe/tests/command/bump_command_test.rs b/crates/shirabe/tests/command/bump_command_test.rs index a7cdfd76..11665e65 100644 --- a/crates/shirabe/tests/command/bump_command_test.rs +++ b/crates/shirabe/tests/command/bump_command_test.rs @@ -7,12 +7,13 @@ use crate::test_case::{ use serial_test::serial; use shirabe::json::JsonFile; use shirabe::package::handle::PackageInterfaceHandle; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; /// ref: BumpCommandTest::testBump (data provider rolled into one body). fn run_bump_case( composer_json: serde_json::Value, - command: &[(&str, PhpMixed)], + command: &[(&str, InputValue)], expected: serde_json::Value, lock: bool, exit_code: i32, @@ -31,10 +32,10 @@ fn run_bump_case( create_composer_lock(&packages, &dev_packages); } - let mut input: Vec<(PhpMixed, PhpMixed)> = - vec![(PhpMixed::from("command"), PhpMixed::from("bump"))]; + let mut input: Vec<(ParameterName, InputValue)> = + vec![(ParameterName::of("command"), InputValue::from("bump"))]; for (k, v) in command { - input.push((PhpMixed::from(*k), v.clone())); + input.push((ParameterName::of(k), v.clone())); } let mut app_tester = get_application_tester(); @@ -74,7 +75,7 @@ fn test_bump() { "require": { "first/pkg": "^2.0", "second/pkg": "3.*" }, "require-dev": { "dev/pkg": "~2.0" }, }), - &[("--dev-only", PhpMixed::from(true))], + &[("--dev-only", InputValue::from(true))], serde_json::json!({ "require": { "first/pkg": "^2.0", "second/pkg": "3.*" }, "require-dev": { "dev/pkg": "^2.3.4.5" }, @@ -89,7 +90,7 @@ fn test_bump() { "require": { "first/pkg": "^2.0", "second/pkg": "3.*" }, "require-dev": { "dev/pkg": "~2.0" }, }), - &[("--no-dev-only", PhpMixed::from(true))], + &[("--no-dev-only", InputValue::from(true))], serde_json::json!({ "require": { "first/pkg": "^2.3.4", "second/pkg": "^3.4" }, "require-dev": { "dev/pkg": "~2.0" }, @@ -106,10 +107,7 @@ fn test_bump() { }), &[( "packages", - PhpMixed::List(vec![ - PhpMixed::from("first/pkg:3.0.1"), - PhpMixed::from("dev/*"), - ]), + InputValue::Array(vec!["first/pkg:3.0.1".to_string(), "dev/*".to_string()]), )], serde_json::json!({ "require": { "first/pkg": "^2.3.4", "second/pkg": "3.*" }, @@ -138,7 +136,7 @@ fn test_bump() { "require": { "first/pkg": "^2.0", "second/pkg": "3.*" }, "require-dev": { "dev/pkg": "~2.0" }, }), - &[("--dry-run", PhpMixed::from(true))], + &[("--dry-run", InputValue::from(true))], serde_json::json!({ "require": { "first/pkg": "^2.0", "second/pkg": "3.*" }, "require-dev": { "dev/pkg": "~2.0" }, @@ -153,7 +151,7 @@ fn test_bump() { "require": { "first/pkg": "^2.3.4", "second/pkg": "^3.4" }, "require-dev": { "dev/pkg": "^2.3.4.5" }, }), - &[("--dry-run", PhpMixed::from(true))], + &[("--dry-run", InputValue::from(true))], serde_json::json!({ "require": { "first/pkg": "^2.3.4", "second/pkg": "^3.4" }, "require-dev": { "dev/pkg": "^2.3.4.5" }, @@ -214,7 +212,7 @@ fn test_bump_fails_on_non_existing_composer_file() { let mut app_tester = get_application_tester(); let status_code = app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("bump"))], + vec![(ParameterName::of("command"), InputValue::from("bump"))], RunOptions { capture_stderr_separately: true, ..RunOptions::default() @@ -248,7 +246,7 @@ fn test_bump_fails_on_write_error_to_composer_file() { let mut app_tester = get_application_tester(); let status_code = app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("bump"))], + vec![(ParameterName::of("command"), InputValue::from("bump"))], RunOptions { capture_stderr_separately: true, ..RunOptions::default() diff --git a/crates/shirabe/tests/command/check_platform_reqs_command_test.rs b/crates/shirabe/tests/command/check_platform_reqs_command_test.rs index 18eff41e..a9feb1a0 100644 --- a/crates/shirabe/tests/command/check_platform_reqs_command_test.rs +++ b/crates/shirabe/tests/command/check_platform_reqs_command_test.rs @@ -6,12 +6,13 @@ use crate::test_case::{ }; use serial_test::serial; use shirabe::package::handle::PackageInterfaceHandle; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; /// ref: CheckPlatformReqsCommandTest::testPlatformReqsAreSatisfied (data provider rolled into one body). fn run_platform_reqs_are_satisfied_case( composer_json: serde_json::Value, - command: &[(&str, PhpMixed)], + command: &[(&str, InputValue)], expected: &str, lock: bool, ) { @@ -28,12 +29,12 @@ fn run_platform_reqs_are_satisfied_case( create_composer_lock(&packages, &dev_packages); } - let mut input: Vec<(PhpMixed, PhpMixed)> = vec![( - PhpMixed::from("command"), - PhpMixed::from("check-platform-reqs"), + let mut input: Vec<(ParameterName, InputValue)> = vec![( + ParameterName::of("command"), + InputValue::from("check-platform-reqs"), )]; for (k, v) in command { - input.push((PhpMixed::from(*k), v.clone())); + input.push((ParameterName::of(k), v.clone())); } let mut app_tester = get_application_tester(); @@ -55,7 +56,7 @@ fn test_platform_reqs_are_satisfied() { "require": { "ext-foobar": "^2.0" }, "require-dev": { "ext-barbaz": "~4.0" }, }), - &[("--no-dev", PhpMixed::from(true))], + &[("--no-dev", InputValue::from(true))], "Checking non-dev platform requirements for packages in the vendor dir ext-foobar 2.3.4 success", true, @@ -67,7 +68,7 @@ ext-foobar 2.3.4 success", "require": { "ext-foobar": "^2.3" }, "require-dev": { "ext-barbaz": "~2.0" }, }), - &[("--lock", PhpMixed::from(true))], + &[("--lock", InputValue::from(true))], "Checking platform requirements using the lock file\next-barbaz 2.3.4.5 success \next-foobar 2.3.4 success", true, ); @@ -82,8 +83,8 @@ fn test_exception_thrown_if_no_lockfile_found() { let err = app_tester .run( vec![( - PhpMixed::from("command"), - PhpMixed::from("check-platform-reqs"), + ParameterName::of("command"), + InputValue::from("check-platform-reqs"), )], RunOptions::default(), ) @@ -125,10 +126,10 @@ fn test_failed_platform_requirement() { .run( vec![ ( - PhpMixed::from("command"), - PhpMixed::from("check-platform-reqs"), + ParameterName::of("command"), + InputValue::from("check-platform-reqs"), ), - (PhpMixed::from("--format"), PhpMixed::from("json")), + (ParameterName::of("--format"), InputValue::from("json")), ], RunOptions::default(), ) diff --git a/crates/shirabe/tests/command/clear_cache_command_test.rs b/crates/shirabe/tests/command/clear_cache_command_test.rs index b1855799..b25200f5 100644 --- a/crates/shirabe/tests/command/clear_cache_command_test.rs +++ b/crates/shirabe/tests/command/clear_cache_command_test.rs @@ -3,7 +3,8 @@ use crate::test_case::{RunOptions, get_application_tester}; 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; fn tear_down() { // --no-cache triggers the env to change so make sure the env is cleaned up after these tests run @@ -26,7 +27,10 @@ fn test_clear_cache_command_success() { let mut app_tester = get_application_tester(); app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("clear-cache"))], + vec![( + ParameterName::of("command"), + InputValue::from("clear-cache"), + )], RunOptions::default(), ) .unwrap(); @@ -50,8 +54,11 @@ fn test_clear_cache_command_with_option_garbage_collection() { app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("clear-cache")), - (PhpMixed::from("--gc"), PhpMixed::Bool(true)), + ( + ParameterName::of("command"), + InputValue::from("clear-cache"), + ), + (ParameterName::of("--gc"), InputValue::Bool(true)), ], RunOptions::default(), ) @@ -76,8 +83,11 @@ fn test_clear_cache_command_with_option_no_cache() { app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("clear-cache")), - (PhpMixed::from("--no-cache"), PhpMixed::Bool(true)), + ( + ParameterName::of("command"), + InputValue::from("clear-cache"), + ), + (ParameterName::of("--no-cache"), InputValue::Bool(true)), ], RunOptions::default(), ) diff --git a/crates/shirabe/tests/command/config_command_test.rs b/crates/shirabe/tests/command/config_command_test.rs index 35ecb7a5..fc2d4874 100644 --- a/crates/shirabe/tests/command/config_command_test.rs +++ b/crates/shirabe/tests/command/config_command_test.rs @@ -2,28 +2,32 @@ use crate::test_case::{RunOptions, get_application_tester, init_temp_composer}; use serial_test::serial; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; /// `['command' => 'config'] + $command`, with the command name prepended. -fn config_input(command: Vec<(PhpMixed, PhpMixed)>) -> Vec<(PhpMixed, PhpMixed)> { - let mut input = vec![(PhpMixed::from("command"), PhpMixed::from("config"))]; +fn config_input(command: Vec<(ParameterName, InputValue)>) -> Vec<(ParameterName, InputValue)> { + let mut input = vec![(ParameterName::of("command"), InputValue::from("config"))]; input.extend(command); input } -fn key(setting_key: &str) -> (PhpMixed, PhpMixed) { - (PhpMixed::from("setting-key"), PhpMixed::from(setting_key)) +fn key(setting_key: &str) -> (ParameterName, InputValue) { + ( + ParameterName::of("setting-key"), + InputValue::from(setting_key), + ) } -fn value(values: &[&str]) -> (PhpMixed, PhpMixed) { +fn value(values: &[&str]) -> (ParameterName, InputValue) { ( - PhpMixed::from("setting-value"), - PhpMixed::List(values.iter().map(|v| PhpMixed::from(*v)).collect()), + ParameterName::of("setting-value"), + InputValue::Array(values.iter().map(|v| v.to_string()).collect()), ) } -fn flag(name: &str) -> (PhpMixed, PhpMixed) { - (PhpMixed::from(name), PhpMixed::Bool(true)) +fn flag(name: &str) -> (ParameterName, InputValue) { + (ParameterName::of(name), InputValue::Bool(true)) } /// Reads CWD's composer.json as a `serde_json::Value` (mirrors PHP's `json_decode(..., true)`). @@ -35,7 +39,7 @@ fn read_composer_json() -> serde_json::Value { struct UpdateCase { name: &'static str, before: serde_json::Value, - command: Vec<(PhpMixed, PhpMixed)>, + command: Vec<(ParameterName, InputValue)>, expected: serde_json::Value, } @@ -325,7 +329,7 @@ fn test_config_updates() { struct ReadCase { name: &'static str, composer_json: serde_json::Value, - command: Vec<(PhpMixed, PhpMixed)>, + command: Vec<(ParameterName, InputValue)>, expected: &'static str, } @@ -428,8 +432,8 @@ fn test_config_throws_for_invalid_arg_combination() { let result = app_tester.run( config_input(vec![ ( - PhpMixed::from("--file"), - PhpMixed::from("alt.composer.json"), + ParameterName::of("--file"), + InputValue::from("alt.composer.json"), ), flag("--global"), ]), diff --git a/crates/shirabe/tests/command/diagnose_command_test.rs b/crates/shirabe/tests/command/diagnose_command_test.rs index 8649b45d..d2878120 100644 --- a/crates/shirabe/tests/command/diagnose_command_test.rs +++ b/crates/shirabe/tests/command/diagnose_command_test.rs @@ -3,7 +3,8 @@ use crate::test_case::{RunOptions, get_application_tester, init_temp_composer}; 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; #[test] #[serial] @@ -18,7 +19,7 @@ fn test_cmd_fail() { let mut app_tester = get_application_tester(); app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("diagnose"))], + vec![(ParameterName::of("command"), InputValue::from("diagnose"))], RunOptions::default(), ) .unwrap(); @@ -65,7 +66,7 @@ fn test_cmd_success() { let mut app_tester = get_application_tester(); app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("diagnose"))], + vec![(ParameterName::of("command"), InputValue::from("diagnose"))], RunOptions::default(), ) .unwrap(); diff --git a/crates/shirabe/tests/command/dump_autoload_command_test.rs b/crates/shirabe/tests/command/dump_autoload_command_test.rs index c21b13df..bd7771b5 100644 --- a/crates/shirabe/tests/command/dump_autoload_command_test.rs +++ b/crates/shirabe/tests/command/dump_autoload_command_test.rs @@ -3,7 +3,8 @@ use crate::test_case::{RunOptions, get_application_tester, init_temp_composer}; use regex::Regex; use serial_test::serial; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; /// ref: DumpAutoloadCommandTest::testDumpAutoload #[test] @@ -14,7 +15,10 @@ fn test_dump_autoload() { let mut app_tester = get_application_tester(); let status_code = app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("dump-autoload"))], + vec![( + ParameterName::of("command"), + InputValue::from("dump-autoload"), + )], RunOptions::default(), ) .unwrap(); @@ -37,8 +41,11 @@ fn test_dump_dev_autoload() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("dump-autoload")), - (PhpMixed::from("--dev"), PhpMixed::from(true)), + ( + ParameterName::of("command"), + InputValue::from("dump-autoload"), + ), + (ParameterName::of("--dev"), InputValue::from(true)), ], RunOptions::default(), ) @@ -62,8 +69,11 @@ fn test_dump_no_dev_autoload() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("dump-autoload")), - (PhpMixed::from("--dev"), PhpMixed::from(true)), + ( + ParameterName::of("command"), + InputValue::from("dump-autoload"), + ), + (ParameterName::of("--dev"), InputValue::from(true)), ], RunOptions::default(), ) @@ -87,9 +97,12 @@ fn test_using_optimize_and_strict_psr() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("dump-autoload")), - (PhpMixed::from("--optimize"), PhpMixed::from(true)), - (PhpMixed::from("--strict-psr"), PhpMixed::from(true)), + ( + ParameterName::of("command"), + InputValue::from("dump-autoload"), + ), + (ParameterName::of("--optimize"), InputValue::from(true)), + (ParameterName::of("--strict-psr"), InputValue::from(true)), ], RunOptions::default(), ) @@ -132,9 +145,12 @@ fn test_fails_using_strict_psr_if_class_map_violations_are_found() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("dump-autoload")), - (PhpMixed::from("--optimize"), PhpMixed::from(true)), - (PhpMixed::from("--strict-psr"), PhpMixed::from(true)), + ( + ParameterName::of("command"), + InputValue::from("dump-autoload"), + ), + (ParameterName::of("--optimize"), InputValue::from(true)), + (ParameterName::of("--strict-psr"), InputValue::from(true)), ], RunOptions::default(), ) @@ -161,10 +177,13 @@ fn test_using_classmap_authoritative() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("dump-autoload")), ( - PhpMixed::from("--classmap-authoritative"), - PhpMixed::from(true), + ParameterName::of("command"), + InputValue::from("dump-autoload"), + ), + ( + ParameterName::of("--classmap-authoritative"), + InputValue::from(true), ), ], RunOptions::default(), @@ -192,12 +211,15 @@ fn test_using_classmap_authoritative_and_strict_psr() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("dump-autoload")), ( - PhpMixed::from("--classmap-authoritative"), - PhpMixed::from(true), + ParameterName::of("command"), + InputValue::from("dump-autoload"), + ), + ( + ParameterName::of("--classmap-authoritative"), + InputValue::from(true), ), - (PhpMixed::from("--strict-psr"), PhpMixed::from(true)), + (ParameterName::of("--strict-psr"), InputValue::from(true)), ], RunOptions::default(), ) @@ -224,8 +246,11 @@ fn test_strict_psr_does_not_work_without_optimized_autoloader() { let err = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("dump-autoload")), - (PhpMixed::from("--strict-psr"), PhpMixed::from(true)), + ( + ParameterName::of("command"), + InputValue::from("dump-autoload"), + ), + (ParameterName::of("--strict-psr"), InputValue::from(true)), ], RunOptions::default(), ) @@ -247,9 +272,12 @@ fn test_dev_and_no_dev_cannot_be_combined() { let err = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("dump-autoload")), - (PhpMixed::from("--dev"), PhpMixed::from(true)), - (PhpMixed::from("--no-dev"), PhpMixed::from(true)), + ( + ParameterName::of("command"), + InputValue::from("dump-autoload"), + ), + (ParameterName::of("--dev"), InputValue::from(true)), + (ParameterName::of("--no-dev"), InputValue::from(true)), ], RunOptions::default(), ) @@ -281,7 +309,10 @@ fn test_with_custom_autoloader_suffix() { let mut app_tester = get_application_tester(); let status_code = app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("dump-autoload"))], + vec![( + ParameterName::of("command"), + InputValue::from("dump-autoload"), + )], RunOptions::default(), ) .unwrap(); @@ -329,7 +360,10 @@ fn test_with_existing_composer_lock_and_autoloader_suffix() { let mut app_tester = get_application_tester(); let status_code = app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("dump-autoload"))], + vec![( + ParameterName::of("command"), + InputValue::from("dump-autoload"), + )], RunOptions::default(), ) .unwrap(); @@ -375,7 +409,10 @@ fn test_with_existing_composer_lock_without_autoloader_suffix() { let mut app_tester = get_application_tester(); let status_code = app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("dump-autoload"))], + vec![( + ParameterName::of("command"), + InputValue::from("dump-autoload"), + )], RunOptions::default(), ) .unwrap(); diff --git a/crates/shirabe/tests/command/exec_command_test.rs b/crates/shirabe/tests/command/exec_command_test.rs index 03a2c7cf..a160664f 100644 --- a/crates/shirabe/tests/command/exec_command_test.rs +++ b/crates/shirabe/tests/command/exec_command_test.rs @@ -2,7 +2,8 @@ use crate::test_case::{RunOptions, get_application_tester, init_temp_composer}; use serial_test::serial; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; /// ref: ExecCommandTest::testListThrowsIfNoBinariesExist #[test] @@ -17,8 +18,8 @@ fn test_list_throws_if_no_binaries_exist() { let err = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("exec")), - (PhpMixed::from("--list"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("exec")), + (ParameterName::of("--list"), InputValue::from(true)), ], RunOptions::default(), ) @@ -62,8 +63,8 @@ fn test_list() { app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("exec")), - (PhpMixed::from("--list"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("exec")), + (ParameterName::of("--list"), InputValue::from(true)), ], RunOptions::default(), ) diff --git a/crates/shirabe/tests/command/fund_command_test.rs b/crates/shirabe/tests/command/fund_command_test.rs index faeda9dc..e1921f4e 100644 --- a/crates/shirabe/tests/command/fund_command_test.rs +++ b/crates/shirabe/tests/command/fund_command_test.rs @@ -8,6 +8,8 @@ use indexmap::IndexMap; use serial_test::serial; use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle}; use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; fn funding_entry(r#type: &str, url: &str) -> IndexMap<String, PhpMixed> { let mut m = IndexMap::new(); @@ -19,7 +21,7 @@ fn funding_entry(r#type: &str, url: &str) -> IndexMap<String, PhpMixed> { /// Runs one `useCaseProvider` case. fn run_fund_case( composer_json: serde_json::Value, - command: &[(&str, PhpMixed)], + command: &[(&str, InputValue)], funding: &[(&str, IndexMap<String, PhpMixed>)], expected: &str, ) { @@ -48,10 +50,10 @@ fn run_fund_case( create_installed_json(&packages, &dev_packages, true); - let mut input: Vec<(PhpMixed, PhpMixed)> = - vec![(PhpMixed::from("command"), PhpMixed::from("fund"))]; + let mut input: Vec<(ParameterName, InputValue)> = + vec![(ParameterName::of("command"), InputValue::from("fund"))]; for (k, v) in command { - input.push((PhpMixed::from(*k), v.clone())); + input.push((ParameterName::of(k), v.clone())); } let mut app_tester = get_application_tester(); @@ -163,7 +165,7 @@ Thank you!", "require": { "first/pkg": "^2.0" }, "require-dev": { "dev/pkg": "~4.0" }, }), - &[("--format", PhpMixed::from("json"))], + &[("--format", InputValue::from("json"))], &[ ( "first/pkg", 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"); diff --git a/crates/shirabe/tests/command/home_command_test.rs b/crates/shirabe/tests/command/home_command_test.rs index 4a77bd8a..17bfd191 100644 --- a/crates/shirabe/tests/command/home_command_test.rs +++ b/crates/shirabe/tests/command/home_command_test.rs @@ -6,12 +6,13 @@ use crate::test_case::{ }; use serial_test::serial; use shirabe::package::handle::PackageInterfaceHandle; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; /// ref: HomeCommandTest::testHomeCommandWithShowFlag fn run_use_case( composer_json: serde_json::Value, - command: Vec<(PhpMixed, PhpMixed)>, + command: Vec<(ParameterName, InputValue)>, expected: &str, urls: &[(&str, &str)], ) { @@ -36,8 +37,8 @@ fn run_use_case( let mut app_tester = get_application_tester(); let mut input = vec![ - (PhpMixed::from("command"), PhpMixed::from("home")), - (PhpMixed::from("--show"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("home")), + (ParameterName::of("--show"), InputValue::from(true)), ]; input.extend(command); app_tester.run(input, RunOptions::default()).unwrap(); @@ -64,8 +65,8 @@ fn test_home_command_with_show_flag_invalid_or_missing_repository_url() { }, }), vec![( - PhpMixed::from("packages"), - PhpMixed::List(vec![PhpMixed::from("vendor/package")]), + ParameterName::of("packages"), + InputValue::Array(vec!["vendor/package".to_string()]), )], "<warning>Invalid or missing repository URL for vendor/package</warning>", &[], @@ -92,8 +93,8 @@ fn test_home_command_with_show_flag_package_not_found() { run_use_case( serde_json::json!({ "repositories": [] }), vec![( - PhpMixed::from("packages"), - PhpMixed::List(vec![PhpMixed::from("vendor/anotherpackage")]), + ParameterName::of("packages"), + InputValue::Array(vec!["vendor/anotherpackage".to_string()]), )], "<warning>Package vendor/anotherpackage not found</warning>\n\ <warning>Invalid or missing repository URL for vendor/anotherpackage</warning>", @@ -108,8 +109,8 @@ fn test_home_command_with_show_flag_a_valid_package_url() { run_use_case( serde_json::json!({ "repositories": [] }), vec![( - PhpMixed::from("packages"), - PhpMixed::List(vec![PhpMixed::from("vendor/package")]), + ParameterName::of("packages"), + InputValue::Array(vec!["vendor/package".to_string()]), )], "https://example.org", &[("vendor/package", "https://example.org")], @@ -123,8 +124,8 @@ fn test_home_command_with_show_flag_a_valid_dev_package_url() { run_use_case( serde_json::json!({ "repositories": [] }), vec![( - PhpMixed::from("packages"), - PhpMixed::List(vec![PhpMixed::from("vendor/devpackage")]), + ParameterName::of("packages"), + InputValue::Array(vec!["vendor/devpackage".to_string()]), )], "https://example.org/dev", &[("vendor/devpackage", "https://example.org/dev")], diff --git a/crates/shirabe/tests/command/init_command_test.rs b/crates/shirabe/tests/command/init_command_test.rs index ffb98fbb..02131356 100644 --- a/crates/shirabe/tests/command/init_command_test.rs +++ b/crates/shirabe/tests/command/init_command_test.rs @@ -6,6 +6,8 @@ use shirabe::command::init_command::InitCommand; use shirabe::json::JsonFile; use shirabe::util::platform::Platform; use shirabe_php_shim::{PHP_SERVER, PhpMixed}; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; use tempfile::TempDir; fn set_up() { @@ -33,23 +35,28 @@ fn read_composer_json(dir: &std::path::Path) -> serde_json::Value { } /// `['command' => 'init', '--no-interaction' => true] + $arguments`. -fn non_interactive_input(arguments: Vec<(PhpMixed, PhpMixed)>) -> Vec<(PhpMixed, PhpMixed)> { +fn non_interactive_input( + arguments: Vec<(ParameterName, InputValue)>, +) -> Vec<(ParameterName, InputValue)> { let mut input = vec![ - (PhpMixed::from("command"), PhpMixed::from("init")), - (PhpMixed::from("--no-interaction"), PhpMixed::Bool(true)), + (ParameterName::of("command"), InputValue::from("init")), + ( + ParameterName::of("--no-interaction"), + InputValue::Bool(true), + ), ]; input.extend(arguments); input } -fn opt(name: &str, value: &str) -> (PhpMixed, PhpMixed) { - (PhpMixed::from(name), PhpMixed::from(value)) +fn opt(name: &str, value: &str) -> (ParameterName, InputValue) { + (ParameterName::of(name), InputValue::from(value)) } -fn opt_list(name: &str, values: &[&str]) -> (PhpMixed, PhpMixed) { +fn opt_list(name: &str, values: &[&str]) -> (ParameterName, InputValue) { ( - PhpMixed::from(name), - PhpMixed::List(values.iter().map(|v| PhpMixed::from(*v)).collect()), + ParameterName::of(name), + InputValue::Array(values.iter().map(|v| v.to_string()).collect()), ) } @@ -158,7 +165,7 @@ fn test_namespace_from_missing_package_name() { assert_eq!(None, namespace); } -fn run_data_provider() -> Vec<(serde_json::Value, Vec<(PhpMixed, PhpMixed)>)> { +fn run_data_provider() -> Vec<(serde_json::Value, Vec<(ParameterName, InputValue)>)> { vec![ // name argument ( @@ -382,7 +389,7 @@ enum InvalidExpectation { StderrMatches(&'static str), } -fn run_invalid_data_provider() -> Vec<(InvalidExpectation, Vec<(PhpMixed, PhpMixed)>)> { +fn run_invalid_data_provider() -> Vec<(InvalidExpectation, Vec<(ParameterName, InputValue)>)> { vec![ // invalid name argument ( @@ -547,7 +554,7 @@ fn test_interactive_run() { app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("init"))], + vec![(ParameterName::of("command"), InputValue::from("init"))], RunOptions::default(), ) .unwrap(); diff --git a/crates/shirabe/tests/command/install_command_test.rs b/crates/shirabe/tests/command/install_command_test.rs index 55ea9964..11afd464 100644 --- a/crates/shirabe/tests/command/install_command_test.rs +++ b/crates/shirabe/tests/command/install_command_test.rs @@ -5,12 +5,13 @@ use crate::test_case::{ init_temp_composer, }; use serial_test::serial; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; -fn input(pairs: Vec<(&str, PhpMixed)>) -> Vec<(PhpMixed, PhpMixed)> { +fn input(pairs: Vec<(&str, InputValue)>) -> Vec<(ParameterName, InputValue)> { pairs .into_iter() - .map(|(k, v)| (PhpMixed::from(k), v)) + .map(|(k, v)| (ParameterName::of(k), v)) .collect() } @@ -18,14 +19,14 @@ fn input(pairs: Vec<(&str, PhpMixed)>) -> Vec<(PhpMixed, PhpMixed)> { fn error_cases() -> Vec<( &'static str, serde_json::Value, - Vec<(&'static str, PhpMixed)>, + Vec<(&'static str, InputValue)>, &'static str, )> { vec![ ( "it writes an error when the dev flag is passed", serde_json::json!({ "repositories": [] }), - vec![("--dev", PhpMixed::from(true))], + vec![("--dev", InputValue::from(true))], r#"<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning> Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. @@ -35,7 +36,7 @@ Generating autoload files"#, ( "it writes an error when no-suggest flag passed", serde_json::json!({ "repositories": [] }), - vec![("--no-suggest", PhpMixed::from(true))], + vec![("--no-suggest", InputValue::from(true))], r#"<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning> Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. @@ -47,14 +48,14 @@ Generating autoload files"#, serde_json::json!({ "repositories": [] }), vec![( "packages", - PhpMixed::List(vec![PhpMixed::from("vendor/package")]), + InputValue::Array(vec!["vendor/package".to_string()]), )], r#"Invalid argument vendor/package. Use "composer require vendor/package" instead to add packages to your composer.json."#, ), ( "it writes an error when no-install flag is passed", serde_json::json!({ "repositories": [] }), - vec![("--no-install", PhpMixed::from(true))], + vec![("--no-install", InputValue::from(true))], r#"Invalid option "--no-install". Use "composer update --no-install" instead if you are trying to update the composer.lock file."#, ), ] @@ -73,7 +74,7 @@ fn test_install_command_errors() { create_installed_json(&packages, &dev_packages, true); let mut app_tester = get_application_tester(); - let mut args = vec![("command", PhpMixed::from("install"))]; + let mut args = vec![("command", InputValue::from("install"))]; args.extend(command); let _ = app_tester.run(input(args), RunOptions::default()); @@ -107,8 +108,8 @@ fn test_install_from_empty_vendor() { app_tester .run( input(vec![ - ("command", PhpMixed::from("install")), - ("--no-progress", PhpMixed::from(true)), + ("command", InputValue::from("install")), + ("--no-progress", InputValue::from(true)), ]), RunOptions::default(), ) @@ -147,9 +148,9 @@ fn test_install_from_empty_vendor_no_dev() { app_tester .run( input(vec![ - ("command", PhpMixed::from("install")), - ("--no-progress", PhpMixed::from(true)), - ("--no-dev", PhpMixed::from(true)), + ("command", InputValue::from("install")), + ("--no-progress", InputValue::from(true)), + ("--no-dev", InputValue::from(true)), ]), RunOptions::default(), ) @@ -190,8 +191,8 @@ fn test_install_new_packages_with_existing_partial_vendor() { app_tester .run( input(vec![ - ("command", PhpMixed::from("install")), - ("--no-progress", PhpMixed::from(true)), + ("command", InputValue::from("install")), + ("--no-progress", InputValue::from(true)), ]), RunOptions::default(), ) diff --git a/crates/shirabe/tests/command/licenses_command_test.rs b/crates/shirabe/tests/command/licenses_command_test.rs index 5b25aadd..b226f2f0 100644 --- a/crates/shirabe/tests/command/licenses_command_test.rs +++ b/crates/shirabe/tests/command/licenses_command_test.rs @@ -6,7 +6,8 @@ use crate::test_case::{ }; use serial_test::serial; use shirabe::package::handle::PackageInterfaceHandle; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; /// ref: LicensesCommandTest::setUp fn set_up() -> TearDown { @@ -85,7 +86,7 @@ fn test_basic_run() { let mut app_tester = get_application_tester(); let status_code = app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("license"))], + vec![(ParameterName::of("command"), InputValue::from("license"))], RunOptions::default(), ) .unwrap(); @@ -115,8 +116,8 @@ fn test_no_dev() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("license")), - (PhpMixed::from("--no-dev"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("license")), + (ParameterName::of("--no-dev"), InputValue::from(true)), ], RunOptions::default(), ) @@ -146,8 +147,8 @@ fn test_format_json() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("license")), - (PhpMixed::from("--format"), PhpMixed::from("json")), + (ParameterName::of("command"), InputValue::from("license")), + (ParameterName::of("--format"), InputValue::from("json")), ], RunOptions { capture_stderr_separately: true, @@ -182,8 +183,8 @@ fn test_format_summary() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("license")), - (PhpMixed::from("--format"), PhpMixed::from("summary")), + (ParameterName::of("command"), InputValue::from("license")), + (ParameterName::of("--format"), InputValue::from("summary")), ], RunOptions::default(), ) @@ -223,8 +224,8 @@ fn test_format_unknown() { let mut app_tester = get_application_tester(); let result = app_tester.run( vec![ - (PhpMixed::from("command"), PhpMixed::from("license")), - (PhpMixed::from("--format"), PhpMixed::from("unknown")), + (ParameterName::of("command"), InputValue::from("license")), + (ParameterName::of("--format"), InputValue::from("unknown")), ], RunOptions::default(), ); @@ -244,8 +245,8 @@ fn test_locked() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("license")), - (PhpMixed::from("--locked"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("license")), + (ParameterName::of("--locked"), InputValue::from(true)), ], RunOptions::default(), ) @@ -276,9 +277,9 @@ fn test_locked_no_dev() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("license")), - (PhpMixed::from("--locked"), PhpMixed::from(true)), - (PhpMixed::from("--no-dev"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("license")), + (ParameterName::of("--locked"), InputValue::from(true)), + (ParameterName::of("--no-dev"), InputValue::from(true)), ], RunOptions::default(), ) @@ -310,8 +311,8 @@ fn test_locked_without_lock_file() { let mut app_tester = get_application_tester(); let result = app_tester.run( vec![ - (PhpMixed::from("command"), PhpMixed::from("license")), - (PhpMixed::from("--locked"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("license")), + (ParameterName::of("--locked"), InputValue::from(true)), ], RunOptions::default(), ); diff --git a/crates/shirabe/tests/command/reinstall_command_test.rs b/crates/shirabe/tests/command/reinstall_command_test.rs index ecd98c37..6847d998 100644 --- a/crates/shirabe/tests/command/reinstall_command_test.rs +++ b/crates/shirabe/tests/command/reinstall_command_test.rs @@ -5,26 +5,24 @@ use crate::test_case::{ init_temp_composer, }; use serial_test::serial; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; -fn input(pairs: Vec<(&str, PhpMixed)>) -> Vec<(PhpMixed, PhpMixed)> { +fn input(pairs: Vec<(&str, InputValue)>) -> Vec<(ParameterName, InputValue)> { pairs .into_iter() - .map(|(k, v)| (PhpMixed::from(k), v)) + .map(|(k, v)| (ParameterName::of(k), v)) .collect() } /// ref: ReinstallCommandTest::caseProvider -fn cases() -> Vec<(&'static str, Vec<(&'static str, PhpMixed)>, &'static str)> { +fn cases() -> Vec<(&'static str, Vec<(&'static str, InputValue)>, &'static str)> { vec![ ( "reinstall a package by name", vec![( "packages", - PhpMixed::List(vec![ - PhpMixed::from("root/req"), - PhpMixed::from("root/anotherreq*"), - ]), + InputValue::Array(vec!["root/req".to_string(), "root/anotherreq*".to_string()]), )], "- Removing root/req (1.0.0) - Removing root/anotherreq2 (1.0.0) @@ -35,10 +33,7 @@ fn cases() -> Vec<(&'static str, Vec<(&'static str, PhpMixed)>, &'static str)> { ), ( "reinstall packages by type", - vec![( - "--type", - PhpMixed::List(vec![PhpMixed::from("metapackage")]), - )], + vec![("--type", InputValue::Array(vec!["metapackage".to_string()]))], "- Removing root/req (1.0.0) - Removing root/lala (1.0.0) - Removing root/anotherreq2 (1.0.0) @@ -52,7 +47,7 @@ fn cases() -> Vec<(&'static str, Vec<(&'static str, PhpMixed)>, &'static str)> { "reinstall a package that is not installed", vec![( "packages", - PhpMixed::List(vec![PhpMixed::from("root/unknownreq")]), + InputValue::Array(vec!["root/unknownreq".to_string()]), )], r#"<warning>Pattern "root/unknownreq" does not match any currently installed packages.</warning> <warning>Found no packages to reinstall, aborting.</warning>"#, @@ -93,9 +88,9 @@ fn test_reinstall_command() { let mut app_tester = get_application_tester(); let mut args = vec![ - ("command", PhpMixed::from("reinstall")), - ("--no-progress", PhpMixed::from(true)), - ("--no-plugins", PhpMixed::from(true)), + ("command", InputValue::from("reinstall")), + ("--no-progress", InputValue::from(true)), + ("--no-plugins", InputValue::from(true)), ]; args.extend(options); app_tester.run(input(args), RunOptions::default()).unwrap(); diff --git a/crates/shirabe/tests/command/remove_command_test.rs b/crates/shirabe/tests/command/remove_command_test.rs index 9139bf26..377d78c0 100644 --- a/crates/shirabe/tests/command/remove_command_test.rs +++ b/crates/shirabe/tests/command/remove_command_test.rs @@ -9,18 +9,19 @@ use serial_test::serial; use shirabe::json::JsonFile; use shirabe::package::Link; use shirabe::package::handle::PackageInterfaceHandle; -use shirabe_php_shim::PhpMixed; use shirabe_semver::constraint::{AnyConstraint, MatchAllConstraint}; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; // Symfony\Component\Console\Command\Command exit codes. const SUCCESS: i32 = 0; const FAILURE: i32 = 1; const INVALID: i32 = 2; -fn input(pairs: Vec<(&str, PhpMixed)>) -> Vec<(PhpMixed, PhpMixed)> { +fn input(pairs: Vec<(&str, InputValue)>) -> Vec<(ParameterName, InputValue)> { pairs .into_iter() - .map(|(k, v)| (PhpMixed::from(k), v)) + .map(|(k, v)| (ParameterName::of(k), v)) .collect() } @@ -47,7 +48,7 @@ fn test_exception_running_with_no_remove_packages() { let mut app_tester = get_application_tester(); let err = app_tester .run( - input(vec![("command", PhpMixed::from("remove"))]), + input(vec![("command", InputValue::from("remove"))]), RunOptions::default(), ) .expect_err("expected InvalidArgumentException for missing packages argument"); @@ -68,8 +69,8 @@ fn test_exception_when_running_unused_without_lock_file() { let err = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("--unused", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("--unused", InputValue::from(true)), ]), RunOptions::default(), ) @@ -94,10 +95,10 @@ fn test_warning_when_removing_non_existent_package() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), + ("command", InputValue::from("remove")), ( "packages", - PhpMixed::List(vec![PhpMixed::from("vendor1/package1")]), + InputValue::Array(vec!["vendor1/package1".to_string()]), ), ]), RunOptions::default(), @@ -131,11 +132,11 @@ fn test_warning_when_removing_package_from_wrong_type() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("packages", PhpMixed::List(vec![PhpMixed::from("root/req")])), - ("--dev", PhpMixed::from(true)), - ("--no-update", PhpMixed::from(true)), - ("--no-interaction", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("packages", InputValue::Array(vec!["root/req".to_string()])), + ("--dev", InputValue::from(true)), + ("--no-update", InputValue::from(true)), + ("--no-interaction", InputValue::from(true)), ]), RunOptions::default(), ) @@ -170,11 +171,11 @@ fn test_warning_when_removing_package_with_deprecated_dependencies_flag() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("packages", PhpMixed::List(vec![PhpMixed::from("root/req")])), - ("--update-with-dependencies", PhpMixed::from(true)), - ("--no-update", PhpMixed::from(true)), - ("--no-interaction", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("packages", InputValue::Array(vec!["root/req".to_string()])), + ("--update-with-dependencies", InputValue::from(true)), + ("--no-update", InputValue::from(true)), + ("--no-interaction", InputValue::from(true)), ]), RunOptions::default(), ) @@ -238,10 +239,10 @@ fn test_message_output_when_no_unused_packages_to_remove() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("--unused", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), - ("--no-interaction", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("--unused", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), + ("--no-interaction", InputValue::from(true)), ]), RunOptions::default(), ) @@ -286,10 +287,10 @@ fn test_remove_unused_package() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("--unused", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), - ("--no-interaction", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("--unused", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), + ("--no-interaction", InputValue::from(true)), ]), RunOptions::default(), ) @@ -355,10 +356,10 @@ fn test_remove_package_by_name() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("packages", PhpMixed::List(vec![PhpMixed::from("root/req")])), - ("--no-audit", PhpMixed::from(true)), - ("--no-interaction", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("packages", InputValue::Array(vec!["root/req".to_string()])), + ("--no-audit", InputValue::from(true)), + ("--no-interaction", InputValue::from(true)), ]), RunOptions::default(), ) @@ -436,11 +437,11 @@ fn test_remove_package_by_name_with_dry_run() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("packages", PhpMixed::List(vec![PhpMixed::from("root/req")])), - ("--dry-run", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), - ("--no-interaction", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("packages", InputValue::Array(vec!["root/req".to_string()])), + ("--dry-run", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), + ("--no-interaction", InputValue::from(true)), ]), RunOptions::default(), ) @@ -522,10 +523,10 @@ fn test_remove_allowed_plugin_package_with_no_other_allowed_plugins() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("packages", PhpMixed::List(vec![PhpMixed::from("root/req")])), - ("--no-audit", PhpMixed::from(true)), - ("--no-interaction", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("packages", InputValue::Array(vec!["root/req".to_string()])), + ("--no-audit", InputValue::from(true)), + ("--no-interaction", InputValue::from(true)), ]), RunOptions::default(), ) @@ -574,10 +575,10 @@ fn test_remove_allowed_plugin_package_with_other_allowed_plugins() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("packages", PhpMixed::List(vec![PhpMixed::from("root/req")])), - ("--no-audit", PhpMixed::from(true)), - ("--no-interaction", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("packages", InputValue::Array(vec!["root/req".to_string()])), + ("--no-audit", InputValue::from(true)), + ("--no-interaction", InputValue::from(true)), ]), RunOptions::default(), ) @@ -629,11 +630,11 @@ fn test_remove_packages_by_vendor() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("packages", PhpMixed::List(vec![PhpMixed::from("root/*")])), - ("--no-install", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), - ("--no-interaction", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("packages", InputValue::Array(vec!["root/*".to_string()])), + ("--no-install", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), + ("--no-interaction", InputValue::from(true)), ]), RunOptions::default(), ) @@ -709,12 +710,12 @@ fn test_remove_packages_by_vendor_with_dry_run() { app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("packages", PhpMixed::List(vec![PhpMixed::from("root/*")])), - ("--dry-run", PhpMixed::from(true)), - ("--no-install", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), - ("--no-interaction", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("packages", InputValue::Array(vec!["root/*".to_string()])), + ("--dry-run", InputValue::from(true)), + ("--no-install", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), + ("--no-interaction", InputValue::from(true)), ]), RunOptions::default(), ) @@ -767,11 +768,11 @@ fn test_warning_when_removing_packages_by_vendor_from_wrong_type() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("packages", PhpMixed::List(vec![PhpMixed::from("root/*")])), - ("--dev", PhpMixed::from(true)), - ("--no-interaction", PhpMixed::from(true)), - ("--no-update", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("packages", InputValue::Array(vec!["root/*".to_string()])), + ("--dev", InputValue::from(true)), + ("--no-interaction", InputValue::from(true)), + ("--no-update", InputValue::from(true)), ]), RunOptions::default(), ) @@ -813,11 +814,11 @@ fn test_package_still_present_error_when_no_install_flag_used() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("packages", PhpMixed::List(vec![PhpMixed::from("root/req")])), - ("--no-install", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), - ("--no-interaction", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("packages", InputValue::Array(vec!["root/req".to_string()])), + ("--no-install", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), + ("--no-interaction", InputValue::from(true)), ]), RunOptions::default(), ) @@ -903,11 +904,11 @@ fn run_update_inherited_dependencies_flag_case( let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("remove")), - ("packages", PhpMixed::List(vec![PhpMixed::from("root/req")])), - (install_flag_name, PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), - ("--no-interaction", PhpMixed::from(true)), + ("command", InputValue::from("remove")), + ("packages", InputValue::Array(vec!["root/req".to_string()])), + (install_flag_name, InputValue::from(true)), + ("--no-audit", InputValue::from(true)), + ("--no-interaction", InputValue::from(true)), ]), RunOptions::default(), ) diff --git a/crates/shirabe/tests/command/repository_command_test.rs b/crates/shirabe/tests/command/repository_command_test.rs index 36b74cc8..a768dc91 100644 --- a/crates/shirabe/tests/command/repository_command_test.rs +++ b/crates/shirabe/tests/command/repository_command_test.rs @@ -3,7 +3,8 @@ use crate::test_case::{RunOptions, get_application_tester, init_temp_composer}; use serial_test::serial; use shirabe::json::JsonFile; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; /// Read the composer.json in the CWD and decode it. fn read_composer_json() -> serde_json::Value { @@ -21,8 +22,8 @@ fn test_list_with_no_repositories() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("list")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("list")), ], RunOptions::default(), ) @@ -59,8 +60,8 @@ fn test_list_with_repositories_as_list() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("list")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("list")), ], RunOptions::default(), ) @@ -98,8 +99,8 @@ fn test_list_with_repositories_as_assoc() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("list")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("list")), ], RunOptions::default(), ) @@ -126,13 +127,13 @@ fn test_add_repository_with_type_and_url() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("add")), - (PhpMixed::from("name"), PhpMixed::from("foo")), - (PhpMixed::from("arg1"), PhpMixed::from("vcs")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("add")), + (ParameterName::of("name"), InputValue::from("foo")), + (ParameterName::of("arg1"), InputValue::from("vcs")), ( - PhpMixed::from("arg2"), - PhpMixed::from("https://example.org/foo.git"), + ParameterName::of("arg2"), + InputValue::from("https://example.org/foo.git"), ), ], RunOptions::default(), @@ -161,12 +162,12 @@ fn test_add_repository_with_json() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("add")), - (PhpMixed::from("name"), PhpMixed::from("bar")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("add")), + (ParameterName::of("name"), InputValue::from("bar")), ( - PhpMixed::from("arg1"), - PhpMixed::from(r#"{"type":"composer","url":"https://repo.example.org"}"#), + ParameterName::of("arg1"), + InputValue::from(r#"{"type":"composer","url":"https://repo.example.org"}"#), ), ], RunOptions::default(), @@ -202,9 +203,9 @@ fn test_remove_repository() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("remove")), - (PhpMixed::from("name"), PhpMixed::from("foo")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("remove")), + (ParameterName::of("name"), InputValue::from("foo")), ], RunOptions::default(), ) @@ -240,10 +241,10 @@ fn run_set_and_get_url_assoc_case(name: &str, index: &str, new_url: &str) { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("set-url")), - (PhpMixed::from("name"), PhpMixed::from(name)), - (PhpMixed::from("arg1"), PhpMixed::from(new_url)), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("set-url")), + (ParameterName::of("name"), InputValue::from(name)), + (ParameterName::of("arg1"), InputValue::from(new_url)), ], RunOptions::default(), ) @@ -263,9 +264,9 @@ fn run_set_and_get_url_assoc_case(name: &str, index: &str, new_url: &str) { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("get-url")), - (PhpMixed::from("name"), PhpMixed::from(name)), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("get-url")), + (ParameterName::of("name"), InputValue::from(name)), ], RunOptions::default(), ) @@ -305,10 +306,10 @@ fn run_set_and_get_url_list_case(name: &str, index: usize, new_url: &str) { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("set-url")), - (PhpMixed::from("name"), PhpMixed::from(name)), - (PhpMixed::from("arg1"), PhpMixed::from(new_url)), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("set-url")), + (ParameterName::of("name"), InputValue::from(name)), + (ParameterName::of("arg1"), InputValue::from(new_url)), ], RunOptions::default(), ) @@ -333,9 +334,9 @@ fn run_set_and_get_url_list_case(name: &str, index: usize, new_url: &str) { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("get-url")), - (PhpMixed::from("name"), PhpMixed::from(name)), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("get-url")), + (ParameterName::of("name"), InputValue::from(name)), ], RunOptions::default(), ) @@ -366,9 +367,9 @@ fn test_disable_and_enable_packagist() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("disable")), - (PhpMixed::from("name"), PhpMixed::from("packagist")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("disable")), + (ParameterName::of("name"), InputValue::from("packagist")), ], RunOptions::default(), ) @@ -384,9 +385,9 @@ fn test_disable_and_enable_packagist() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("enable")), - (PhpMixed::from("name"), PhpMixed::from("packagist")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("enable")), + (ParameterName::of("name"), InputValue::from("packagist")), ], RunOptions::default(), ) @@ -404,12 +405,12 @@ fn test_invalid_arg_combination_throws() { let err = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), + (ParameterName::of("command"), InputValue::from("repo")), ( - PhpMixed::from("--file"), - PhpMixed::from("alt.composer.json"), + ParameterName::of("--file"), + InputValue::from("alt.composer.json"), ), - (PhpMixed::from("--global"), PhpMixed::from(true)), + (ParameterName::of("--global"), InputValue::from(true)), ], RunOptions::default(), ) @@ -438,11 +439,11 @@ fn test_prepend_repository_by_name_list_to_assoc() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("add")), - (PhpMixed::from("name"), PhpMixed::from("foo")), - (PhpMixed::from("arg1"), PhpMixed::from("path")), - (PhpMixed::from("arg2"), PhpMixed::from("foo/bar")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("add")), + (ParameterName::of("name"), InputValue::from("foo")), + (ParameterName::of("arg1"), InputValue::from("path")), + (ParameterName::of("arg2"), InputValue::from("foo/bar")), ], RunOptions::default(), ) @@ -478,12 +479,12 @@ fn test_append_repository_by_name_list_to_assoc() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("add")), - (PhpMixed::from("name"), PhpMixed::from("foo")), - (PhpMixed::from("arg1"), PhpMixed::from("path")), - (PhpMixed::from("arg2"), PhpMixed::from("foo/bar")), - (PhpMixed::from("--append"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("add")), + (ParameterName::of("name"), InputValue::from("foo")), + (ParameterName::of("arg1"), InputValue::from("path")), + (ParameterName::of("arg2"), InputValue::from("foo/bar")), + (ParameterName::of("--append"), InputValue::from(true)), ], RunOptions::default(), ) @@ -519,11 +520,11 @@ fn test_prepend_repository_assoc_with_packagist_disabled() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("add")), - (PhpMixed::from("name"), PhpMixed::from("foo")), - (PhpMixed::from("arg1"), PhpMixed::from("path")), - (PhpMixed::from("arg2"), PhpMixed::from("foo/bar")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("add")), + (ParameterName::of("name"), InputValue::from("foo")), + (ParameterName::of("arg1"), InputValue::from("path")), + (ParameterName::of("arg2"), InputValue::from("foo/bar")), ], RunOptions::default(), ) @@ -560,12 +561,12 @@ fn test_append_repository_assoc_with_packagist_disabled() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("add")), - (PhpMixed::from("name"), PhpMixed::from("foo")), - (PhpMixed::from("arg1"), PhpMixed::from("path")), - (PhpMixed::from("arg2"), PhpMixed::from("foo/bar")), - (PhpMixed::from("--append"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("add")), + (ParameterName::of("name"), InputValue::from("foo")), + (ParameterName::of("arg1"), InputValue::from("path")), + (ParameterName::of("arg2"), InputValue::from("foo/bar")), + (ParameterName::of("--append"), InputValue::from(true)), ], RunOptions::default(), ) @@ -608,15 +609,15 @@ fn test_add_before_and_after_by_name() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("add")), - (PhpMixed::from("name"), PhpMixed::from("beta")), - (PhpMixed::from("arg1"), PhpMixed::from("vcs")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("add")), + (ParameterName::of("name"), InputValue::from("beta")), + (ParameterName::of("arg1"), InputValue::from("vcs")), ( - PhpMixed::from("arg2"), - PhpMixed::from("https://example.org/b"), + ParameterName::of("arg2"), + InputValue::from("https://example.org/b"), ), - (PhpMixed::from("--before"), PhpMixed::from("omega")), + (ParameterName::of("--before"), InputValue::from("omega")), ], RunOptions::default(), ) @@ -628,15 +629,15 @@ fn test_add_before_and_after_by_name() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("add")), - (PhpMixed::from("name"), PhpMixed::from("gamma")), - (PhpMixed::from("arg1"), PhpMixed::from("vcs")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("add")), + (ParameterName::of("name"), InputValue::from("gamma")), + (ParameterName::of("arg1"), InputValue::from("vcs")), ( - PhpMixed::from("arg2"), - PhpMixed::from("https://example.org/g"), + ParameterName::of("arg2"), + InputValue::from("https://example.org/g"), ), - (PhpMixed::from("--after"), PhpMixed::from("alpha")), + (ParameterName::of("--after"), InputValue::from("alpha")), ], RunOptions::default(), ) @@ -670,13 +671,13 @@ fn test_add_same_name_replaces_existing() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("add")), - (PhpMixed::from("name"), PhpMixed::from("foo")), - (PhpMixed::from("arg1"), PhpMixed::from("vcs")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("add")), + (ParameterName::of("name"), InputValue::from("foo")), + (ParameterName::of("arg1"), InputValue::from("vcs")), ( - PhpMixed::from("arg2"), - PhpMixed::from("https://example.org/old"), + ParameterName::of("arg2"), + InputValue::from("https://example.org/old"), ), ], RunOptions::default(), @@ -689,15 +690,15 @@ fn test_add_same_name_replaces_existing() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("repo")), - (PhpMixed::from("action"), PhpMixed::from("add")), - (PhpMixed::from("name"), PhpMixed::from("foo")), - (PhpMixed::from("arg1"), PhpMixed::from("vcs")), + (ParameterName::of("command"), InputValue::from("repo")), + (ParameterName::of("action"), InputValue::from("add")), + (ParameterName::of("name"), InputValue::from("foo")), + (ParameterName::of("arg1"), InputValue::from("vcs")), ( - PhpMixed::from("arg2"), - PhpMixed::from("https://example.org/new"), + ParameterName::of("arg2"), + InputValue::from("https://example.org/new"), ), - (PhpMixed::from("--append"), PhpMixed::from(true)), + (ParameterName::of("--append"), InputValue::from(true)), ], RunOptions::default(), ) diff --git a/crates/shirabe/tests/command/require_command_test.rs b/crates/shirabe/tests/command/require_command_test.rs index 2a9a0411..a4f3bb9c 100644 --- a/crates/shirabe/tests/command/require_command_test.rs +++ b/crates/shirabe/tests/command/require_command_test.rs @@ -6,12 +6,13 @@ use crate::test_case::{ }; use serial_test::serial; use shirabe::json::JsonFile; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; -fn input(pairs: Vec<(&str, PhpMixed)>) -> Vec<(PhpMixed, PhpMixed)> { +fn input(pairs: Vec<(&str, InputValue)>) -> Vec<(ParameterName, InputValue)> { pairs .into_iter() - .map(|(k, v)| (PhpMixed::from(k), v)) + .map(|(k, v)| (ParameterName::of(k), v)) .collect() } @@ -34,12 +35,12 @@ fn test_require_throws_if_none_matches() { let err = app_tester .run( input(vec![ - ("command", PhpMixed::from("require")), - ("--dry-run", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), + ("command", InputValue::from("require")), + ("--dry-run", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), ( "packages", - PhpMixed::List(vec![PhpMixed::from("required/pkg")]), + InputValue::Array(vec!["required/pkg".to_string()]), ), ]), RunOptions::default(), @@ -81,12 +82,12 @@ fn test_require_warns_if_resolved_to_feature_branch() { app_tester .run( input(vec![ - ("command", PhpMixed::from("require")), - ("--dry-run", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), + ("command", InputValue::from("require")), + ("--dry-run", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), ( "packages", - PhpMixed::List(vec![PhpMixed::from("required/pkg")]), + InputValue::Array(vec!["required/pkg".to_string()]), ), ]), RunOptions { @@ -121,7 +122,7 @@ Are you sure you want to use this constraint (y) or would you rather abort (n) t fn provide_require() -> Vec<( &'static str, serde_json::Value, - Vec<(&'static str, PhpMixed)>, + Vec<(&'static str, InputValue)>, &'static str, )> { vec![ @@ -134,7 +135,7 @@ fn provide_require() -> Vec<( { "name": "required/pkg", "version": "1.0.0" }, ] } }, }), - vec![("packages", PhpMixed::List(vec![PhpMixed::from("required/pkg")]))], + vec![("packages", InputValue::Array(vec!["required/pkg".to_string()]))], "<warning>Cannot use required/pkg's latest version 1.2.0 as it requires ext-foobar ^1 which is missing from your platform. ./composer.json has been updated Running composer update required/pkg @@ -157,9 +158,9 @@ Using version ^1.0 for required/pkg", ] } }, }), vec![ - ("packages", PhpMixed::List(vec![PhpMixed::from("required/pkg")])), - ("--no-install", PhpMixed::from(true)), - ("-v", PhpMixed::from(true)), + ("packages", InputValue::Array(vec!["required/pkg".to_string()])), + ("--no-install", InputValue::from(true)), + ("-v", InputValue::from(true)), ], "<warning>Cannot use required/pkg's latest version 1.2.0 as it requires ext-foobar ^1 which is missing from your platform. <warning>Cannot use required/pkg 1.1.0 as it requires ext-foobar ^1 which is missing from your platform. @@ -184,8 +185,8 @@ Using version ^1.0 for required/pkg", ] } }, }), vec![ - ("packages", PhpMixed::List(vec![PhpMixed::from("required/pkg")])), - ("--no-install", PhpMixed::from(true)), + ("packages", InputValue::Array(vec!["required/pkg".to_string()])), + ("--no-install", InputValue::from(true)), ], "<warning>Cannot use required/pkg's latest version 1.1.0 as it requires php ^20 which is not satisfied by your platform. ./composer.json has been updated @@ -205,8 +206,8 @@ Using version ^1.0 for required/pkg", ] } }, }), vec![ - ("packages", PhpMixed::List(vec![PhpMixed::from("required/pkg")])), - ("--no-update", PhpMixed::from(true)), + ("packages", InputValue::Array(vec!["required/pkg".to_string()])), + ("--no-update", InputValue::from(true)), ], "<warning>Cannot use required/pkg's latest version 1.1.0 as it requires php ^20 which is not satisfied by your platform. Using version ^1.0 for required/pkg @@ -224,8 +225,8 @@ Using version ^1.0 for required/pkg "require": { "existing/dep": "^1" }, }), vec![ - ("packages", PhpMixed::List(vec![PhpMixed::from("required/pkg")])), - ("--no-install", PhpMixed::from(true)), + ("packages", InputValue::Array(vec!["required/pkg".to_string()])), + ("--no-install", InputValue::from(true)), ], "./composer.json has been updated Running composer update required/pkg @@ -245,9 +246,9 @@ Using version ^1.1 for required/pkg", ] } }, }), vec![ - ("packages", PhpMixed::List(vec![PhpMixed::from("required/pkg")])), - ("--no-install", PhpMixed::from(true)), - ("--fixed", PhpMixed::from(true)), + ("packages", InputValue::Array(vec!["required/pkg".to_string()])), + ("--no-install", InputValue::from(true)), + ("--fixed", InputValue::from(true)), ], "./composer.json has been updated Running composer update required/pkg @@ -268,9 +269,9 @@ fn test_require() { let mut app_tester = get_application_tester(); let mut args = vec![ - ("command", PhpMixed::from("require")), - ("--dry-run", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), + ("command", InputValue::from("require")), + ("--dry-run", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), ]; args.extend(command); app_tester.run(input(args), RunOptions::default()).unwrap(); @@ -357,19 +358,19 @@ fn test_inconsistent_require_keys() { let mut app_tester = get_application_tester(); let mut command = vec![ - ("command", PhpMixed::from("require")), - ("--no-audit", PhpMixed::from(true)), - ("--dev", PhpMixed::from(is_dev)), - ("--no-install", PhpMixed::from(true)), + ("command", InputValue::from("require")), + ("--no-audit", InputValue::from(true)), + ("--dev", InputValue::from(is_dev)), + ("--no-install", InputValue::from(true)), ( "packages", - PhpMixed::List(vec![PhpMixed::from("required/pkg")]), + InputValue::Array(vec!["required/pkg".to_string()]), ), ]; if is_interactive { app_tester.set_inputs(vec!["yes".to_string()]); } else { - command.push(("--no-interaction", PhpMixed::from(true))); + command.push(("--no-interaction", InputValue::from(true))); } app_tester diff --git a/crates/shirabe/tests/command/run_script_command_test.rs b/crates/shirabe/tests/command/run_script_command_test.rs index 992fc6e2..5c4a60f7 100644 --- a/crates/shirabe/tests/command/run_script_command_test.rs +++ b/crates/shirabe/tests/command/run_script_command_test.rs @@ -2,7 +2,8 @@ use crate::test_case::{RunOptions, get_application_tester, init_temp_composer}; use serial_test::serial; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; /// ref: RunScriptCommandTest::testDetectAndPassDevModeToEventAndToDispatching /// @@ -49,8 +50,8 @@ fn test_can_list_scripts() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("run-script")), - (PhpMixed::from("--list"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("run-script")), + (ParameterName::of("--list"), InputValue::from(true)), ], RunOptions::default(), ) @@ -95,9 +96,9 @@ fn test_can_define_aliases() { let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("test")), - (PhpMixed::from("--help"), PhpMixed::from(true)), - (PhpMixed::from("--format"), PhpMixed::from("json")), + (ParameterName::of("command"), InputValue::from("test")), + (ParameterName::of("--help"), InputValue::from(true)), + (ParameterName::of("--format"), InputValue::from("json")), ], RunOptions::default(), ) @@ -193,9 +194,12 @@ class MyCommand extends Command app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("test-direct")), - (PhpMixed::from("--outeropt"), PhpMixed::from(true)), - (PhpMixed::from("req-arg"), PhpMixed::from("lala")), + ( + ParameterName::of("command"), + InputValue::from("test-direct"), + ), + (ParameterName::of("--outeropt"), InputValue::from(true)), + (ParameterName::of("req-arg"), InputValue::from("lala")), ], RunOptions::default(), ) @@ -211,9 +215,9 @@ class MyCommand extends Command app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("test-ref")), - (PhpMixed::from("--outeropt"), PhpMixed::from(true)), - (PhpMixed::from("req-arg"), PhpMixed::from("lala")), + (ParameterName::of("command"), InputValue::from("test-ref")), + (ParameterName::of("--outeropt"), InputValue::from(true)), + (ParameterName::of("req-arg"), InputValue::from("lala")), ], RunOptions::default(), ) @@ -230,8 +234,8 @@ class MyCommand extends Command let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("run-script")), - (PhpMixed::from("--list"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("run-script")), + (ParameterName::of("--list"), InputValue::from(true)), ], RunOptions::default(), ) @@ -317,8 +321,8 @@ class MyCommandWithDefinitions extends Command app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from(cmd_name)), - (PhpMixed::from("req-arg"), PhpMixed::from("lala")), + (ParameterName::of("command"), InputValue::from(cmd_name)), + (ParameterName::of("req-arg"), InputValue::from("lala")), ], RunOptions::default(), ) @@ -331,10 +335,10 @@ class MyCommandWithDefinitions extends Command .run( vec![ ( - PhpMixed::from("command"), - PhpMixed::from(cmd_alias.as_str()), + ParameterName::of("command"), + InputValue::from(cmd_alias.as_str()), ), - (PhpMixed::from("req-arg"), PhpMixed::from("lala")), + (ParameterName::of("req-arg"), InputValue::from("lala")), ], RunOptions::default(), ) @@ -346,8 +350,8 @@ class MyCommandWithDefinitions extends Command let status_code = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("run-script")), - (PhpMixed::from("--list"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("run-script")), + (ParameterName::of("--list"), InputValue::from(true)), ], RunOptions::default(), ) diff --git a/crates/shirabe/tests/command/search_command_test.rs b/crates/shirabe/tests/command/search_command_test.rs index 7806ea0f..cc011d0f 100644 --- a/crates/shirabe/tests/command/search_command_test.rs +++ b/crates/shirabe/tests/command/search_command_test.rs @@ -2,7 +2,8 @@ use crate::test_case::{RunOptions, get_application_tester, init_temp_composer}; use serial_test::serial; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; fn repositories_json() -> serde_json::Value { serde_json::json!({ @@ -22,11 +23,11 @@ fn repositories_json() -> serde_json::Value { } /// ref: SearchCommandTest::testSearch (data provider rolled into one body). -fn run_search_case(command: Vec<(PhpMixed, PhpMixed)>, expected: &str) { +fn run_search_case(command: Vec<(ParameterName, InputValue)>, expected: &str) { let _tear_down = init_temp_composer(Some(&repositories_json()), None, None, true); - let mut input: Vec<(PhpMixed, PhpMixed)> = - vec![(PhpMixed::from("command"), PhpMixed::from("search"))]; + let mut input: Vec<(ParameterName, InputValue)> = + vec![(ParameterName::of("command"), InputValue::from("search"))]; input.extend(command); let mut app_tester = get_application_tester(); @@ -40,8 +41,8 @@ fn test_search() { // 'by name and description' run_search_case( vec![( - "tokens".into(), - PhpMixed::List(vec![PhpMixed::from("fancy")]), + ParameterName::of("tokens"), + InputValue::Array(vec!["fancy".to_string()]), )], "bar/baz <warning>! Abandoned !</warning> fancy baz\nvendor-2/fancy-package", ); @@ -49,8 +50,8 @@ fn test_search() { // 'by name and description with multiple tokens' run_search_case( vec![( - "tokens".into(), - PhpMixed::List(vec![PhpMixed::from("fancy"), PhpMixed::from("vendor")]), + ParameterName::of("tokens"), + InputValue::Array(vec!["fancy".to_string(), "vendor".to_string()]), )], "vendor-1/package-1 generic description\nbar/baz <warning>! Abandoned !</warning> fancy baz\nvendor-2/fancy-package", ); @@ -59,10 +60,10 @@ fn test_search() { run_search_case( vec![ ( - "tokens".into(), - PhpMixed::List(vec![PhpMixed::from("fancy")]), + ParameterName::of("tokens"), + InputValue::Array(vec!["fancy".to_string()]), ), - ("--only-name".into(), PhpMixed::from(true)), + (ParameterName::of("--only-name"), InputValue::from(true)), ], "vendor-2/fancy-package", ); @@ -70,8 +71,11 @@ fn test_search() { // 'by vendor only' run_search_case( vec![ - ("tokens".into(), PhpMixed::List(vec![PhpMixed::from("bar")])), - ("--only-vendor".into(), PhpMixed::from(true)), + ( + ParameterName::of("tokens"), + InputValue::Array(vec!["bar".to_string()]), + ), + (ParameterName::of("--only-vendor"), InputValue::from(true)), ], "bar", ); @@ -80,10 +84,10 @@ fn test_search() { run_search_case( vec![ ( - "tokens".into(), - PhpMixed::List(vec![PhpMixed::from("vendor")]), + ParameterName::of("tokens"), + InputValue::Array(vec!["vendor".to_string()]), ), - ("--type".into(), PhpMixed::from("foo")), + (ParameterName::of("--type"), InputValue::from("foo")), ], "vendor-2/fancy-package", ); @@ -92,10 +96,10 @@ fn test_search() { run_search_case( vec![ ( - "tokens".into(), - PhpMixed::List(vec![PhpMixed::from("vendor-2/fancy")]), + ParameterName::of("tokens"), + InputValue::Array(vec!["vendor-2/fancy".to_string()]), ), - ("--format".into(), PhpMixed::from("json")), + (ParameterName::of("--format"), InputValue::from("json")), ], "[\n {\n \"name\": \"vendor-2/fancy-package\",\n \"description\": null\n }\n]", ); @@ -103,8 +107,8 @@ fn test_search() { // 'no results' run_search_case( vec![( - "tokens".into(), - PhpMixed::List(vec![PhpMixed::from("invalid-package-name")]), + ParameterName::of("tokens"), + InputValue::Array(vec!["invalid-package-name".to_string()]), )], "", ); @@ -124,11 +128,14 @@ fn test_invalid_format() { let result = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("search")), - (PhpMixed::from("--format"), PhpMixed::from("test-format")), + (ParameterName::of("command"), InputValue::from("search")), + ( + ParameterName::of("--format"), + InputValue::from("test-format"), + ), ( - PhpMixed::from("tokens"), - PhpMixed::List(vec![PhpMixed::from("test")]), + ParameterName::of("tokens"), + InputValue::Array(vec!["test".to_string()]), ), ], RunOptions::default(), @@ -155,12 +162,12 @@ fn test_invalid_flags() { let err = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("search")), - (PhpMixed::from("--only-vendor"), PhpMixed::from(true)), - (PhpMixed::from("--only-name"), PhpMixed::from(true)), + (ParameterName::of("command"), InputValue::from("search")), + (ParameterName::of("--only-vendor"), InputValue::from(true)), + (ParameterName::of("--only-name"), InputValue::from(true)), ( - PhpMixed::from("tokens"), - PhpMixed::List(vec![PhpMixed::from("test")]), + ParameterName::of("tokens"), + InputValue::Array(vec!["test".to_string()]), ), ], RunOptions::default(), diff --git a/crates/shirabe/tests/command/self_update_command_test.rs b/crates/shirabe/tests/command/self_update_command_test.rs index 1f83af66..2248873f 100644 --- a/crates/shirabe/tests/command/self_update_command_test.rs +++ b/crates/shirabe/tests/command/self_update_command_test.rs @@ -4,6 +4,8 @@ use crate::test_case::{RunOptions, get_application_tester, init_temp_composer}; use indexmap::IndexMap; use serial_test::serial; use shirabe_php_shim::{PHP_BINARY, PhpMixed}; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; use shirabe_symfony_process::Process; /// ref: SelfUpdateCommandTest::setUp. The `composer-test.phar` copy PHP also performs here lives in @@ -108,8 +110,11 @@ fn test_update_with_invalid_option_throws_exception() { let err = app_tester .run( vec![ - (PhpMixed::from("command"), PhpMixed::from("self-update")), - (PhpMixed::from("invalid-option"), PhpMixed::from(true)), + ( + ParameterName::of("command"), + InputValue::from("self-update"), + ), + (ParameterName::of("invalid-option"), InputValue::from(true)), ], RunOptions::default(), ) diff --git a/crates/shirabe/tests/command/show_command_test.rs b/crates/shirabe/tests/command/show_command_test.rs index eb8176e9..3834b016 100644 --- a/crates/shirabe/tests/command/show_command_test.rs +++ b/crates/shirabe/tests/command/show_command_test.rs @@ -8,13 +8,13 @@ use serial_test::serial; use shirabe::package::Link; use shirabe::package::handle::PackageInterfaceHandle; use shirabe::repository::PlatformRepository; -use shirabe_php_shim::{PhpMixed, date_local}; +use shirabe_php_shim::date_local; -/// Build a `Vec<(PhpMixed, PhpMixed)>` command input from `(key, value)` pairs. -fn input(pairs: Vec<(&str, PhpMixed)>) -> Vec<(PhpMixed, PhpMixed)> { +/// Build a `Vec<(ParameterName, InputValue)>` command input from `(key, value)` pairs. +fn input(pairs: Vec<(&str, InputValue)>) -> Vec<(ParameterName, InputValue)> { pairs .into_iter() - .map(|(k, v)| (PhpMixed::from(k), v)) + .map(|(k, v)| (ParameterName::of(k), v)) .collect() } @@ -50,7 +50,11 @@ fn show_composer_json(requires: serde_json::Value) -> serde_json::Value { } /// ref: ShowCommandTest::testShow (one data-provider case). -fn run_show_case(command: Vec<(PhpMixed, PhpMixed)>, expected: &str, requires: serde_json::Value) { +fn run_show_case( + command: Vec<(ParameterName, InputValue)>, + expected: &str, + requires: serde_json::Value, +) { let _tear_down = init_temp_composer(Some(&show_composer_json(requires)), None, None, true); let pkg = get_complete_package("vendor/package", "v1.0.0"); @@ -76,12 +80,14 @@ fn run_show_case(command: Vec<(PhpMixed, PhpMixed)>, expected: &str, requires: s } use crate::test_case::{create_composer_lock, create_installed_json}; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; #[test] #[serial] fn test_show_default_shows_installed_with_version_and_description() { run_show_case( - input(vec![("command", PhpMixed::from("show"))]), + input(vec![("command", InputValue::from("show"))]), "outdated/major 1.0.0 outdated/minor 1.0.0 outdated/patch 1.0.0 @@ -95,9 +101,9 @@ vendor/package 1.0.0 description of installed package", fn test_show_with_installed_and_self() { run_show_case( input(vec![ - ("command", PhpMixed::from("show")), - ("--installed", PhpMixed::from(true)), - ("--self", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("--installed", InputValue::from(true)), + ("--self", InputValue::from(true)), ]), "outdated/major 1.0.0 outdated/minor 1.0.0 @@ -113,9 +119,9 @@ vendor/package 1.0.0 description of installed package", fn test_show_with_locked_and_self() { run_show_case( input(vec![ - ("command", PhpMixed::from("show")), - ("--locked", PhpMixed::from(true)), - ("--self", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("--locked", InputValue::from(true)), + ("--self", InputValue::from(true)), ]), "root/pkg 1.2.3 vendor/locked 3.0.0 description of locked package", @@ -128,8 +134,8 @@ vendor/locked 3.0.0 description of locked package", fn test_show_with_available() { run_show_case( input(vec![ - ("command", PhpMixed::from("show")), - ("-a", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("-a", InputValue::from(true)), ]), "outdated/major outdated/major v2.0.0 description outdated/minor outdated/minor v1.1.1 description @@ -144,8 +150,8 @@ vendor/package generic description", fn test_show_with_direct_shows_nothing_if_no_deps() { run_show_case( input(vec![ - ("command", PhpMixed::from("show")), - ("--direct", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("--direct", InputValue::from(true)), ]), "", serde_json::json!({}), @@ -157,8 +163,8 @@ fn test_show_with_direct_shows_nothing_if_no_deps() { fn test_show_with_direct_shows_only_root_deps() { run_show_case( input(vec![ - ("command", PhpMixed::from("show")), - ("--direct", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("--direct", InputValue::from(true)), ]), "outdated/major 1.0.0", serde_json::json!({"outdated/major": "*"}), @@ -169,7 +175,7 @@ fn test_show_with_direct_shows_only_root_deps() { #[serial] fn test_show_outdated_deps() { run_show_case( - input(vec![("command", PhpMixed::from("outdated"))]), + input(vec![("command", InputValue::from("outdated"))]), "Legend: ! patch or minor release available - update recommended ~ major release available - update possible @@ -191,8 +197,8 @@ outdated/patch 1.0.0 <highlight>! 1.0.1</highlight>", fn test_show_outdated_deps_sorting_by_age() { run_show_case( input(vec![ - ("command", PhpMixed::from("outdated")), - ("--sort-by-age", PhpMixed::from(true)), + ("command", InputValue::from("outdated")), + ("--sort-by-age", InputValue::from(true)), ]), "Legend: ! patch or minor release available - update recommended @@ -214,8 +220,8 @@ outdated/major 1.0.0 ~ 2.0.0 from today", fn test_show_outdated_deps_with_direct_only_show_direct_deps_with_updated() { run_show_case( input(vec![ - ("command", PhpMixed::from("outdated")), - ("--direct", PhpMixed::from(true)), + ("command", InputValue::from("outdated")), + ("--direct", InputValue::from(true)), ]), "Legend: ! patch or minor release available - update recommended @@ -233,8 +239,8 @@ outdated/major 1.0.0 ~ 2.0.0", fn test_show_outdated_deps_with_direct_show_msg_if_all_up_to_date() { run_show_case( input(vec![ - ("command", PhpMixed::from("outdated")), - ("--direct", PhpMixed::from(true)), + ("command", InputValue::from("outdated")), + ("--direct", InputValue::from(true)), ]), "All your direct dependencies are up to date", serde_json::json!({"vendor/package": "*"}), @@ -246,8 +252,8 @@ fn test_show_outdated_deps_with_direct_show_msg_if_all_up_to_date() { fn test_show_outdated_deps_with_major_only() { run_show_case( input(vec![ - ("command", PhpMixed::from("outdated")), - ("--major-only", PhpMixed::from(true)), + ("command", InputValue::from("outdated")), + ("--major-only", InputValue::from(true)), ]), "Legend: ! patch or minor release available - update recommended @@ -267,8 +273,8 @@ outdated/major 1.0.0 ~ 2.0.0", fn test_show_outdated_deps_with_minor_only() { run_show_case( input(vec![ - ("command", PhpMixed::from("outdated")), - ("--minor-only", PhpMixed::from(true)), + ("command", InputValue::from("outdated")), + ("--minor-only", InputValue::from(true)), ]), "Legend: ! patch or minor release available - update recommended @@ -289,8 +295,8 @@ outdated/patch 1.0.0 <highlight>! 1.0.1</highlight>", fn test_show_outdated_deps_with_patch_only() { run_show_case( input(vec![ - ("command", PhpMixed::from("outdated")), - ("--patch-only", PhpMixed::from(true)), + ("command", InputValue::from("outdated")), + ("--patch-only", InputValue::from(true)), ]), "Legend: ! patch or minor release available - update recommended @@ -334,7 +340,7 @@ fn test_outdated_filters_according_to_platform_reqs_and_warns() { let mut app_tester = get_application_tester(); app_tester .run( - input(vec![("command", PhpMixed::from("outdated"))]), + input(vec![("command", InputValue::from("outdated"))]), RunOptions::default(), ) .unwrap(); @@ -356,8 +362,8 @@ vendor/package 1.1.0 ~ 1.0.0", app_tester .run( input(vec![ - ("command", PhpMixed::from("outdated")), - ("--verbose", PhpMixed::from(true)), + ("command", InputValue::from("outdated")), + ("--verbose", InputValue::from(true)), ]), RunOptions::default(), ) @@ -406,7 +412,7 @@ fn test_outdated_filters_according_to_platform_reqs_without_warning_for_higher_v let mut app_tester = get_application_tester(); app_tester .run( - input(vec![("command", PhpMixed::from("outdated"))]), + input(vec![("command", InputValue::from("outdated"))]), RunOptions::default(), ) .unwrap(); @@ -455,9 +461,9 @@ fn test_show_direct_with_name_does_not_show_transient_dependencies() { let err = app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("--direct", PhpMixed::from(true)), - ("package", PhpMixed::from("vendor/package")), + ("command", InputValue::from("show")), + ("--direct", InputValue::from(true)), + ("package", InputValue::from("vendor/package")), ]), RunOptions::default(), ) @@ -502,9 +508,9 @@ fn test_show_direct_with_name_only_shows_direct_dependents() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("--direct", PhpMixed::from(true)), - ("package", PhpMixed::from("direct/dependent")), + ("command", InputValue::from("show")), + ("--direct", InputValue::from(true)), + ("package", InputValue::from("direct/dependent")), ]), RunOptions::default(), ) @@ -520,9 +526,9 @@ fn test_show_direct_with_name_only_shows_direct_dependents() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("--direct", PhpMixed::from(true)), - ("package", PhpMixed::from("direct/dependent2")), + ("command", InputValue::from("show")), + ("--direct", InputValue::from(true)), + ("package", InputValue::from("direct/dependent2")), ]), RunOptions::default(), ) @@ -583,8 +589,8 @@ fn test_show_platform_only_shows_platform_packages() { app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("-p", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("-p", InputValue::from(true)), ]), RunOptions::default(), ) @@ -605,8 +611,8 @@ fn test_show_platform_works_without_composer_json() { app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("-p", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("-p", InputValue::from(true)), ]), RunOptions::default(), ) @@ -618,9 +624,9 @@ fn test_show_platform_works_without_composer_json() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("-p", PhpMixed::from(true)), - ("package", PhpMixed::from("php")), + ("command", InputValue::from("show")), + ("-p", InputValue::from(true)), + ("package", InputValue::from("php")), ]), RunOptions::default(), ) @@ -630,10 +636,10 @@ fn test_show_platform_works_without_composer_json() { let status_code = app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("-p", PhpMixed::from(true)), - ("-f", PhpMixed::from("json")), - ("package", PhpMixed::from("php")), + ("command", InputValue::from("show")), + ("-p", InputValue::from(true)), + ("-f", InputValue::from("json")), + ("package", InputValue::from("php")), ]), RunOptions::default(), ) @@ -688,9 +694,9 @@ fn test_outdated_with_zero_major() { app_tester .run( input(vec![ - ("command", PhpMixed::from("outdated")), - ("--direct", PhpMixed::from(true)), - ("--patch-only", PhpMixed::from(true)), + ("command", InputValue::from("outdated")), + ("--direct", InputValue::from(true)), + ("--patch-only", InputValue::from(true)), ]), RunOptions::default(), ) @@ -707,9 +713,9 @@ zero/patch 0.1.2 <highlight>! 0.1.2.1</highlight>", app_tester .run( input(vec![ - ("command", PhpMixed::from("outdated")), - ("--direct", PhpMixed::from(true)), - ("--minor-only", PhpMixed::from(true)), + ("command", InputValue::from("outdated")), + ("--direct", InputValue::from(true)), + ("--minor-only", InputValue::from(true)), ]), RunOptions::default(), ) @@ -727,9 +733,9 @@ zero/patch 0.1.2 <highlight>! 0.1.2.1</highlight>", app_tester .run( input(vec![ - ("command", PhpMixed::from("outdated")), - ("--direct", PhpMixed::from(true)), - ("--major-only", PhpMixed::from(true)), + ("command", InputValue::from("outdated")), + ("--direct", InputValue::from(true)), + ("--major-only", InputValue::from(true)), ]), RunOptions::default(), ) @@ -775,8 +781,8 @@ fn test_show_all_shows_all_sections() { app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("--all", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("--all", InputValue::from(true)), ]), RunOptions::default(), ) @@ -810,8 +816,8 @@ fn test_locked_requires_valid_lock_file() { let err = app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("--locked", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("--locked", InputValue::from(true)), ]), RunOptions::default(), ) @@ -838,8 +844,8 @@ fn test_locked_shows_all_locked() { app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("--locked", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("--locked", InputValue::from(true)), ]), RunOptions::default(), ) @@ -857,8 +863,8 @@ fn test_locked_shows_all_locked() { app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("--locked", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("--locked", InputValue::from(true)), ]), RunOptions::default(), ) @@ -873,57 +879,57 @@ vendor/locked2 2.0.0 description of locked2 package", #[test] #[serial] fn test_invalid_option_combinations() { - let combos: Vec<Vec<(&str, PhpMixed)>> = vec![ + let combos: Vec<Vec<(&str, InputValue)>> = vec![ vec![ - ("--direct", PhpMixed::from(true)), - ("--all", PhpMixed::from(true)), + ("--direct", InputValue::from(true)), + ("--all", InputValue::from(true)), ], vec![ - ("--direct", PhpMixed::from(true)), - ("--available", PhpMixed::from(true)), + ("--direct", InputValue::from(true)), + ("--available", InputValue::from(true)), ], vec![ - ("--direct", PhpMixed::from(true)), - ("--platform", PhpMixed::from(true)), + ("--direct", InputValue::from(true)), + ("--platform", InputValue::from(true)), ], vec![ - ("--tree", PhpMixed::from(true)), - ("--all", PhpMixed::from(true)), + ("--tree", InputValue::from(true)), + ("--all", InputValue::from(true)), ], vec![ - ("--tree", PhpMixed::from(true)), - ("--available", PhpMixed::from(true)), + ("--tree", InputValue::from(true)), + ("--available", InputValue::from(true)), ], vec![ - ("--tree", PhpMixed::from(true)), - ("--latest", PhpMixed::from(true)), + ("--tree", InputValue::from(true)), + ("--latest", InputValue::from(true)), ], vec![ - ("--tree", PhpMixed::from(true)), - ("--path", PhpMixed::from(true)), + ("--tree", InputValue::from(true)), + ("--path", InputValue::from(true)), ], vec![ - ("--patch-only", PhpMixed::from(true)), - ("--minor-only", PhpMixed::from(true)), + ("--patch-only", InputValue::from(true)), + ("--minor-only", InputValue::from(true)), ], vec![ - ("--patch-only", PhpMixed::from(true)), - ("--major-only", PhpMixed::from(true)), + ("--patch-only", InputValue::from(true)), + ("--major-only", InputValue::from(true)), ], vec![ - ("--minor-only", PhpMixed::from(true)), - ("--major-only", PhpMixed::from(true)), + ("--minor-only", InputValue::from(true)), + ("--major-only", InputValue::from(true)), ], vec![ - ("--minor-only", PhpMixed::from(true)), - ("--major-only", PhpMixed::from(true)), - ("--patch-only", PhpMixed::from(true)), + ("--minor-only", InputValue::from(true)), + ("--major-only", InputValue::from(true)), + ("--patch-only", InputValue::from(true)), ], - vec![("--format", PhpMixed::from("test"))], + vec![("--format", InputValue::from("test"))], ]; for combo in combos { - let mut pairs = vec![("command", PhpMixed::from("show"))]; + let mut pairs = vec![("command", InputValue::from("show"))]; pairs.extend(combo.clone()); let mut app_tester = get_application_tester(); let status_code = app_tester.run(input(pairs), RunOptions::default()).unwrap(); @@ -940,8 +946,8 @@ fn test_ignored_option_combinations() { app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("--installed", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("--installed", InputValue::from(true)), ]), RunOptions::default(), ) @@ -956,10 +962,10 @@ fn test_ignored_option_combinations() { app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), + ("command", InputValue::from("show")), ( "--ignore", - PhpMixed::List(vec![PhpMixed::from("vendor/package")]), + InputValue::Array(vec!["vendor/package".to_string()]), ), ]), RunOptions::default(), @@ -986,9 +992,9 @@ fn test_self_and_name_only() { app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("--self", PhpMixed::from(true)), - ("--name-only", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("--self", InputValue::from(true)), + ("--name-only", InputValue::from(true)), ]), RunOptions::default(), ) @@ -1009,9 +1015,9 @@ fn test_self_and_package_combination() { let mut app_tester = get_application_tester(); let result = app_tester.run( input(vec![ - ("command", PhpMixed::from("show")), - ("--self", PhpMixed::from(true)), - ("package", PhpMixed::from("vendor/package")), + ("command", InputValue::from("show")), + ("--self", InputValue::from(true)), + ("package", InputValue::from("vendor/package")), ]), RunOptions::default(), ); @@ -1045,8 +1051,8 @@ fn test_self() { app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("--self", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("--self", InputValue::from(true)), ]), RunOptions::default(), ) @@ -1091,7 +1097,7 @@ fn test_not_installed_error() { let mut app_tester = get_application_tester(); app_tester .run( - input(vec![("command", PhpMixed::from("show"))]), + input(vec![("command", InputValue::from("show"))]), RunOptions::default(), ) .unwrap(); @@ -1129,8 +1135,8 @@ fn test_no_dev_option() { app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("--no-dev", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("--no-dev", InputValue::from(true)), ]), RunOptions::default(), ) @@ -1169,8 +1175,8 @@ fn test_package_filter() { app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("package", PhpMixed::from("vendor/package")), + ("command", InputValue::from("show")), + ("package", InputValue::from("vendor/package")), ]), RunOptions::default(), ) @@ -1186,9 +1192,9 @@ fn test_package_filter() { app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("package", PhpMixed::from("company/*")), - ("--name-only", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("package", InputValue::from("company/*")), + ("--name-only", InputValue::from(true)), ]), RunOptions::default(), ) @@ -1202,7 +1208,7 @@ fn test_package_filter() { } /// ref: ShowCommandTest::testNotExistingPackage (one data-provider case). -fn run_not_existing_package_case(package: &str, options: Vec<(&str, PhpMixed)>, expected: &str) { +fn run_not_existing_package_case(package: &str, options: Vec<(&str, InputValue)>, expected: &str) { let _tear_down = init_temp_composer( Some(&serde_json::json!({ "require": {"vendor/package": "1.0.0"}, @@ -1216,8 +1222,8 @@ fn run_not_existing_package_case(package: &str, options: Vec<(&str, PhpMixed)>, create_composer_lock(&[pkg], &[]); let mut pairs = vec![ - ("command", PhpMixed::from("show")), - ("package", PhpMixed::from(package)), + ("command", InputValue::from("show")), + ("package", InputValue::from(package)), ]; pairs.extend(options); @@ -1248,7 +1254,7 @@ fn test_not_existing_package_with_no_options() { fn test_not_existing_package_with_all_option() { run_not_existing_package_case( "not/existing", - vec![("--all", PhpMixed::from(true))], + vec![("--all", InputValue::from(true))], "Package \"not/existing\" not found.", ); } @@ -1258,7 +1264,7 @@ fn test_not_existing_package_with_all_option() { fn test_not_existing_package_with_locked_option() { run_not_existing_package_case( "not/existing", - vec![("--locked", PhpMixed::from(true))], + vec![("--locked", InputValue::from(true))], "Package \"not/existing\" not found in lock file, try using --available (-a) to show all available packages.", ); } @@ -1268,7 +1274,7 @@ fn test_not_existing_package_with_locked_option() { fn test_not_existing_platform_with_platform_option() { run_not_existing_package_case( "ext-nonexisting", - vec![("--platform", PhpMixed::from(true))], + vec![("--platform", InputValue::from(true))], "Package \"ext-nonexisting\" not found, try using --available (-a) to show all available packages.", ); } @@ -1306,11 +1312,11 @@ fn test_not_existing_package_with_working_dir() { let err = app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("package", PhpMixed::from("not/existing")), + ("command", InputValue::from("show")), + ("package", InputValue::from("not/existing")), ( "--working-dir", - PhpMixed::from(dir.display().to_string().as_str()), + InputValue::from(dir.display().to_string().as_str()), ), ]), RunOptions::default(), @@ -1329,7 +1335,7 @@ fn test_not_existing_package_with_working_dir() { /// ref: ShowCommandTest::testSpecificPackageAndTree (one data-provider case). fn run_specific_package_and_tree_case( packages: Vec<PackageInterfaceHandle>, - options: Vec<(&str, PhpMixed)>, + options: Vec<(&str, InputValue)>, expected: &str, ) { let _tear_down = init_temp_composer( @@ -1344,9 +1350,9 @@ fn run_specific_package_and_tree_case( create_installed_json(&packages, &[], true); let mut pairs = vec![ - ("command", PhpMixed::from("show")), - ("package", PhpMixed::from("vendor/package")), - ("--tree", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("package", InputValue::from("vendor/package")), + ("--tree", InputValue::from(true)), ]; pairs.extend(options); @@ -1416,7 +1422,7 @@ fn test_specific_package_and_tree_with_json_format() { let pkg = get_package("vendor/package", "1.0.0"); run_specific_package_and_tree_case( vec![pkg], - vec![("--format", PhpMixed::from("json"))], + vec![("--format", InputValue::from("json"))], "{ \"installed\": [ { @@ -1467,8 +1473,8 @@ fn test_name_only_prints_no_trailing_whitespace() { app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("-N", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("-N", InputValue::from(true)), ]), RunOptions::default(), ) @@ -1484,9 +1490,9 @@ vendor/somepackage", app_tester .run( input(vec![ - ("command", PhpMixed::from("show")), - ("--outdated", PhpMixed::from(true)), - ("-N", PhpMixed::from(true)), + ("command", InputValue::from("show")), + ("--outdated", InputValue::from(true)), + ("-N", InputValue::from(true)), ]), RunOptions::default(), ) diff --git a/crates/shirabe/tests/command/status_command_test.rs b/crates/shirabe/tests/command/status_command_test.rs index 32b8390a..a5571856 100644 --- a/crates/shirabe/tests/command/status_command_test.rs +++ b/crates/shirabe/tests/command/status_command_test.rs @@ -6,12 +6,13 @@ use crate::test_case::{ }; use serial_test::serial; use shirabe::package::handle::PackageInterfaceHandle; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; -fn input(pairs: Vec<(&str, PhpMixed)>) -> Vec<(PhpMixed, PhpMixed)> { +fn input(pairs: Vec<(&str, InputValue)>) -> Vec<(ParameterName, InputValue)> { pairs .into_iter() - .map(|(k, v)| (PhpMixed::from(k), v)) + .map(|(k, v)| (ParameterName::of(k), v)) .collect() } @@ -36,7 +37,7 @@ fn test_no_local_changes() { let mut app_tester = get_application_tester(); app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("status"))], + vec![(ParameterName::of("command"), InputValue::from("status"))], RunOptions::default(), ) .unwrap(); @@ -59,7 +60,7 @@ struct LocallyModifiedPackageData { /// ref: StatusCommandTest::testLocallyModifiedPackages (data provider rolled into a helper). fn run_locally_modified_packages_case( composer_json: serde_json::Value, - command_flags: Vec<(&str, PhpMixed)>, + command_flags: Vec<(&str, InputValue)>, package_data: LocallyModifiedPackageData, ) { let _tear_down = init_temp_composer(Some(&composer_json), None, None, true); @@ -84,7 +85,7 @@ fn run_locally_modified_packages_case( let mut app_tester = get_application_tester(); app_tester .run( - input(vec![("command", PhpMixed::from("install"))]), + input(vec![("command", InputValue::from("install"))]), RunOptions::default(), ) .unwrap(); @@ -99,7 +100,7 @@ fn run_locally_modified_packages_case( ) .unwrap(); - let mut status_input = vec![("command", PhpMixed::from("status"))]; + let mut status_input = vec![("command", InputValue::from("status"))]; status_input.extend(command_flags); app_tester .run(input(status_input), RunOptions::default()) @@ -135,7 +136,7 @@ fn test_locally_modified_packages_from_source() { fn test_locally_modified_packages_from_dist() { run_locally_modified_packages_case( serde_json::json!({ "require": { "smarty/smarty": "^3.1" } }), - vec![("--verbose", PhpMixed::from(true))], + vec![("--verbose", InputValue::from(true))], LocallyModifiedPackageData { name: "smarty/smarty", version: "3.1.7", diff --git a/crates/shirabe/tests/command/suggests_command_test.rs b/crates/shirabe/tests/command/suggests_command_test.rs index dd793c40..6236e3f9 100644 --- a/crates/shirabe/tests/command/suggests_command_test.rs +++ b/crates/shirabe/tests/command/suggests_command_test.rs @@ -8,7 +8,8 @@ use indexmap::IndexMap; use serial_test::serial; use shirabe::package::Link; use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle}; -use shirabe_php_shim::PhpMixed; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; /// ref: SuggestsCommandTest::getPackageWithSuggestAndRequires fn get_package_with_suggest_and_requires( @@ -82,7 +83,7 @@ fn test_installed_packages_with_no_suggestions() { let mut app_tester = get_application_tester(); let status_code = app_tester .run( - vec![(PhpMixed::from("command"), PhpMixed::from("suggest"))], + vec![(ParameterName::of("command"), InputValue::from("suggest"))], RunOptions::default(), ) .unwrap(); @@ -171,7 +172,7 @@ fn suggest_packages() -> (Vec<PackageInterfaceHandle>, Vec<PackageInterfaceHandl (packages, dev_packages) } -fn run_suggest_case(has_lock_file: bool, command: &[(&str, PhpMixed)], expected: &str) { +fn run_suggest_case(has_lock_file: bool, command: &[(&str, InputValue)], expected: &str) { let tear_down = init_temp_composer( Some(&serde_json::json!({ "repositories": { @@ -199,10 +200,10 @@ fn run_suggest_case(has_lock_file: bool, command: &[(&str, PhpMixed)], expected: create_composer_lock(&packages, &dev_packages); } - let mut input: Vec<(PhpMixed, PhpMixed)> = - vec![(PhpMixed::from("command"), PhpMixed::from("suggest"))]; + let mut input: Vec<(ParameterName, InputValue)> = + vec![(ParameterName::of("command"), InputValue::from("suggest"))]; for (k, v) in command { - input.push((PhpMixed::from(*k), v.clone())); + input.push((ParameterName::of(k), v.clone())); } let mut app_tester = get_application_tester(); @@ -216,7 +217,7 @@ fn run_suggest_case(has_lock_file: bool, command: &[(&str, PhpMixed)], expected: #[test] #[serial] fn test_suggest() { - let t = PhpMixed::from(true); + let t = InputValue::from(true); let by_package = ("--by-package", t.clone()); let by_suggestion = ("--by-suggestion", t.clone()); let no_dev = ("--no-dev", t.clone()); @@ -359,7 +360,7 @@ vendor3/suggested is suggested by: true, &[( "packages", - PhpMixed::List(vec![PhpMixed::from("vendor2/package2")]), + InputValue::Array(vec!["vendor2/package2".to_string()]), )], for_pkg, ); @@ -367,7 +368,7 @@ vendor3/suggested is suggested by: false, &[( "packages", - PhpMixed::List(vec![PhpMixed::from("vendor2/package2")]), + InputValue::Array(vec!["vendor2/package2".to_string()]), )], for_pkg, ); diff --git a/crates/shirabe/tests/command/update_command_test.rs b/crates/shirabe/tests/command/update_command_test.rs index 3aa42880..6fe8f927 100644 --- a/crates/shirabe/tests/command/update_command_test.rs +++ b/crates/shirabe/tests/command/update_command_test.rs @@ -6,13 +6,14 @@ use crate::test_case::{ }; use serial_test::serial; use shirabe::package::Link; -use shirabe_php_shim::PhpMixed; use shirabe_semver::constraint::{AnyConstraint, MatchAllConstraint}; +use shirabe_symfony_console::input::InputValue; +use shirabe_symfony_console::input::ParameterName; -fn input(pairs: Vec<(&str, PhpMixed)>) -> Vec<(PhpMixed, PhpMixed)> { +fn input(pairs: Vec<(&str, InputValue)>) -> Vec<(ParameterName, InputValue)> { pairs .into_iter() - .map(|(k, v)| (PhpMixed::from(k), v)) + .map(|(k, v)| (ParameterName::of(k), v)) .collect() } @@ -75,7 +76,7 @@ fn root_dep_and_transitive_dep() -> serde_json::Value { fn provide_updates() -> Vec<( &'static str, serde_json::Value, - Vec<(&'static str, PhpMixed)>, + Vec<(&'static str, InputValue)>, &'static str, bool, )> { @@ -98,7 +99,7 @@ Package operations: 2 installs, 0 updates, 0 removals ( "simple update with very verbose output", root_dep_and_transitive_dep(), - vec![("-vv", PhpMixed::from(true))], + vec![("-vv", InputValue::from(true))], "Loading composer repositories with package information Updating dependencies Dependency resolution completed in %f seconds @@ -119,8 +120,8 @@ Installs: dep/pkg:1.0.2, root/req:1.0.0 "update with temporary constraint + --no-install", root_dep_and_transitive_dep(), vec![ - ("--with", PhpMixed::List(vec![PhpMixed::from("dep/pkg:1.0.0")])), - ("--no-install", PhpMixed::from(true)), + ("--with", InputValue::Array(vec!["dep/pkg:1.0.0".to_string()])), + ("--no-install", InputValue::from(true)), ], "Loading composer repositories with package information Updating dependencies @@ -132,7 +133,7 @@ Lock file operations: 2 installs, 0 updates, 0 removals ( "update with temporary constraint failing resolution", root_dep_and_transitive_dep(), - vec![("--with", PhpMixed::List(vec![PhpMixed::from("dep/pkg:^2")]))], + vec![("--with", InputValue::Array(vec!["dep/pkg:^2".to_string()]))], "Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages. @@ -145,7 +146,7 @@ Your requirements could not be resolved to an installable set of packages. ( "update with temporary constraint failing resolution on root package", root_dep_and_transitive_dep(), - vec![("--with", PhpMixed::List(vec![PhpMixed::from("root/req:^2")]))], + vec![("--with", InputValue::Array(vec!["root/req:^2".to_string()]))], "The temporary constraint \"^2\" for \"root/req\" must be a subset of the constraint in your composer.json (1.*) Run `composer require root/req` or `composer require root/req:^2` instead to replace the constraint", false, @@ -153,7 +154,7 @@ Run `composer require root/req` or `composer require root/req:^2` instead to rep ( "update & bump", root_dep_and_transitive_dep(), - vec![("--bump-after-update", PhpMixed::from(true))], + vec![("--bump-after-update", InputValue::from(true))], "Loading composer repositories with package information Updating dependencies Lock file operations: 2 installs, 0 updates, 0 removals @@ -174,8 +175,8 @@ No requirements to update in ./composer.json.", "update & bump with lock", root_dep_and_transitive_dep(), vec![ - ("--bump-after-update", PhpMixed::from(true)), - ("--lock", PhpMixed::from(true)), + ("--bump-after-update", InputValue::from(true)), + ("--lock", InputValue::from(true)), ], "Loading composer repositories with package information Updating dependencies @@ -187,7 +188,7 @@ Nothing to install, update or remove", ( "update & bump dev only", root_dep_and_transitive_dep(), - vec![("--bump-after-update", PhpMixed::from("dev"))], + vec![("--bump-after-update", InputValue::from("dev"))], "Loading composer repositories with package information Updating dependencies Lock file operations: 2 installs, 0 updates, 0 removals @@ -205,8 +206,8 @@ No requirements to update in ./composer.json.", "update & dump with failing update", root_dep_and_transitive_dep(), vec![ - ("--with", PhpMixed::List(vec![PhpMixed::from("dep/pkg:^2")])), - ("--bump-after-update", PhpMixed::from(true)), + ("--with", InputValue::Array(vec!["dep/pkg:^2".to_string()])), + ("--bump-after-update", InputValue::from(true)), ], "Loading composer repositories with package information Updating dependencies @@ -220,7 +221,7 @@ Your requirements could not be resolved to an installable set of packages. ( "update with replaced name filter fails to resolve", root_dep_and_transitive_dep(), - vec![("--with", PhpMixed::List(vec![PhpMixed::from("replaced/pkg:^2")]))], + vec![("--with", InputValue::Array(vec!["replaced/pkg:^2".to_string()]))], "Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages. @@ -245,9 +246,9 @@ fn test_update() { let mut app_tester = get_application_tester(); let mut args = vec![ - ("command", PhpMixed::from("update")), - ("--dry-run", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), + ("command", InputValue::from("update")), + ("--dry-run", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), ]; args.extend(command); app_tester.run(input(args), RunOptions::default()).unwrap(); @@ -286,14 +287,14 @@ fn test_update_with_patch_only() { app_tester .run( input(vec![ - ("command", PhpMixed::from("update")), - ("--dry-run", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), - ("--no-install", PhpMixed::from(true)), - ("--patch-only", PhpMixed::from(true)), + ("command", InputValue::from("update")), + ("--dry-run", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), + ("--no-install", InputValue::from(true)), + ("--patch-only", InputValue::from(true)), ( "--with", - PhpMixed::List(vec![PhpMixed::from("root/req:^1.1")]), + InputValue::Array(vec!["root/req:^1.1".to_string()]), ), ]), RunOptions::default(), @@ -317,21 +318,18 @@ Your requirements could not be resolved to an installable set of packages. app_tester .run( input(vec![ - ("command", PhpMixed::from("update")), - ("--dry-run", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), - ("--no-install", PhpMixed::from(true)), - ("--patch-only", PhpMixed::from(true)), + ("command", InputValue::from("update")), + ("--dry-run", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), + ("--no-install", InputValue::from(true)), + ("--patch-only", InputValue::from(true)), ( "--with", - PhpMixed::List(vec![PhpMixed::from("root/req:^1.0.1")]), + InputValue::Array(vec!["root/req:^1.0.1".to_string()]), ), ( "packages", - PhpMixed::List(vec![ - PhpMixed::from("root/req"), - PhpMixed::from("root/req2"), - ]), + InputValue::Array(vec!["root/req".to_string(), "root/req2".to_string()]), ), ]), RunOptions::default(), @@ -365,8 +363,8 @@ fn test_interactive_mode_throws_if_no_package_to_update() { let err = app_tester .run( input(vec![ - ("command", PhpMixed::from("update")), - ("--interactive", PhpMixed::from(true)), + ("command", InputValue::from("update")), + ("--interactive", InputValue::from(true)), ]), RunOptions::default(), ) @@ -396,8 +394,8 @@ fn test_interactive_mode_throws_if_no_package_entered() { let err = app_tester .run( input(vec![ - ("command", PhpMixed::from("update")), - ("--interactive", PhpMixed::from(true)), + ("command", InputValue::from("update")), + ("--interactive", InputValue::from(true)), ]), RunOptions::default(), ) @@ -492,10 +490,10 @@ fn test_interactive_tmp() { app_tester .run( input(vec![ - ("command", PhpMixed::from("update")), - ("--interactive", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), - ("--dry-run", PhpMixed::from(true)), + ("command", InputValue::from("update")), + ("--interactive", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), + ("--dry-run", InputValue::from(true)), ]), RunOptions { interactive: Some(true), @@ -550,10 +548,10 @@ fn test_no_security_blocking_allows_insecure_packages() { app_tester .run( input(vec![ - ("command", PhpMixed::from("update")), - ("--dry-run", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), - ("--no-install", PhpMixed::from(true)), + ("command", InputValue::from("update")), + ("--dry-run", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), + ("--no-install", InputValue::from(true)), ]), RunOptions::default(), ) @@ -573,11 +571,11 @@ fn test_no_security_blocking_allows_insecure_packages() { app_tester .run( input(vec![ - ("command", PhpMixed::from("update")), - ("--dry-run", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), - ("--no-install", PhpMixed::from(true)), - ("--no-security-blocking", PhpMixed::from(true)), + ("command", InputValue::from("update")), + ("--dry-run", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), + ("--no-install", InputValue::from(true)), + ("--no-security-blocking", InputValue::from(true)), ]), RunOptions::default(), ) @@ -610,10 +608,10 @@ fn test_bump_after_update_without_lockfile() { app_tester .run( input(vec![ - ("command", PhpMixed::from("update")), - ("--dry-run", PhpMixed::from(true)), - ("--no-audit", PhpMixed::from(true)), - ("--bump-after-update", PhpMixed::from("dev")), + ("command", InputValue::from("update")), + ("--dry-run", InputValue::from(true)), + ("--no-audit", InputValue::from(true)), + ("--bump-after-update", InputValue::from("dev")), ]), RunOptions::default(), ) diff --git a/crates/shirabe/tests/command/validate_command_test.rs b/crates/shirabe/tests/command/validate_command_test.rs index 67370df0..fb05b423 100644 --- a/crates/shirabe/tests/command/validate_command_test.rs +++ b/crates/shirabe/tests/command/validate_command_test.rs @@ -5,7 +5,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; /// ref: ValidateCommandTest::MINIMAL_VALID_CONFIGURATION fn minimal_valid_configuration() -> serde_json::Value { @@ -31,8 +32,8 @@ fn minimal_valid_configuration() -> serde_json::Value { }) } -fn validate_input(command: Vec<(PhpMixed, PhpMixed)>) -> Vec<(PhpMixed, PhpMixed)> { - let mut input = vec![(PhpMixed::from("command"), PhpMixed::from("validate"))]; +fn validate_input(command: Vec<(ParameterName, InputValue)>) -> Vec<(ParameterName, InputValue)> { + let mut input = vec![(ParameterName::of("command"), InputValue::from("validate"))]; input.extend(command); input } @@ -40,7 +41,7 @@ fn validate_input(command: Vec<(PhpMixed, PhpMixed)>) -> Vec<(PhpMixed, PhpMixed struct ValidateCase { name: &'static str, composer_json: serde_json::Value, - command: Vec<(PhpMixed, PhpMixed)>, + command: Vec<(ParameterName, InputValue)>, expected: &'static str, } @@ -86,7 +87,10 @@ fn provide_validate_tests() -> Vec<ValidateCase> { ValidateCase { name: "passing without publish-check", composer_json: publish_data_stripped, - command: vec![(PhpMixed::from("--no-check-publish"), PhpMixed::Bool(true))], + command: vec![( + ParameterName::of("--no-check-publish"), + InputValue::Bool(true), + )], expected: "./composer.json is valid, but with a few warnings\n<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>\n<warning># General warnings</warning>\n- No license specified, it is recommended to do so. For closed-source software you may use \"proprietary\" as license.", }, ] |
