aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/common
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-28 08:47:30 +0900
committernsfisis <nsfisis@gmail.com>2026-06-28 08:47:30 +0900
commitf408ff1ff95ce6e512810ccb10695f773fe5a8b9 (patch)
tree88325daacd6652f3541ff1e98fd70d0e56ccf84f /crates/shirabe/tests/common
parent7f84f914b29cf68d045080b430877f4b75367ada (diff)
downloadphp-shirabe-f408ff1ff95ce6e512810ccb10695f773fe5a8b9.tar.gz
php-shirabe-f408ff1ff95ce6e512810ccb10695f773fe5a8b9.tar.zst
php-shirabe-f408ff1ff95ce6e512810ccb10695f773fe5a8b9.zip
test(util/git): port interactive Bitbucket OAuth runCommand test
Implement the four privateBitbucketWithOauthProvider cases that were stubbed as an ignored todo!(). Extend IOStub with per-question askAndHideAnswer responses and auth pre-seeding so the stateful OAuth flow can be driven without willReturnCallback, and inject a mock HttpDownloader plus no-op config sources to mirror PHPUnit's Config mock. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/common')
-rw-r--r--crates/shirabe/tests/common/io_stub.rs32
1 files changed, 31 insertions, 1 deletions
diff --git a/crates/shirabe/tests/common/io_stub.rs b/crates/shirabe/tests/common/io_stub.rs
index 9318d45..b57dd0c 100644
--- a/crates/shirabe/tests/common/io_stub.rs
+++ b/crates/shirabe/tests/common/io_stub.rs
@@ -29,6 +29,10 @@ pub struct IOStub {
ask: Option<PhpMixed>,
ask_confirmation: Option<bool>,
ask_and_hide_answer: Option<Option<String>>,
+ // Keyed `askAndHideAnswer` replies, mirroring tests whose willReturnCallback
+ // switches on the question string. Unknown questions return `''` like PHP's
+ // `switch` default.
+ ask_and_hide_answer_responses: Option<indexmap::IndexMap<String, String>>,
}
impl IOStub {
@@ -79,6 +83,29 @@ impl IOStub {
self.ask_and_hide_answer = Some(value);
self
}
+ pub fn with_ask_and_hide_answer_responses(
+ mut self,
+ value: indexmap::IndexMap<String, String>,
+ ) -> Self {
+ self.ask_and_hide_answer_responses = Some(value);
+ self
+ }
+
+ // Pre-seeds the in-memory auth store, equivalent to a willReturnCallback that
+ // reads a captured `$initial_config`. Reads delegate to `BaseIO` as long as the
+ // `with_has_authentication`/`with_get_authentication` overrides are left unset.
+ pub fn with_authentication(
+ mut self,
+ repository_name: impl Into<String>,
+ username: impl Into<String>,
+ password: Option<String>,
+ ) -> Self {
+ let mut auth = indexmap::IndexMap::new();
+ auth.insert("username".to_string(), Some(username.into()));
+ auth.insert("password".to_string(), password);
+ self.authentications.insert(repository_name.into(), auth);
+ self
+ }
}
impl IOInterfaceImmutable for IOStub {
@@ -127,7 +154,10 @@ impl IOInterfaceImmutable for IOStub {
) -> anyhow::Result<PhpMixed> {
Ok(default)
}
- fn ask_and_hide_answer(&self, _question: String) -> Option<String> {
+ fn ask_and_hide_answer(&self, question: String) -> Option<String> {
+ if let Some(responses) = &self.ask_and_hide_answer_responses {
+ return Some(responses.get(&question).cloned().unwrap_or_default());
+ }
self.ask_and_hide_answer.clone().unwrap_or(None)
}
fn select(