aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/command/exec_command_test.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-26 01:01:53 +0900
committernsfisis <nsfisis@gmail.com>2026-06-26 01:01:53 +0900
commitf639066eaf49325fdbf1b697fb24c187b2d5038e (patch)
tree7444d076aec641916766c29e8ced5cb6177c2a15 /crates/shirabe/tests/command/exec_command_test.rs
parent5f9778e6988b43a759d976322dd73dcac7ff927d (diff)
downloadphp-shirabe-f639066eaf49325fdbf1b697fb24c187b2d5038e.tar.gz
php-shirabe-f639066eaf49325fdbf1b697fb24c187b2d5038e.tar.zst
php-shirabe-f639066eaf49325fdbf1b697fb24c187b2d5038e.zip
test(command): port command test bodies from Composer PHPUnit suite
Faithfully port repository, base_dependency, exec, dump_autoload, run_script, licenses command tests from their PHP counterparts (expected values verbatim). Newly passing: repository (6), base_dependency (5), exec (2). Tests whose ported bodies hit a genuine unported path (HTTP/curl, event-dispatch re-entrancy, spl_autoload_register, php_uname, instance_of, un-delimited Preg patterns, Config::merge dropping list repos) keep faithful bodies but stay #[ignore] with precise reasons; no assertions weakened. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/command/exec_command_test.rs')
-rw-r--r--crates/shirabe/tests/command/exec_command_test.rs72
1 files changed, 68 insertions, 4 deletions
diff --git a/crates/shirabe/tests/command/exec_command_test.rs b/crates/shirabe/tests/command/exec_command_test.rs
index d182754..95649f7 100644
--- a/crates/shirabe/tests/command/exec_command_test.rs
+++ b/crates/shirabe/tests/command/exec_command_test.rs
@@ -1,13 +1,77 @@
//! ref: composer/tests/Composer/Test/Command/ExecCommandTest.php
+use crate::test_case::{RunOptions, get_application_tester, init_temp_composer};
+use serial_test::serial;
+use shirabe_php_shim::PhpMixed;
+
+/// ref: ExecCommandTest::testListThrowsIfNoBinariesExist
#[test]
-#[ignore = "missing TestCase::init_temp_composer and get_application_tester (ApplicationTester with run/get_display) infrastructure"]
+#[serial]
fn test_list_throws_if_no_binaries_exist() {
- todo!()
+ let tear_down = init_temp_composer(Some(&serde_json::json!({})), None, None, false);
+ let composer_dir = tear_down.working_dir();
+
+ let composer_bin_dir = format!("{}/vendor/bin", composer_dir.display());
+
+ let mut app_tester = get_application_tester();
+ let err = app_tester
+ .run(
+ vec![
+ (PhpMixed::from("command"), PhpMixed::from("exec")),
+ (PhpMixed::from("--list"), PhpMixed::from(true)),
+ ],
+ RunOptions::default(),
+ )
+ .expect_err("exec --list with no binaries should raise a RuntimeException");
+
+ assert!(
+ err.to_string().contains(&format!(
+ "No binaries found in composer.json or in bin-dir ({})",
+ composer_bin_dir
+ )),
+ "expected RuntimeException about no binaries, got: {:?}",
+ err.to_string(),
+ );
+
+ drop(tear_down);
}
+/// ref: ExecCommandTest::testList
#[test]
-#[ignore = "missing TestCase::init_temp_composer and get_application_tester (ApplicationTester with run/get_display) infrastructure"]
+#[serial]
fn test_list() {
- todo!()
+ let tear_down = init_temp_composer(
+ Some(&serde_json::json!({
+ "bin": [
+ "a",
+ ],
+ })),
+ None,
+ None,
+ false,
+ );
+ let composer_dir = tear_down.working_dir();
+
+ let composer_bin_dir = format!("{}/vendor/bin", composer_dir.display());
+ std::fs::create_dir_all(&composer_bin_dir).unwrap();
+ std::fs::write(format!("{}/b", composer_bin_dir), "").unwrap();
+ std::fs::write(format!("{}/b.bat", composer_bin_dir), "").unwrap();
+ std::fs::write(format!("{}/c", composer_bin_dir), "").unwrap();
+
+ let mut app_tester = get_application_tester();
+ app_tester
+ .run(
+ vec![
+ (PhpMixed::from("command"), PhpMixed::from("exec")),
+ (PhpMixed::from("--list"), PhpMixed::from(true)),
+ ],
+ RunOptions::default(),
+ )
+ .unwrap();
+
+ let output = app_tester.get_display();
+
+ assert_eq!("Available binaries:\n- b\n- c\n- a (local)", output.trim(),);
+
+ drop(tear_down);
}