1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
//! ref: composer/tests/Composer/Test/IO/ConsoleIOTest.php
// These mock Symfony's InputInterface/OutputInterface/HelperSet (and QuestionHelper) to
// drive ConsoleIO; those console abstractions are not ported.
use indexmap::IndexMap;
use shirabe::io::ConsoleIO;
use shirabe::io::IOInterfaceImmutable;
use shirabe::io::IOInterfaceMutable;
use shirabe_external_packages::symfony::console::helper::QuestionHelper;
use shirabe_external_packages::symfony::console::input::array_input::ArrayInput;
use shirabe_external_packages::symfony::console::input::input_interface::InputInterface;
use shirabe_external_packages::symfony::console::output::buffered_output::BufferedOutput;
use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface;
use std::cell::RefCell;
use std::rc::Rc;
/// Builds a ConsoleIO backed by real, side-effect-free Input/Output/QuestionHelper. PHP uses
/// PHPUnit mocks here, but for tests that exercise only the authentication map they carry no
/// expectations, so concrete implementations are an exact substitute.
fn make_console_io() -> ConsoleIO {
let input: Rc<RefCell<dyn InputInterface>> =
Rc::new(RefCell::new(ArrayInput::new(vec![], None).unwrap()));
let output: Rc<RefCell<dyn OutputInterface>> =
Rc::new(RefCell::new(BufferedOutput::new(None, false, None)));
ConsoleIO::new(input, output, QuestionHelper::default())
}
#[ignore = "requires a PHPUnit mock of InputInterface::isInteractive with willReturnOnConsecutiveCalls; no mocking framework"]
#[test]
fn test_is_interactive() {
todo!()
}
#[ignore = "requires a PHPUnit mock of OutputInterface with expects()->method('write')->with() expectation verification; no mocking framework"]
#[test]
fn test_write() {
todo!()
}
#[ignore = "requires a PHPUnit mock of ConsoleOutputInterface with getErrorOutput/write expectation verification; no mocking framework"]
#[test]
fn test_write_error() {
todo!()
}
#[ignore = "requires a PHPUnit mock of OutputInterface with a write() callback expectation verification; no mocking framework"]
#[test]
fn test_write_with_multiple_line_string_when_debugging() {
todo!()
}
#[ignore = "requires a PHPUnit mock of OutputInterface with willReturnCallback series expectation verification; no mocking framework"]
#[test]
fn test_overwrite() {
todo!()
}
#[ignore = "requires a PHPUnit mock of QuestionHelper/HelperSet with ask/get expectation verification; no mocking framework"]
#[test]
fn test_ask() {
todo!()
}
#[ignore = "requires a PHPUnit mock of QuestionHelper/HelperSet with ask/get expectation verification; no mocking framework"]
#[test]
fn test_ask_confirmation() {
todo!()
}
#[ignore = "requires a PHPUnit mock of QuestionHelper/HelperSet with ask/get expectation verification; no mocking framework"]
#[test]
fn test_ask_and_validate() {
todo!()
}
#[ignore = "requires a PHPUnit mock of QuestionHelper/HelperSet with ask/get expectation verification; no mocking framework"]
#[test]
fn test_select() {
todo!()
}
#[test]
fn test_set_and_get_authentication() {
let mut console_io = make_console_io();
console_io.set_authentication(
"repoName".to_string(),
"l3l0".to_string(),
Some("passwd".to_string()),
);
let mut expected: IndexMap<String, Option<String>> = IndexMap::new();
expected.insert("username".to_string(), Some("l3l0".to_string()));
expected.insert("password".to_string(), Some("passwd".to_string()));
assert_eq!(expected, console_io.get_authentication("repoName"));
}
#[test]
fn test_get_authentication_when_did_not_set() {
let console_io = make_console_io();
let mut expected: IndexMap<String, Option<String>> = IndexMap::new();
expected.insert("username".to_string(), None);
expected.insert("password".to_string(), None);
assert_eq!(expected, console_io.get_authentication("repoName"));
}
#[test]
fn test_has_authentication() {
let mut console_io = make_console_io();
console_io.set_authentication(
"repoName".to_string(),
"l3l0".to_string(),
Some("passwd".to_string()),
);
assert!(console_io.has_authentication("repoName"));
assert!(!console_io.has_authentication("repoName2"));
}
#[ignore = "data provider includes malformed-UTF-8 inputs (e.g. \\xFF, \\xC3\\x28); sanitize() takes PhpMixed::String which is UTF-8-only and cannot carry invalid bytes, so those cases are unrepresentable"]
#[test]
fn test_sanitize() {
todo!()
}
|