aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/command
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-25 16:27:53 +0900
committernsfisis <nsfisis@gmail.com>2026-06-26 00:20:05 +0900
commit3a0d9340810a8808d963135a884f50d08442ac67 (patch)
tree9fbed3350a23c791f52e37209095e0db41962c87 /crates/shirabe/tests/command
parent46ac7242d526e13707dc140b7244e0fadf2219b9 (diff)
downloadphp-shirabe-3a0d9340810a8808d963135a884f50d08442ac67.tar.gz
php-shirabe-3a0d9340810a8808d963135a884f50d08442ac67.tar.zst
php-shirabe-3a0d9340810a8808d963135a884f50d08442ac67.zip
test: port 59 autoload/vcs/installer/util/command tests; fix output capture
Port autoload_generator (24), bitbucket (14), suggested_packages (11), git_driver (6), archive_manager (3), and a bump command test. Fix the ApplicationTester output-capture root cause (php://memory streams must be readable regardless of fopen mode). Implement posix_getuid/geteuid, the PCRE 'A' anchored modifier, php_strip_whitespace, stream_get_wrappers, is_callable scalars; fix preg_quote angle-bracket escaping and class-map parser regexes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/command')
-rw-r--r--crates/shirabe/tests/command/bump_command_test.rs70
1 files changed, 65 insertions, 5 deletions
diff --git a/crates/shirabe/tests/command/bump_command_test.rs b/crates/shirabe/tests/command/bump_command_test.rs
index 4e9a49c..8866990 100644
--- a/crates/shirabe/tests/command/bump_command_test.rs
+++ b/crates/shirabe/tests/command/bump_command_test.rs
@@ -1,19 +1,79 @@
//! ref: composer/tests/Composer/Test/Command/BumpCommandTest.php
-#[ignore = "missing TestCase::init_temp_composer, create_installed_json, create_composer_lock, and get_application_tester (ApplicationTester) infrastructure"]
+use crate::test_case::{RunOptions, get_application_tester, init_temp_composer};
+use serial_test::serial;
+use shirabe_php_shim::PhpMixed;
+
+#[ignore = "missing TestCase::create_installed_json / create_composer_lock infrastructure and full bump flow (require_composer reaches the network)"]
#[test]
fn test_bump() {
todo!()
}
-#[ignore = "missing TestCase::init_temp_composer and get_application_tester (ApplicationTester) infrastructure"]
#[test]
+#[serial]
fn test_bump_fails_on_non_existing_composer_file() {
- todo!()
+ let tear_down = init_temp_composer(Some(&serde_json::json!({})), None, None, false);
+ let composer_json_path = tear_down.working_dir().join("composer.json");
+ std::fs::remove_file(&composer_json_path).unwrap();
+
+ let mut app_tester = get_application_tester();
+ let status_code = app_tester
+ .run(
+ vec![(PhpMixed::from("command"), PhpMixed::from("bump"))],
+ RunOptions {
+ capture_stderr_separately: true,
+ ..RunOptions::default()
+ },
+ )
+ .unwrap();
+
+ assert_eq!(1, status_code);
+ let error_output = app_tester.get_error_output();
+ assert!(
+ error_output.contains("./composer.json is not readable."),
+ "expected error output to mention composer.json not readable, got: {:?}",
+ error_output,
+ );
+
+ drop(tear_down);
}
-#[ignore = "missing TestCase::init_temp_composer and get_application_tester (ApplicationTester) infrastructure"]
#[test]
+#[serial]
+#[ignore = "BumpCommand::initialize constructs a full Composer (Factory::create_http_downloader \
+ -> CurlDownloader::new -> curl_multi_init), and the curl subsystem in shirabe-php-shim \
+ is still todo!(). Only reachable once the HTTP/curl layer is ported. The companion \
+ test_bump_fails_on_non_existing_composer_file covers the same error-output capture path \
+ without reaching curl (the missing composer.json makes Composer construction a no-op)."]
fn test_bump_fails_on_write_error_to_composer_file() {
- todo!()
+ if shirabe_php_shim::function_exists("posix_getuid") && shirabe_php_shim::posix_getuid() == 0 {
+ // ref: $this->markTestSkipped('Cannot run as root');
+ return;
+ }
+
+ let tear_down = init_temp_composer(Some(&serde_json::json!({})), None, None, false);
+ let composer_json_path = tear_down.working_dir().join("composer.json");
+ shirabe_php_shim::chmod(&composer_json_path.to_string_lossy(), 0o444);
+
+ let mut app_tester = get_application_tester();
+ let status_code = app_tester
+ .run(
+ vec![(PhpMixed::from("command"), PhpMixed::from("bump"))],
+ RunOptions {
+ capture_stderr_separately: true,
+ ..RunOptions::default()
+ },
+ )
+ .unwrap();
+
+ assert_eq!(1, status_code);
+ let error_output = app_tester.get_error_output();
+ assert!(
+ error_output.contains("./composer.json is not writable."),
+ "expected error output to mention composer.json not writable, got: {:?}",
+ error_output,
+ );
+
+ drop(tear_down);
}