aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-12 01:22:13 +0900
committernsfisis <nsfisis@gmail.com>2026-07-16 01:02:47 +0900
commite588920985c71eaa652a292db2dd1d75b73712e4 (patch)
tree983b8c49c4d628e966c32a3a1cfd5b2cad03bc29 /crates
parent754c41c474194a00ed34190ba228ac36dac609a5 (diff)
downloadphp-shirabe-e588920985c71eaa652a292db2dd1d75b73712e4.tar.gz
php-shirabe-e588920985c71eaa652a292db2dd1d75b73712e4.tar.zst
php-shirabe-e588920985c71eaa652a292db2dd1d75b73712e4.zip
refactor(locker-test): reuse test_case's installation_manager helper
locker_test.rs defined its own installation_manager, identical to test_case.rs's (both build a bare InstallationManager over a mock HttpDownloader). Expose the shared one via pub(crate) and drop the duplicate. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'crates')
-rw-r--r--crates/shirabe/tests/common/test_case.rs2
-rw-r--r--crates/shirabe/tests/package/locker_test.rs23
2 files changed, 2 insertions, 23 deletions
diff --git a/crates/shirabe/tests/common/test_case.rs b/crates/shirabe/tests/common/test_case.rs
index 5bfc2d0f..4adee211 100644
--- a/crates/shirabe/tests/common/test_case.rs
+++ b/crates/shirabe/tests/common/test_case.rs
@@ -174,7 +174,7 @@ fn null_io() -> std::rc::Rc<std::cell::RefCell<dyn IOInterface>> {
/// ref: FactoryMock::createInstallationManager (the real installers are never created in tests, so a
/// bare InstallationManager over a mock HttpDownloader suffices).
-fn installation_manager(
+pub(crate) fn installation_manager(
io: &std::rc::Rc<std::cell::RefCell<dyn IOInterface>>,
) -> std::rc::Rc<std::cell::RefCell<InstallationManager>> {
let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None)));
diff --git a/crates/shirabe/tests/package/locker_test.rs b/crates/shirabe/tests/package/locker_test.rs
index fc66293b..c355c774 100644
--- a/crates/shirabe/tests/package/locker_test.rs
+++ b/crates/shirabe/tests/package/locker_test.rs
@@ -1,8 +1,7 @@
//! ref: composer/tests/Composer/Test/Package/LockerTest.php
+use crate::test_case::installation_manager;
use indexmap::IndexMap;
-use shirabe::config::Config;
-use shirabe::installer::InstallationManager;
use shirabe::io::IOInterface;
use shirabe::io::null_io::NullIO;
use shirabe::json::{JsonEncodeOptions, JsonFile};
@@ -10,8 +9,6 @@ use shirabe::package::Locker;
use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle};
use shirabe::plugin::plugin_interface;
use shirabe::repository::{FindPackageConstraint, RepositoryInterfaceHandle};
-use shirabe::util::http_downloader::HttpDownloader;
-use shirabe::util::r#loop::Loop;
use shirabe::util::process_executor::ProcessExecutor;
use shirabe_php_shim::{LogicException, PhpMixed, hash};
use tempfile::TempDir;
@@ -20,24 +17,6 @@ fn null_io() -> std::rc::Rc<std::cell::RefCell<dyn IOInterface>> {
std::rc::Rc::new(std::cell::RefCell::new(NullIO::new()))
}
-fn installation_manager(
- io: &std::rc::Rc<std::cell::RefCell<dyn IOInterface>>,
-) -> std::rc::Rc<std::cell::RefCell<InstallationManager>> {
- // These tests never reach Locker::get_package_time, so the InstallationManager is never
- // actually used; build it over a mock HttpDownloader to avoid the unimplemented curl backend.
- let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None)));
- let http_downloader = std::rc::Rc::new(std::cell::RefCell::new(HttpDownloader::__new_mock(
- io.clone(),
- config,
- )));
- let r#loop = std::rc::Rc::new(std::cell::RefCell::new(Loop::new(http_downloader, None)));
- std::rc::Rc::new(std::cell::RefCell::new(InstallationManager::new(
- r#loop,
- io.clone(),
- None,
- )))
-}
-
/// ref: LockerTest::getJsonContent — `JsonFile::encode(ksort([minimum-stability, name]), 0)`.
fn get_json_content(custom_data: &[(&str, &str)]) -> String {
let mut data: IndexMap<String, PhpMixed> = IndexMap::new();