diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-23 01:41:33 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-23 01:41:33 +0900 |
| commit | 421d98d9a52dd036acd5632f9049f4503c9add18 (patch) | |
| tree | 578d4bc15a7cb01a591393df85d0b9cdfd7d6ea2 /crates/shirabe/tests/io | |
| parent | 894764ecb04f9c456b9ebda77d155bf6128e2175 (diff) | |
| download | php-shirabe-421d98d9a52dd036acd5632f9049f4503c9add18.tar.gz php-shirabe-421d98d9a52dd036acd5632f9049f4503c9add18.tar.zst php-shirabe-421d98d9a52dd036acd5632f9049f4503c9add18.zip | |
refactor(io): hold QuestionHelper directly in ConsoleIO instead of HelperSet
Every ConsoleIO construction site only ever registers a single QuestionHelper
(production) or none (tests), and routing asks through HelperSet::get('question')
loses the concrete type, forcing a downcast back to QuestionHelper. Receive the
QuestionHelper in the constructor and hold it directly (in a RefCell, since
QuestionHelper::ask takes &mut self while the IOInterfaceImmutable ask methods are
&self), dropping the HelperSet field and the throwaway HelperSet built at each
call site.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/io')
| -rw-r--r-- | crates/shirabe/tests/io/console_io_test.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/crates/shirabe/tests/io/console_io_test.rs b/crates/shirabe/tests/io/console_io_test.rs index a79b7ca..3c8242a 100644 --- a/crates/shirabe/tests/io/console_io_test.rs +++ b/crates/shirabe/tests/io/console_io_test.rs @@ -7,7 +7,7 @@ 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::helper::QuestionHelper; 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; @@ -15,7 +15,7 @@ use shirabe_external_packages::symfony::console::output::output_interface::Outpu use std::cell::RefCell; use std::rc::Rc; -/// Builds a ConsoleIO backed by real, side-effect-free Input/Output/HelperSet. PHP uses +/// Builds a ConsoleIO backed by real, side-effect-free Input/Output/QuestionHelper. 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 { @@ -23,8 +23,7 @@ fn make_console_io() -> ConsoleIO { 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) + ConsoleIO::new(input, output, QuestionHelper::default()) } #[ignore = "requires a PHPUnit mock of InputInterface::isInteractive with willReturnOnConsecutiveCalls; no mocking framework"] |
