aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/repository/platform_repository_test.rs
blob: c85af4bf9785249b3202cab96ec0d046a3047c28 (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
68
69
70
//! ref: composer/tests/Composer/Test/Repository/PlatformRepositoryTest.php

use shirabe::repository::PlatformRepository;

// These probe runtime/extension/library versions and assert the synthesized platform
// packages; the detection mocks ProcessExecutor/Runtime/HhvmDetector and the package
// versions are parsed through a look-around regex.
#[test]
#[ignore = "requires PHPUnit getMockBuilder mock of Composer\\Platform\\HhvmDetector (willReturn getVersion); Runtime/HhvmDetector are concrete structs with no mock/override mechanism"]
fn test_hhvm_package() {
    todo!()
}

#[test]
#[ignore = "requires PHPUnit getMockBuilder mock of Composer\\Platform\\Runtime (willReturnCallback/willReturnMap for hasConstant/getConstant/invoke/getExtensions); no mocking framework and Runtime is a concrete struct"]
fn test_php_version() {
    todo!()
}

#[test]
#[ignore = "requires PHPUnit getMockBuilder mock of Composer\\Platform\\Runtime (expects(once)/with/willReturn for invoke, willReturnCallback for getConstant); no mocking framework"]
fn test_inet_pton_regression() {
    todo!()
}

#[test]
#[ignore = "requires PHPUnit getMockBuilder mock of Composer\\Platform\\Runtime (willReturnMap/willReturnCallback for getExtensions/getExtensionVersion/getExtensionInfo/invoke/hasConstant/getConstant/hasClass/construct) plus ResourceBundleStub/ImagickStub; no mocking framework"]
fn test_library_information() {
    todo!()
}

#[test]
#[ignore = "requires PHPUnit getMockBuilder mock of Composer\\Platform\\Runtime (willReturnMap for getConstant/getExtensions); no mocking framework and Runtime is a concrete struct"]
fn test_composer_platform_version() {
    todo!()
}

#[test]
fn test_valid_platform_packages() {
    let cases: Vec<(&str, bool)> = vec![
        ("php", true),
        ("php-debug", true),
        ("php-ipv6", true),
        ("php-64bit", true),
        ("php-zts", true),
        ("hhvm", true),
        ("hhvm-foo", false),
        ("ext-foo", true),
        ("ext-123", true),
        ("extfoo", false),
        ("ext", false),
        ("lib-foo", true),
        ("lib-123", true),
        ("libfoo", false),
        ("lib", false),
        ("composer", true),
        ("composer-foo", false),
        ("composer-plugin-api", true),
        ("composer-plugin", false),
        ("composer-runtime-api", true),
        ("composer-runtime", false),
    ];

    for (package_name, expectation) in cases {
        assert_eq!(
            expectation,
            PlatformRepository::is_platform_package(package_name)
        );
    }
}