aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/command/self_update_command_test.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-26 02:23:58 +0900
committernsfisis <nsfisis@gmail.com>2026-06-26 02:23:58 +0900
commit6c89c720d9e4728c288e3c66ffb7dcb4cba5121c (patch)
tree4697f897302425df1b57eb87bf9441308530d0bf /crates/shirabe/tests/command/self_update_command_test.rs
parent4bd544608e4934fff4463fd6b104d06162a51ba0 (diff)
downloadphp-shirabe-6c89c720d9e4728c288e3c66ffb7dcb4cba5121c.tar.gz
php-shirabe-6c89c720d9e4728c288e3c66ffb7dcb4cba5121c.tar.zst
php-shirabe-6c89c720d9e4728c288e3c66ffb7dcb4cba5121c.zip
test(command): port show/remove/global/audit/check-platform-reqs/status/self-update/validate tests
Faithfully port the remaining stubbed command test bodies from their PHP counterparts (expected values verbatim). Newly passing: remove (6), global (2), check-platform-reqs (1), status (1), audit (1), self-update (1). Tests whose ported bodies reach a genuine unported src path keep faithful bodies but stay #[ignore] with precise reasons. Dominant blockers surfaced: - ShowCommand::configure stub (empty set_definition) blocks all 42 show tests - Composer-handle RefCell re-entrancy in the Installer (composer.rs:500) and Factory::create_composer (composer.rs:446) paths - check_platform_reqs nests InstalledRepository in InstalledRepository - audit's non-locked branch (audit_command.rs:285) and write_error3 re-entrancy Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/command/self_update_command_test.rs')
-rw-r--r--crates/shirabe/tests/command/self_update_command_test.rs54
1 files changed, 41 insertions, 13 deletions
diff --git a/crates/shirabe/tests/command/self_update_command_test.rs b/crates/shirabe/tests/command/self_update_command_test.rs
index 8e51580..094eb5e 100644
--- a/crates/shirabe/tests/command/self_update_command_test.rs
+++ b/crates/shirabe/tests/command/self_update_command_test.rs
@@ -1,39 +1,67 @@
//! ref: composer/tests/Composer/Test/Command/SelfUpdateCommandTest.php
-/// Returns the path to the copied composer.phar used by the test bodies.
-fn set_up() -> String {
- // Depends on initTempComposer and the composer-test.phar fixture, neither ported yet.
- todo!()
+use crate::test_case::{RunOptions, get_application_tester, init_temp_composer};
+use serial_test::serial;
+use shirabe_php_shim::PhpMixed;
+
+/// ref: SelfUpdateCommandTest::setUp (portable part: initTempComposer; the composer-test.phar copy
+/// is omitted because the phar fixture and Symfony Process are not ported).
+fn set_up() -> crate::test_case::TearDown {
+ init_temp_composer(None, None, None, true)
}
#[test]
-#[ignore = "depends on initTempComposer, composer-test.phar fixture, and Symfony Process to spawn the phar; none ported"]
+#[serial]
+#[ignore = "spawns `new Process([PHP_BINARY, $this->phar, 'self-update'])` running composer-test.phar \
+ over HTTP; requires Symfony Process and the composer-test.phar fixture, neither ported"]
fn test_successful_update() {
- let _phar = set_up();
+ let _tear_down = set_up();
todo!()
}
#[test]
-#[ignore = "depends on initTempComposer, composer-test.phar fixture, and Symfony Process to spawn the phar; none ported"]
+#[serial]
+#[ignore = "spawns `new Process([PHP_BINARY, $this->phar, 'self-update', '2.4.0'])` running \
+ composer-test.phar over HTTP; requires Symfony Process and the composer-test.phar \
+ fixture, neither ported"]
fn test_update_to_specific_version() {
- let _phar = set_up();
+ let _tear_down = set_up();
todo!()
}
#[test]
-#[ignore = "depends on getApplicationTester (ApplicationTester) which is not ported"]
+#[serial]
fn test_update_with_invalid_option_throws_exception() {
- let _phar = set_up();
+ let _tear_down = set_up();
- todo!()
+ let mut app_tester = get_application_tester();
+ let err = app_tester
+ .run(
+ vec![
+ (PhpMixed::from("command"), PhpMixed::from("self-update")),
+ (PhpMixed::from("invalid-option"), PhpMixed::from(true)),
+ ],
+ RunOptions::default(),
+ )
+ .expect_err("expected InvalidArgumentException for the unknown argument");
+
+ assert!(
+ err.to_string()
+ .contains("The \"invalid-option\" argument does not exist."),
+ "expected error about unknown argument, got: {:?}",
+ err,
+ );
}
#[test]
-#[ignore = "depends on initTempComposer, composer-test.phar fixture, and Symfony Process to spawn the phar; none ported"]
+#[serial]
+#[ignore = "spawns `new Process([PHP_BINARY, $this->phar, 'self-update', $option])` running \
+ composer-test.phar over HTTP (data provider: --stable/--preview/--snapshot); requires \
+ Symfony Process and the composer-test.phar fixture, neither ported"]
fn test_update_to_different_channel() {
- let _phar = set_up();
+ let _tear_down = set_up();
todo!()
}