diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-21 01:00:23 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-21 01:00:23 +0900 |
| commit | 2f45a943d17c80e2ee3808d34440b0ad3002615c (patch) | |
| tree | 23c5141be44e43c60ff2ba12f3177686c5f8b4b1 /crates | |
| parent | 3edd08813f4c8e08f983cf19568dc91d1b368417 (diff) | |
| download | php-shirabe-2f45a943d17c80e2ee3808d34440b0ad3002615c.tar.gz php-shirabe-2f45a943d17c80e2ee3808d34440b0ad3002615c.tar.zst php-shirabe-2f45a943d17c80e2ee3808d34440b0ad3002615c.zip | |
test(io): port NullIOTest
All eight cases pass against NullIO's no-op IOInterfaceImmutable methods.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/shirabe/tests/io/main.rs | 1 | ||||
| -rw-r--r-- | crates/shirabe/tests/io/null_io_test.rs | 88 |
2 files changed, 89 insertions, 0 deletions
diff --git a/crates/shirabe/tests/io/main.rs b/crates/shirabe/tests/io/main.rs index 00f19c8..68d66a3 100644 --- a/crates/shirabe/tests/io/main.rs +++ b/crates/shirabe/tests/io/main.rs @@ -1 +1,2 @@ mod buffer_io_test; +mod null_io_test; diff --git a/crates/shirabe/tests/io/null_io_test.rs b/crates/shirabe/tests/io/null_io_test.rs index 78ae3ec..75678b9 100644 --- a/crates/shirabe/tests/io/null_io_test.rs +++ b/crates/shirabe/tests/io/null_io_test.rs @@ -1 +1,89 @@ //! ref: composer/tests/Composer/Test/IO/NullIOTest.php + +use indexmap::IndexMap; +use shirabe::io::IOInterfaceImmutable; +use shirabe::io::null_io::NullIO; +use shirabe_php_shim::PhpMixed; + +#[test] +fn test_is_interactive() { + let io = NullIO::new(); + + assert!(!io.is_interactive()); +} + +#[test] +fn test_has_authentication() { + let io = NullIO::new(); + + assert!(!io.has_authentication("foo")); +} + +#[test] +fn test_ask_and_hide_answer() { + let io = NullIO::new(); + + assert_eq!(None, io.ask_and_hide_answer("foo".to_string())); +} + +#[test] +fn test_get_authentications() { + let io = NullIO::new(); + + assert!(io.get_authentications().is_empty()); + + let mut expected: IndexMap<String, Option<String>> = IndexMap::new(); + expected.insert("username".to_string(), None); + expected.insert("password".to_string(), None); + assert_eq!(expected, io.get_authentication("foo")); +} + +#[test] +fn test_ask() { + let io = NullIO::new(); + + assert_eq!( + PhpMixed::String("foo".to_string()), + io.ask("bar".to_string(), PhpMixed::String("foo".to_string())) + ); +} + +#[test] +fn test_ask_confirmation() { + let io = NullIO::new(); + + assert!(!io.ask_confirmation("bar".to_string(), false)); +} + +#[test] +fn test_ask_and_validate() { + let io = NullIO::new(); + + assert_eq!( + PhpMixed::String("foo".to_string()), + io.ask_and_validate( + "question".to_string(), + Box::new(|_x| Ok(PhpMixed::Bool(true))), + None, + PhpMixed::String("foo".to_string()) + ) + .unwrap() + ); +} + +#[test] +fn test_select() { + let io = NullIO::new(); + + assert_eq!( + PhpMixed::String("1".to_string()), + io.select( + "question".to_string(), + vec!["item1".to_string(), "item2".to_string()], + PhpMixed::String("1".to_string()), + PhpMixed::Int(2), + "foo".to_string(), + true + ) + ); +} |
