aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/application_test.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/tests/application_test.rs')
-rw-r--r--crates/shirabe/tests/application_test.rs91
1 files changed, 82 insertions, 9 deletions
diff --git a/crates/shirabe/tests/application_test.rs b/crates/shirabe/tests/application_test.rs
index 856c1b7..dddf8de 100644
--- a/crates/shirabe/tests/application_test.rs
+++ b/crates/shirabe/tests/application_test.rs
@@ -1,9 +1,22 @@
//! ref: composer/tests/Composer/Test/ApplicationTest.php
-// These drive the console Application (doRun, getDisplay, plugin disabling, command
-// resolution) via ApplicationTester, none of which are ported.
+// These drive the console Application (doRun, command resolution, plugin disabling).
+// The tests needing Application::setAutoExit/setCatchErrors or the initTempComposer
+// helper, or a runtime define() of COMPOSER_DEV_WARNING_TIME, remain unportable.
+use std::cell::RefCell;
+use std::rc::Rc;
+
+use shirabe::command::about_command::AboutCommand;
+use shirabe::command::self_update_command::SelfUpdateCommand;
+use shirabe::console::application::Application;
use shirabe::util::platform::Platform;
+use shirabe_external_packages::symfony::console::command::Command;
+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 shirabe_php_shim::PhpMixed;
fn set_up() {
Platform::put_env("COMPOSER_DISABLE_XDEBUG_WARN", "1");
@@ -21,8 +34,8 @@ impl Drop for TearDown {
}
}
+#[ignore = "no define() setter exists for the COMPOSER_DEV_WARNING_TIME constant (shim defined() is a fixed matches!)"]
#[test]
-#[ignore = "requires the console Application/ApplicationTester harness, which is not yet ported"]
fn test_dev_warning() {
let _tear_down = TearDown;
set_up();
@@ -30,26 +43,86 @@ fn test_dev_warning() {
todo!()
}
+#[ignore]
#[test]
-#[ignore = "requires the console Application/ApplicationTester harness, which is not yet ported"]
fn test_dev_warning_suppressed_for_self_update() {
let _tear_down = TearDown;
set_up();
- todo!()
+ if Platform::is_windows() {
+ // markTestSkipped('Does not run on windows')
+ return;
+ }
+
+ let application = Rc::new(RefCell::new(Application::new(
+ "Composer".to_string(),
+ "".to_string(),
+ )));
+ let command: Rc<RefCell<dyn Command>> = Rc::new(RefCell::new(SelfUpdateCommand::new()));
+ application.borrow_mut().add(command).unwrap();
+
+ let output = Rc::new(RefCell::new(BufferedOutput::new(None, false, None)));
+ let input: Rc<RefCell<dyn InputInterface>> = Rc::new(RefCell::new(
+ ArrayInput::new(
+ vec![(PhpMixed::from("command"), PhpMixed::from("self-update"))],
+ None,
+ )
+ .unwrap(),
+ ));
+ let output_trait: Rc<RefCell<dyn OutputInterface>> = output.clone();
+ Application::do_run(&application, input, output_trait).unwrap();
+
+ assert_eq!(
+ "This instance of Composer does not have the self-update command.\n\
+ This could be due to a number of reasons, such as Composer being installed as a system package on your OS, or Composer being installed as a package in the current project.\n",
+ output.borrow().fetch().as_str()
+ );
}
+#[ignore]
#[test]
-#[ignore = "requires the console Application/ApplicationTester harness, which is not yet ported"]
fn test_process_isolation_works_multiple_times() {
let _tear_down = TearDown;
set_up();
- todo!()
+ let application = Rc::new(RefCell::new(Application::new(
+ "Composer".to_string(),
+ "".to_string(),
+ )));
+ let command: Rc<RefCell<dyn Command>> = Rc::new(RefCell::new(AboutCommand::new()));
+ application.borrow_mut().add(command).unwrap();
+
+ let input1: Rc<RefCell<dyn InputInterface>> = Rc::new(RefCell::new(
+ ArrayInput::new(
+ vec![(PhpMixed::from("command"), PhpMixed::from("about"))],
+ None,
+ )
+ .unwrap(),
+ ));
+ 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()
+ );
+
+ let input2: Rc<RefCell<dyn InputInterface>> = Rc::new(RefCell::new(
+ ArrayInput::new(
+ vec![(PhpMixed::from("command"), PhpMixed::from("about"))],
+ None,
+ )
+ .unwrap(),
+ ));
+ 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()
+ );
}
+#[ignore = "Application::set_auto_exit / set_catch_errors and the initTempComposer test helper do not exist"]
#[test]
-#[ignore = "requires the console Application/ApplicationTester harness, which is not yet ported"]
fn test_no_plugins_disables_plugins_when_script_commands_exist() {
let _tear_down = TearDown;
set_up();
@@ -57,8 +130,8 @@ fn test_no_plugins_disables_plugins_when_script_commands_exist() {
todo!()
}
+#[ignore = "Application::set_auto_exit / set_catch_errors and the initTempComposer test helper do not exist"]
#[test]
-#[ignore = "requires the console Application/ApplicationTester harness, which is not yet ported"]
fn test_script_command_takes_priority_over_abbreviated_builtin_command() {
let _tear_down = TearDown;
set_up();