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) --- .../src/event_dispatcher/event_dispatcher.rs | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'crates/shirabe/src/event_dispatcher') diff --git a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs index 4aff50c9..5043610b 100644 --- a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs +++ b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs @@ -101,6 +101,10 @@ pub struct EventDispatcher { /// when set, `get_listeners` returns this closure's result verbatim instead of resolving /// registered listeners and package scripts. get_listeners_override: Option, + /// For testing only. Mirrors PHPUnit's `getMockBuilder(EventDispatcher)->onlyMethods(['dispatchScript'])`: + /// when set, `dispatch_script` returns this closure's result instead of building and + /// dispatching a script event. + dispatch_script_override: Option, } /// For testing only. Holds a closure standing in for an overridden `getListeners` method. @@ -112,6 +116,17 @@ impl std::fmt::Debug for GetListenersOverride { } } +/// For testing only. Holds a closure standing in for an overridden `dispatchScript` method. +pub struct DispatchScriptOverride( + pub Box) -> anyhow::Result>, +); + +impl std::fmt::Debug for DispatchScriptOverride { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str("DispatchScriptOverride(..)") + } +} + impl EventDispatcher { pub fn new( composer: PartialComposerWeakHandle, @@ -142,6 +157,7 @@ impl EventDispatcher { previous_hash: None, previous_listeners: IndexMap::new(), get_listeners_override: None, + dispatch_script_override: None, } } @@ -155,6 +171,17 @@ impl EventDispatcher { self.get_listeners_override = Some(GetListenersOverride(callback)); } + /// For testing only. Installs a closure that overrides `dispatch_script`, mirroring PHPUnit's + /// `onlyMethods(['dispatchScript'])->willReturnCallback(...)`. + pub fn __set_dispatch_script_override( + &mut self, + callback: Box< + dyn Fn(&str, bool, &[String], &IndexMap) -> anyhow::Result, + >, + ) { + self.dispatch_script_override = Some(DispatchScriptOverride(callback)); + } + /// For testing only. Exposes the protected `getPhpExecCommand`, mirroring the PHP tests' /// `new \ReflectionMethod($dispatcher, 'getPhpExecCommand')`. pub fn __get_php_exec_command(&self) -> anyhow::Result { @@ -197,6 +224,10 @@ impl EventDispatcher { additional_args: Vec, flags: IndexMap, ) -> anyhow::Result { + if let Some(over) = &self.dispatch_script_override { + return (over.0)(event_name, dev_mode, &additional_args, &flags); + } + let composer = self.composer(); assert!( composer.is_full(), -- cgit v1.3.1