From 759b2980e70dfb8960238f75d68bb6dddce25414 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 7 Aug 2026 07:01:50 +0900 Subject: test: port the tests left as todo!() stubs Replace the todo!() bodies with real ports. Four autoload-generator tests now run for real; the rest stay #[ignore]d, but each ignore reason now names the concrete missing symbol instead of a vague subsystem. Production additions the ports need: the deprecated AuthHelper::addAuthenticationHeader wrapper, EventDispatcher::__set_dispatch_script_override as the seam for PHPUnit onlyMethods(['dispatchScript']), and a define() stub in the shim. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/tests/application_test.rs | 38 +++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'crates/shirabe/tests/application_test.rs') diff --git a/crates/shirabe/tests/application_test.rs b/crates/shirabe/tests/application_test.rs index c7ec6cfd..6ce9166b 100644 --- a/crates/shirabe/tests/application_test.rs +++ b/crates/shirabe/tests/application_test.rs @@ -22,7 +22,7 @@ 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; +use shirabe_php_shim::{PHP_EOL, PHP_SERVER, PhpMixed, define, defined, time}; fn set_up() { Platform::put_env("COMPOSER_DISABLE_XDEBUG_WARN", "1"); @@ -40,15 +40,43 @@ impl Drop for TearDown { } } -#[ignore = "no define() setter exists for the COMPOSER_DEV_WARNING_TIME constant (shim defined() is a fixed matches!)"] +#[ignore = "shirabe_php_shim::define is a todo!() (there is no runtime constant registry), so COMPOSER_DEV_WARNING_TIME cannot be defined and defined() — a fixed matches! that omits it — keeps the warning branch unreachable"] #[test] fn test_dev_warning() { let _tear_down = TearDown; set_up(); - // TODO(phase-d): no define() setter exists for the COMPOSER_DEV_WARNING_TIME constant (the - // shim's defined() is a fixed matches!), so this test's runtime define() cannot be reproduced. - todo!() + let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); + + if !defined("COMPOSER_DEV_WARNING_TIME") { + define("COMPOSER_DEV_WARNING_TIME", PhpMixed::Int(time() - 1)); + } + + let output = std::rc::Rc::new(std::cell::RefCell::new(BufferedOutput::new( + None, false, None, + ))); + let input: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + ArrayInput::new( + vec![(PhpMixed::from("command"), PhpMixed::from("about"))], + None, + ) + .unwrap(), + )); + let output_trait: std::rc::Rc> = output.clone(); + application.do_run(input, output_trait).unwrap(); + + let expected_output = format!( + "Warning: This development build of Composer is over 60 days old. It is recommended to update it by running \"{} self-update\" to get the latest version.{}", + PHP_SERVER + .lock() + .unwrap() + .get("PHP_SELF") + .unwrap_or_default() + .to_string_lossy(), + PHP_EOL + ); + assert!(output.borrow().fetch().contains(&expected_output)); } #[ignore = "SelfUpdateCommand::execute is intentionally stubbed with a Shirabe-specific \"not available\" message instead of the original Composer wording this test expects"] -- cgit v1.3.1