aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-22 04:38:26 +0900
committernsfisis <nsfisis@gmail.com>2026-06-22 04:55:34 +0900
commitffd3e239a56172d2a336fb4d6253c01f6b1a0100 (patch)
tree344b02702bafcb503806cec94d6433807e0ce5b0 /crates/shirabe/tests
parentc3bf6c567ba2eac2830fa6eddcf4fadf619eb17b (diff)
downloadphp-shirabe-ffd3e239a56172d2a336fb4d6253c01f6b1a0100.tar.gz
php-shirabe-ffd3e239a56172d2a336fb4d6253c01f6b1a0100.tar.zst
php-shirabe-ffd3e239a56172d2a336fb4d6253c01f6b1a0100.zip
refactor(console): introduce ApplicationHandle shared-ownership newtype
Collapse the dual Application API (static methods taking `&Rc<RefCell<Application>>` plus `&mut self` bridges via `shared()`) into a single handle type `ApplicationHandle(Rc<RefCell<Application>>)`, mirroring the Composer handle pattern. Methods that invoke command callbacks (add, run, do_run, base_run, base_do_run, do_run_command, add_commands, init) move to `impl ApplicationHandle` with short-scoped borrows; data-only methods and `impl BaseApplication` stay on `Application`. `shared()` now returns the handle, and `new_shared`/`init_shared` fold into `ApplicationHandle::new`/`init`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests')
-rw-r--r--crates/shirabe/tests/application_test.rs28
1 files changed, 8 insertions, 20 deletions
diff --git a/crates/shirabe/tests/application_test.rs b/crates/shirabe/tests/application_test.rs
index dddf8de..7a2a751 100644
--- a/crates/shirabe/tests/application_test.rs
+++ b/crates/shirabe/tests/application_test.rs
@@ -9,7 +9,7 @@ use std::rc::Rc;
use shirabe::command::about_command::AboutCommand;
use shirabe::command::self_update_command::SelfUpdateCommand;
-use shirabe::console::application::Application;
+use shirabe::console::application::ApplicationHandle;
use shirabe::util::platform::Platform;
use shirabe_external_packages::symfony::console::command::Command;
use shirabe_external_packages::symfony::console::input::array_input::ArrayInput;
@@ -54,12 +54,9 @@ fn test_dev_warning_suppressed_for_self_update() {
return;
}
- let application = Rc::new(RefCell::new(Application::new(
- "Composer".to_string(),
- "".to_string(),
- )));
+ let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap();
let command: Rc<RefCell<dyn Command>> = Rc::new(RefCell::new(SelfUpdateCommand::new()));
- application.borrow_mut().add(command).unwrap();
+ application.add(command).unwrap();
let output = Rc::new(RefCell::new(BufferedOutput::new(None, false, None)));
let input: Rc<RefCell<dyn InputInterface>> = Rc::new(RefCell::new(
@@ -70,7 +67,7 @@ fn test_dev_warning_suppressed_for_self_update() {
.unwrap(),
));
let output_trait: Rc<RefCell<dyn OutputInterface>> = output.clone();
- Application::do_run(&application, input, output_trait).unwrap();
+ application.do_run(input, output_trait).unwrap();
assert_eq!(
"This instance of Composer does not have the self-update command.\n\
@@ -85,12 +82,9 @@ fn test_process_isolation_works_multiple_times() {
let _tear_down = TearDown;
set_up();
- let application = Rc::new(RefCell::new(Application::new(
- "Composer".to_string(),
- "".to_string(),
- )));
+ let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap();
let command: Rc<RefCell<dyn Command>> = Rc::new(RefCell::new(AboutCommand::new()));
- application.borrow_mut().add(command).unwrap();
+ application.add(command).unwrap();
let input1: Rc<RefCell<dyn InputInterface>> = Rc::new(RefCell::new(
ArrayInput::new(
@@ -101,10 +95,7 @@ fn test_process_isolation_works_multiple_times() {
));
let output1: Rc<RefCell<dyn OutputInterface>> =
Rc::new(RefCell::new(BufferedOutput::new(None, false, None)));
- assert_eq!(
- 0,
- Application::do_run(&application, input1, output1).unwrap()
- );
+ assert_eq!(0, application.do_run(input1, output1).unwrap());
let input2: Rc<RefCell<dyn InputInterface>> = Rc::new(RefCell::new(
ArrayInput::new(
@@ -115,10 +106,7 @@ fn test_process_isolation_works_multiple_times() {
));
let output2: Rc<RefCell<dyn OutputInterface>> =
Rc::new(RefCell::new(BufferedOutput::new(None, false, None)));
- assert_eq!(
- 0,
- Application::do_run(&application, input2, output2).unwrap()
- );
+ assert_eq!(0, application.do_run(input2, output2).unwrap());
}
#[ignore = "Application::set_auto_exit / set_catch_errors and the initTempComposer test helper do not exist"]