aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/io/buffer_io_test.rs
blob: 5bb1801440ca1e9e24a47808a0acf21c31f77af9 (plain)
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
//! ref: composer/tests/Composer/Test/IO/BufferIOTest.php

use shirabe::io::IOInterfaceImmutable;
use shirabe::io::buffer_io::BufferIO;
use shirabe_external_packages::symfony::console::output::output_interface::VERBOSITY_NORMAL;
use shirabe_php_shim::PhpMixed;

#[test]
fn test_set_user_inputs() {
    let mut buffer_io = BufferIO::new(String::new(), VERBOSITY_NORMAL, None).unwrap();

    // The Rust port always uses a StreamableInputInterface, so the version-guard
    // exception branch in the original test does not apply.
    buffer_io
        .set_user_inputs(vec!["yes".to_string(), "no".to_string(), String::new()])
        .unwrap();

    assert!(buffer_io.ask_confirmation("Please say yes!".to_string(), false));
    assert!(!buffer_io.ask_confirmation("Now please say no!".to_string(), true));
    assert_eq!(
        PhpMixed::String("default".to_string()),
        buffer_io.ask(
            "Empty string last".to_string(),
            PhpMixed::String("default".to_string())
        )
    );
}