diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-07 07:01:50 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-07 07:01:50 +0900 |
| commit | 759b2980e70dfb8960238f75d68bb6dddce25414 (patch) | |
| tree | e37a0af6423f8ae8dd26da309b278d49d45b3451 /crates/shirabe/tests/util/auth_helper_test.rs | |
| parent | 9a393adc0ace86cac788723b524e83c63dfc91c1 (diff) | |
| download | php-shirabe-759b2980e70dfb8960238f75d68bb6dddce25414.tar.gz php-shirabe-759b2980e70dfb8960238f75d68bb6dddce25414.tar.zst php-shirabe-759b2980e70dfb8960238f75d68bb6dddce25414.zip | |
test: port the tests left as todo!() stubs
Replace the todo!() bodies with real ports. Four autoload-generator
tests now run for real; the rest stay #[ignore]d, but each ignore reason
now names the concrete missing symbol instead of a vague subsystem.
Production additions the ports need: the deprecated
AuthHelper::addAuthenticationHeader wrapper,
EventDispatcher::__set_dispatch_script_override as the seam for PHPUnit
onlyMethods(['dispatchScript']), and a define() stub in the shim.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/util/auth_helper_test.rs')
| -rw-r--r-- | crates/shirabe/tests/util/auth_helper_test.rs | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/crates/shirabe/tests/util/auth_helper_test.rs b/crates/shirabe/tests/util/auth_helper_test.rs index 91d9cb75..ef5daaf7 100644 --- a/crates/shirabe/tests/util/auth_helper_test.rs +++ b/crates/shirabe/tests/util/auth_helper_test.rs @@ -757,16 +757,48 @@ fn test_prompt_auth_if_needed_multiple_bitbucket_downloads() { } #[test] -#[ignore = "exercises the deprecated addAuthenticationHeader wrapper (not ported) which relies on \ -trigger_error/E_USER_DEPRECATED; the PHP error-handler subsystem is not modeled"] +#[ignore = "addAuthenticationHeader opens with trigger_error(E_USER_DEPRECATED), and \ +shirabe_php_shim::trigger_error is a todo!()"] fn test_add_authentication_header_with_custom_headers() { - // TODO(phase-d): exercises AuthHelper::addAuthenticationHeader, a deprecated wrapper - // around addAuthenticationOptions that PHP implements via - // trigger_error(E_USER_DEPRECATED). It has not been ported to Rust (no - // add_authentication_header method exists on AuthHelper) because the PHP - // error-handler subsystem it relies on is not modeled — same limitation as - // error_handler_test.rs. - todo!() + let mut f = set_up(); + let headers = vec![ + "Accept-Encoding: gzip".to_string(), + "Connection: close".to_string(), + ]; + let origin = "example.org"; + let url = "https://example.org/packages.json"; + let custom_headers = vec![ + "API-TOKEN: abc123".to_string(), + "X-CUSTOM-HEADER: value".to_string(), + ]; + let headers_json = json_encode(&PhpMixed::List( + custom_headers + .iter() + .map(|h| PhpMixed::String(h.clone())) + .collect(), + )) + .unwrap(); + + expects_authentication(&f.io, origin, &headers_json, "custom-headers"); + + f.io.borrow_mut() + .expects( + vec![Expectation::text( + "Using custom HTTP headers for authentication", + )], + true, + ) + .unwrap(); + + let mut expected_headers = headers.clone(); + expected_headers.extend(custom_headers); + + assert_eq!( + expected_headers, + f.auth_helper + .add_authentication_header(headers, origin, url) + .unwrap() + ); } #[test] |
