aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/installer
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-20 05:32:30 +0900
committernsfisis <nsfisis@gmail.com>2026-07-20 05:32:30 +0900
commit6a2040e9c1b200530269d65e5e57f897a4f95584 (patch)
tree461276d06229d4b16892619a9bfa766e613cd71f /crates/shirabe/tests/installer
parent09755004c6d9396f10a5299a013834224da4e3d5 (diff)
downloadphp-shirabe-6a2040e9c1b200530269d65e5e57f897a4f95584.tar.gz
php-shirabe-6a2040e9c1b200530269d65e5e57f897a4f95584.tar.zst
php-shirabe-6a2040e9c1b200530269d65e5e57f897a4f95584.zip
fix(installation-manager): un-ignore test_add_remove_installer
Add the __add_installer test seam that registers an installer as a pre-built Rc handle, so the test can reproduce PHP's object-identity semantics (assertSame / removeInstaller) via Rc::ptr_eq; add_installer cannot serve because Rc::from(Box) reallocates, losing the caller's pointer identity. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/installer')
-rw-r--r--crates/shirabe/tests/installer/installation_manager_test.rs40
1 files changed, 35 insertions, 5 deletions
diff --git a/crates/shirabe/tests/installer/installation_manager_test.rs b/crates/shirabe/tests/installer/installation_manager_test.rs
index f5012ef7..867e759a 100644
--- a/crates/shirabe/tests/installer/installation_manager_test.rs
+++ b/crates/shirabe/tests/installer/installation_manager_test.rs
@@ -283,13 +283,43 @@ fn test_add_get_installer() {
assert!(manager.get_installer("unregistered").is_err());
}
-#[ignore = "removeInstaller compares installers by object identity, but add_installer moves the Box<dyn InstallerInterface> into the manager, leaving no &dyn reference to pass back to remove_installer; faithful reproduction needs a shared-ownership installer registry"]
#[test]
fn test_add_remove_installer() {
- // TODO(phase-d): removeInstaller compares installers by object identity, but add_installer
- // moves the Box<dyn InstallerInterface> into the manager, leaving no &dyn reference to pass
- // back to remove_installer; faithful reproduction needs a shared-ownership installer registry.
- todo!()
+ let set_up = set_up();
+ let mut installer = MockInstaller::new();
+ installer
+ .expect_supports()
+ .times(2)
+ .returning(|arg| arg == "vendor");
+ // The manager stores installers as Rc, so the PHP object-identity semantics (assertSame,
+ // removeInstaller) map to Rc::ptr_eq on a handle registered via __add_installer.
+ let installer: std::rc::Rc<dyn InstallerInterface> = std::rc::Rc::new(installer);
+
+ let mut installer2 = MockInstaller::new();
+ installer2
+ .expect_supports()
+ .times(1)
+ .returning(|arg| arg == "vendor");
+ let installer2: std::rc::Rc<dyn InstallerInterface> = std::rc::Rc::new(installer2);
+
+ let mut manager =
+ shirabe::installer::InstallationManager::new(set_up.loop_.clone(), set_up.io.clone(), None);
+
+ manager.__add_installer(installer.clone());
+ assert!(std::rc::Rc::ptr_eq(
+ &installer,
+ &manager.get_installer("vendor").unwrap()
+ ));
+ manager.__add_installer(installer2.clone());
+ assert!(std::rc::Rc::ptr_eq(
+ &installer2,
+ &manager.get_installer("vendor").unwrap()
+ ));
+ manager.remove_installer(&*installer2);
+ assert!(std::rc::Rc::ptr_eq(
+ &installer,
+ &manager.get_installer("vendor").unwrap()
+ ));
}
#[ignore = "partial mock of InstallationManager (onlyMethods install/update/uninstall) with expects(once)->with(...) is not reproducible without method-overriding mocks; execute() also takes the batched download path"]