aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/command/self_update_command_test.rs
blob: 094eb5ee9c1e7a487b0a8921f576a3a400a8dad7 (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
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
//! ref: composer/tests/Composer/Test/Command/SelfUpdateCommandTest.php

use crate::test_case::{RunOptions, get_application_tester, init_temp_composer};
use serial_test::serial;
use shirabe_php_shim::PhpMixed;

/// ref: SelfUpdateCommandTest::setUp (portable part: initTempComposer; the composer-test.phar copy
/// is omitted because the phar fixture and Symfony Process are not ported).
fn set_up() -> crate::test_case::TearDown {
    init_temp_composer(None, None, None, true)
}

#[test]
#[serial]
#[ignore = "spawns `new Process([PHP_BINARY, $this->phar, 'self-update'])` running composer-test.phar \
            over HTTP; requires Symfony Process and the composer-test.phar fixture, neither ported"]
fn test_successful_update() {
    let _tear_down = set_up();

    todo!()
}

#[test]
#[serial]
#[ignore = "spawns `new Process([PHP_BINARY, $this->phar, 'self-update', '2.4.0'])` running \
            composer-test.phar over HTTP; requires Symfony Process and the composer-test.phar \
            fixture, neither ported"]
fn test_update_to_specific_version() {
    let _tear_down = set_up();

    todo!()
}

#[test]
#[serial]
fn test_update_with_invalid_option_throws_exception() {
    let _tear_down = set_up();

    let mut app_tester = get_application_tester();
    let err = app_tester
        .run(
            vec![
                (PhpMixed::from("command"), PhpMixed::from("self-update")),
                (PhpMixed::from("invalid-option"), PhpMixed::from(true)),
            ],
            RunOptions::default(),
        )
        .expect_err("expected InvalidArgumentException for the unknown argument");

    assert!(
        err.to_string()
            .contains("The \"invalid-option\" argument does not exist."),
        "expected error about unknown argument, got: {:?}",
        err,
    );
}

#[test]
#[serial]
#[ignore = "spawns `new Process([PHP_BINARY, $this->phar, 'self-update', $option])` running \
            composer-test.phar over HTTP (data provider: --stable/--preview/--snapshot); requires \
            Symfony Process and the composer-test.phar fixture, neither ported"]
fn test_update_to_different_channel() {
    let _tear_down = set_up();

    todo!()
}