From b3849c077fe19808afcace0753d37bdd91118ceb Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 28 Jun 2026 06:11:57 +0900 Subject: test(factory): port testDefaultValuesAreAsExpected The IOMock and ConfigStubBuilder helpers now cover the writeError verification and the get('disable-tls')=>true stub the PHP test needs. Co-Authored-By: Claude Opus 4.8 --- crates/shirabe/tests/factory_test.rs | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/crates/shirabe/tests/factory_test.rs b/crates/shirabe/tests/factory_test.rs index bb26b09..c6464de 100644 --- a/crates/shirabe/tests/factory_test.rs +++ b/crates/shirabe/tests/factory_test.rs @@ -1,8 +1,23 @@ //! ref: composer/tests/Composer/Test/FactoryTest.php +use std::cell::RefCell; +use std::rc::Rc; + +use indexmap::IndexMap; use serial_test::serial; use shirabe::factory::Factory; +use shirabe::io::IOInterface; +use shirabe::io::io_interface; use shirabe::util::platform::Platform; +use shirabe_php_shim::PhpMixed; + +#[path = "common/config_stub.rs"] +mod config_stub; +#[path = "common/io_mock.rs"] +#[allow(dead_code)] // io_mock exposes more helpers than this binary uses +mod io_mock; +use config_stub::ConfigStubBuilder; +use io_mock::{Expectation, get_io_mock}; fn tear_down() { Platform::clear_env("COMPOSER"); @@ -18,11 +33,26 @@ impl Drop for TearDown { #[test] #[serial] -#[ignore = "requires PHPUnit-style mocks: an IOInterface mock verifying writeError is called exactly once with the exact warning, plus a Config mock stubbing get('disable-tls')=>true; no such mock/expectation infrastructure (e.g. mockall) exists"] fn test_default_values_are_as_expected() { let _tear_down = TearDown; - todo!() + let (io_mock, _io_guard) = get_io_mock(io_interface::DEBUG).unwrap(); + io_mock + .borrow_mut() + .expects( + vec![Expectation::text( + "You are running Composer with SSL/TLS protection disabled.", + )], + false, + ) + .unwrap(); + + let config = ConfigStubBuilder::new() + .with("disable-tls", PhpMixed::Bool(true)) + .build_shared(); + + let io: Rc> = io_mock.clone(); + Factory::create_http_downloader(io, &config, IndexMap::new()).unwrap(); } #[test] -- cgit v1.3.1