aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/io
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-22 02:09:59 +0900
committernsfisis <nsfisis@gmail.com>2026-06-22 02:09:59 +0900
commit822d9a872807a92a5337ee8b7bab96dc9845cdbb (patch)
tree4931365df5978caffade69cad2154718a9076f66 /crates/shirabe/tests/io
parentf691b864b687f251c3b266e8cff2774d730567ba (diff)
downloadphp-shirabe-822d9a872807a92a5337ee8b7bab96dc9845cdbb.tar.gz
php-shirabe-822d9a872807a92a5337ee8b7bab96dc9845cdbb.tar.zst
php-shirabe-822d9a872807a92a5337ee8b7bab96dc9845cdbb.zip
test: port more test cases
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/io')
-rw-r--r--crates/shirabe/tests/io/console_io_test.rs80
1 files changed, 64 insertions, 16 deletions
diff --git a/crates/shirabe/tests/io/console_io_test.rs b/crates/shirabe/tests/io/console_io_test.rs
index a931a8b..c1adbd4 100644
--- a/crates/shirabe/tests/io/console_io_test.rs
+++ b/crates/shirabe/tests/io/console_io_test.rs
@@ -2,80 +2,128 @@
// These mock Symfony's InputInterface/OutputInterface/HelperSet (and QuestionHelper) to
// drive ConsoleIO; those console abstractions are not ported.
+
+use indexmap::IndexMap;
+use shirabe::io::ConsoleIO;
+use shirabe::io::IOInterfaceImmutable;
+use shirabe::io::IOInterfaceMutable;
+use shirabe_external_packages::symfony::console::helper::HelperSet;
+use shirabe_external_packages::symfony::console::input::array_input::ArrayInput;
+use shirabe_external_packages::symfony::console::input::input_interface::InputInterface;
+use shirabe_external_packages::symfony::console::output::buffered_output::BufferedOutput;
+use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface;
+use std::cell::RefCell;
+use std::rc::Rc;
+
+/// Builds a ConsoleIO backed by real, side-effect-free Input/Output/HelperSet. PHP uses
+/// PHPUnit mocks here, but for tests that exercise only the authentication map they carry no
+/// expectations, so concrete implementations are an exact substitute.
+fn make_console_io() -> ConsoleIO {
+ let input: Rc<RefCell<dyn InputInterface>> =
+ Rc::new(RefCell::new(ArrayInput::new(vec![], None).unwrap()));
+ let output: Rc<RefCell<dyn OutputInterface>> =
+ Rc::new(RefCell::new(BufferedOutput::new(None, false, None)));
+ let helper_set = HelperSet::default();
+ ConsoleIO::new(input, output, helper_set)
+}
+
+#[ignore = "requires a PHPUnit mock of InputInterface::isInteractive with willReturnOnConsecutiveCalls; no mocking framework"]
#[test]
-#[ignore = "mocks Symfony Input/Output/HelperSet to drive ConsoleIO; not ported"]
fn test_is_interactive() {
todo!()
}
+#[ignore = "requires a PHPUnit mock of OutputInterface with expects()->method('write')->with() expectation verification; no mocking framework"]
#[test]
-#[ignore = "mocks Symfony Input/Output/HelperSet to drive ConsoleIO; not ported"]
fn test_write() {
todo!()
}
+#[ignore = "requires a PHPUnit mock of ConsoleOutputInterface with getErrorOutput/write expectation verification; no mocking framework"]
#[test]
-#[ignore = "mocks Symfony Input/Output/HelperSet to drive ConsoleIO; not ported"]
fn test_write_error() {
todo!()
}
+#[ignore = "requires a PHPUnit mock of OutputInterface with a write() callback expectation verification; no mocking framework"]
#[test]
-#[ignore = "mocks Symfony Input/Output/HelperSet to drive ConsoleIO; not ported"]
fn test_write_with_multiple_line_string_when_debugging() {
todo!()
}
+#[ignore = "requires a PHPUnit mock of OutputInterface with willReturnCallback series expectation verification; no mocking framework"]
#[test]
-#[ignore = "mocks Symfony Input/Output/HelperSet to drive ConsoleIO; not ported"]
fn test_overwrite() {
todo!()
}
+#[ignore = "requires a PHPUnit mock of QuestionHelper/HelperSet with ask/get expectation verification; no mocking framework"]
#[test]
-#[ignore = "mocks Symfony Input/Output/HelperSet to drive ConsoleIO; not ported"]
fn test_ask() {
todo!()
}
+#[ignore = "requires a PHPUnit mock of QuestionHelper/HelperSet with ask/get expectation verification; no mocking framework"]
#[test]
-#[ignore = "mocks Symfony Input/Output/HelperSet to drive ConsoleIO; not ported"]
fn test_ask_confirmation() {
todo!()
}
+#[ignore = "requires a PHPUnit mock of QuestionHelper/HelperSet with ask/get expectation verification; no mocking framework"]
#[test]
-#[ignore = "mocks Symfony Input/Output/HelperSet to drive ConsoleIO; not ported"]
fn test_ask_and_validate() {
todo!()
}
+#[ignore = "requires a PHPUnit mock of QuestionHelper/HelperSet with ask/get expectation verification; no mocking framework"]
#[test]
-#[ignore = "mocks Symfony Input/Output/HelperSet to drive ConsoleIO; not ported"]
fn test_select() {
todo!()
}
+#[ignore]
#[test]
-#[ignore = "mocks Symfony Input/Output/HelperSet to drive ConsoleIO; not ported"]
fn test_set_and_get_authentication() {
- todo!()
+ let mut console_io = make_console_io();
+ console_io.set_authentication(
+ "repoName".to_string(),
+ "l3l0".to_string(),
+ Some("passwd".to_string()),
+ );
+
+ let mut expected: IndexMap<String, Option<String>> = IndexMap::new();
+ expected.insert("username".to_string(), Some("l3l0".to_string()));
+ expected.insert("password".to_string(), Some("passwd".to_string()));
+ assert_eq!(expected, console_io.get_authentication("repoName"));
}
+#[ignore]
#[test]
-#[ignore = "mocks Symfony Input/Output/HelperSet to drive ConsoleIO; not ported"]
fn test_get_authentication_when_did_not_set() {
- todo!()
+ let console_io = make_console_io();
+
+ let mut expected: IndexMap<String, Option<String>> = IndexMap::new();
+ expected.insert("username".to_string(), None);
+ expected.insert("password".to_string(), None);
+ assert_eq!(expected, console_io.get_authentication("repoName"));
}
+#[ignore]
#[test]
-#[ignore = "mocks Symfony Input/Output/HelperSet to drive ConsoleIO; not ported"]
fn test_has_authentication() {
- todo!()
+ let mut console_io = make_console_io();
+ console_io.set_authentication(
+ "repoName".to_string(),
+ "l3l0".to_string(),
+ Some("passwd".to_string()),
+ );
+
+ assert!(console_io.has_authentication("repoName"));
+ assert!(!console_io.has_authentication("repoName2"));
}
+#[ignore = "data provider includes malformed-UTF-8 inputs (e.g. \\xFF, \\xC3\\x28); sanitize() takes PhpMixed::String which is UTF-8-only and cannot carry invalid bytes, so those cases are unrepresentable"]
#[test]
-#[ignore = "mocks Symfony Input/Output/HelperSet to drive ConsoleIO; not ported"]
fn test_sanitize() {
todo!()
}