aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-21 04:11:50 +0900
committernsfisis <nsfisis@gmail.com>2026-06-21 04:11:50 +0900
commit343e6fcc129b47768059860e26ef6372170794b2 (patch)
tree8188b36316e5c7ba60e954fe6e1533bc07808249 /crates/shirabe
parent5f85bb006a71eef80037102936a6530510662365 (diff)
downloadphp-shirabe-343e6fcc129b47768059860e26ef6372170794b2.tar.gz
php-shirabe-343e6fcc129b47768059860e26ef6372170794b2.tar.zst
php-shirabe-343e6fcc129b47768059860e26ef6372170794b2.zip
test: port MetapackageInstallerTest and SelfUpdate/Status/Home command stubs
MetapackageInstaller install/uninstall verified against a real InstalledArrayRepository; update reaches version_compare (todo!()) and is ignored. The command tests need the ApplicationTester harness (stubbed). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe')
-rw-r--r--crates/shirabe/tests/command/home_command_test.rs6
-rw-r--r--crates/shirabe/tests/command/main.rs3
-rw-r--r--crates/shirabe/tests/command/self_update_command_test.rs24
-rw-r--r--crates/shirabe/tests/command/status_command_test.rs12
-rw-r--r--crates/shirabe/tests/installer/main.rs4
-rw-r--r--crates/shirabe/tests/installer/metapackage_installer_test.rs69
6 files changed, 118 insertions, 0 deletions
diff --git a/crates/shirabe/tests/command/home_command_test.rs b/crates/shirabe/tests/command/home_command_test.rs
index 0cbe03d..0bb4357 100644
--- a/crates/shirabe/tests/command/home_command_test.rs
+++ b/crates/shirabe/tests/command/home_command_test.rs
@@ -1 +1,7 @@
//! ref: composer/tests/Composer/Test/Command/HomeCommandTest.php
+
+#[test]
+#[ignore = "requires the ApplicationTester/initTempComposer harness, which is not yet ported"]
+fn test_home_command_with_show_flag() {
+ todo!()
+}
diff --git a/crates/shirabe/tests/command/main.rs b/crates/shirabe/tests/command/main.rs
index 381649a..195f570 100644
--- a/crates/shirabe/tests/command/main.rs
+++ b/crates/shirabe/tests/command/main.rs
@@ -3,4 +3,7 @@ mod audit_command_test;
mod clear_cache_command_test;
mod diagnose_command_test;
mod exec_command_test;
+mod home_command_test;
mod reinstall_command_test;
+mod self_update_command_test;
+mod status_command_test;
diff --git a/crates/shirabe/tests/command/self_update_command_test.rs b/crates/shirabe/tests/command/self_update_command_test.rs
index 6623853..a4b7358 100644
--- a/crates/shirabe/tests/command/self_update_command_test.rs
+++ b/crates/shirabe/tests/command/self_update_command_test.rs
@@ -1 +1,25 @@
//! ref: composer/tests/Composer/Test/Command/SelfUpdateCommandTest.php
+
+#[test]
+#[ignore = "requires the ApplicationTester harness, which is not yet ported"]
+fn test_successful_update() {
+ todo!()
+}
+
+#[test]
+#[ignore = "requires the ApplicationTester harness, which is not yet ported"]
+fn test_update_to_specific_version() {
+ todo!()
+}
+
+#[test]
+#[ignore = "requires the ApplicationTester harness, which is not yet ported"]
+fn test_update_with_invalid_option_throws_exception() {
+ todo!()
+}
+
+#[test]
+#[ignore = "requires the ApplicationTester harness, which is not yet ported"]
+fn test_update_to_different_channel() {
+ todo!()
+}
diff --git a/crates/shirabe/tests/command/status_command_test.rs b/crates/shirabe/tests/command/status_command_test.rs
index 8dec3eb..6b8dcf6 100644
--- a/crates/shirabe/tests/command/status_command_test.rs
+++ b/crates/shirabe/tests/command/status_command_test.rs
@@ -1 +1,13 @@
//! ref: composer/tests/Composer/Test/Command/StatusCommandTest.php
+
+#[test]
+#[ignore = "requires the ApplicationTester/initTempComposer harness, which is not yet ported"]
+fn test_no_local_changes() {
+ todo!()
+}
+
+#[test]
+#[ignore = "requires the ApplicationTester/initTempComposer harness, which is not yet ported"]
+fn test_locally_modified_packages() {
+ todo!()
+}
diff --git a/crates/shirabe/tests/installer/main.rs b/crates/shirabe/tests/installer/main.rs
index fa7fea5..f28341e 100644
--- a/crates/shirabe/tests/installer/main.rs
+++ b/crates/shirabe/tests/installer/main.rs
@@ -1 +1,5 @@
+#[path = "../common/test_case.rs"]
+mod test_case;
+
mod installer_event_test;
+mod metapackage_installer_test;
diff --git a/crates/shirabe/tests/installer/metapackage_installer_test.rs b/crates/shirabe/tests/installer/metapackage_installer_test.rs
index 29f8526..daf2e20 100644
--- a/crates/shirabe/tests/installer/metapackage_installer_test.rs
+++ b/crates/shirabe/tests/installer/metapackage_installer_test.rs
@@ -1 +1,70 @@
//! ref: composer/tests/Composer/Test/Installer/MetapackageInstallerTest.php
+//!
+//! PHP verifies the mocked repository's add/remove/hasPackage calls; here the same
+//! behaviour is checked against a real InstalledArrayRepository by observing its state.
+
+use std::cell::RefCell;
+use std::rc::Rc;
+
+use shirabe::installer::{InstallerInterface, MetapackageInstaller};
+use shirabe::io::IOInterface;
+use shirabe::io::null_io::NullIO;
+use shirabe::repository::{InstalledArrayRepository, RepositoryInterface};
+
+use crate::test_case::get_package;
+
+fn run<F: std::future::Future>(future: F) -> F::Output {
+ tokio::runtime::Builder::new_current_thread()
+ .build()
+ .unwrap()
+ .block_on(future)
+}
+
+fn installer() -> MetapackageInstaller {
+ let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new()));
+ MetapackageInstaller::new(io)
+}
+
+#[test]
+fn test_install() {
+ let package = get_package("test/pkg", "1.0.0");
+ let mut installer = installer();
+ let mut repository = InstalledArrayRepository::new_with_packages(vec![]).unwrap();
+
+ run(installer.install(&mut repository, package.clone())).unwrap();
+
+ assert!(repository.has_package(package));
+}
+
+#[test]
+#[ignore = "MetapackageInstaller::update formats an UpdateOperation, which reaches version_compare (todo!()) in the php-shim"]
+fn test_update() {
+ let initial = get_package("test/initial", "1.0.0");
+ let target = get_package("test/target", "1.0.1");
+ let mut installer = installer();
+ let mut repository =
+ InstalledArrayRepository::new_with_packages(vec![initial.clone()]).unwrap();
+
+ run(installer.update(&mut repository, initial.clone(), target.clone())).unwrap();
+
+ assert!(!repository.has_package(initial.clone()));
+ assert!(repository.has_package(target.clone()));
+
+ // Updating again, with the initial package no longer installed, fails.
+ assert!(run(installer.update(&mut repository, initial, target)).is_err());
+}
+
+#[test]
+fn test_uninstall() {
+ let package = get_package("test/pkg", "1.0.0");
+ let mut installer = installer();
+ let mut repository =
+ InstalledArrayRepository::new_with_packages(vec![package.clone()]).unwrap();
+
+ run(installer.uninstall(&mut repository, package.clone())).unwrap();
+
+ assert!(!repository.has_package(package.clone()));
+
+ // Uninstalling again, with the package no longer installed, fails.
+ assert!(run(installer.uninstall(&mut repository, package)).is_err());
+}