diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-28 06:11:57 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-28 07:20:32 +0900 |
| commit | b3849c077fe19808afcace0753d37bdd91118ceb (patch) | |
| tree | ecd1bf6ed8621a8f987fa1605698b65f268f001b | |
| parent | d645028a10915f792ec015b33ebd3af4efcb8c37 (diff) | |
| download | php-shirabe-b3849c077fe19808afcace0753d37bdd91118ceb.tar.gz php-shirabe-b3849c077fe19808afcace0753d37bdd91118ceb.tar.zst php-shirabe-b3849c077fe19808afcace0753d37bdd91118ceb.zip | |
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 <noreply@anthropic.com>
| -rw-r--r-- | crates/shirabe/tests/factory_test.rs | 34 |
1 files 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( + "<warning>You are running Composer with SSL/TLS protection disabled.</warning>", + )], + false, + ) + .unwrap(); + + let config = ConfigStubBuilder::new() + .with("disable-tls", PhpMixed::Bool(true)) + .build_shared(); + + let io: Rc<RefCell<dyn IOInterface>> = io_mock.clone(); + Factory::create_http_downloader(io, &config, IndexMap::new()).unwrap(); } #[test] |
