aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/factory_test.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-21 03:42:21 +0900
committernsfisis <nsfisis@gmail.com>2026-06-21 03:42:21 +0900
commit06b5f60fd066ec0e1e41c5f85973b323d429b464 (patch)
tree402aacf154f560ae7d3d5fbe735de436fabaf324 /crates/shirabe/tests/factory_test.rs
parentef5cde35bc06724581922a3804945a31667b3a39 (diff)
downloadphp-shirabe-06b5f60fd066ec0e1e41c5f85973b323d429b464.tar.gz
php-shirabe-06b5f60fd066ec0e1e41c5f85973b323d429b464.tar.zst
php-shirabe-06b5f60fd066ec0e1e41c5f85973b323d429b464.zip
test(factory): port FactoryTest
getComposerFile env paths verified. The default-values case mocks IO/Config (unportable); the unset-env case is order-dependent without the deferred tearDown, so both are ignored. setUp/tearDown not ported. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/factory_test.rs')
-rw-r--r--crates/shirabe/tests/factory_test.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/crates/shirabe/tests/factory_test.rs b/crates/shirabe/tests/factory_test.rs
index a7ad372..687e5ab 100644
--- a/crates/shirabe/tests/factory_test.rs
+++ b/crates/shirabe/tests/factory_test.rs
@@ -1 +1,36 @@
//! ref: composer/tests/Composer/Test/FactoryTest.php
+
+use shirabe::factory::Factory;
+use shirabe::util::platform::Platform;
+
+#[test]
+#[ignore = "mocks an IOInterface with a writeError expectation and a Config returning disable-tls=true; mocking is not available"]
+fn test_default_values_are_as_expected() {
+ todo!()
+}
+
+#[test]
+#[ignore = "depends on COMPOSER being unset, but sibling tests set it and the tearDown that clears it is not ported"]
+fn test_get_composer_json_path() {
+ assert_eq!("./composer.json", Factory::get_composer_file().unwrap());
+}
+
+#[test]
+fn test_get_composer_json_path_fails_if_dir() {
+ let dir = env!("CARGO_MANIFEST_DIR");
+ Platform::put_env("COMPOSER", dir);
+ let err = Factory::get_composer_file().unwrap_err();
+ assert_eq!(
+ format!(
+ "The COMPOSER environment variable is set to {} which is a directory, this variable should point to a composer.json or be left unset.",
+ dir
+ ),
+ err.to_string()
+ );
+}
+
+#[test]
+fn test_get_composer_json_path_from_env() {
+ Platform::put_env("COMPOSER", " foo.json ");
+ assert_eq!("foo.json", Factory::get_composer_file().unwrap());
+}