1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-03-28 15:00:06 +01:00

♻️ Refactor tests to Swift Testing

This commit is contained in:
2025-10-16 15:57:41 +02:00
parent 378a8a5547
commit fa403b5a99
24 changed files with 191 additions and 203 deletions

View File

@@ -6,70 +6,66 @@
// Copyright © 2023 Nico Verbruggen. All rights reserved.
//
import XCTest
import Testing
import Foundation
class AppVersionTest: XCTestCase {
func test_can_retrieve_internal_app_version() {
XCTAssertNotNil(AppVersion.fromCurrentVersion())
}
func test_can_parse_normal_version_string() {
struct AppVersionTest {
@Test func test_can_parse_normal_version_string() {
let version = AppVersion.from("1.0.0")
XCTAssertNotNil(version)
XCTAssertEqual("1.0.0", version?.version)
XCTAssertEqual(nil, version?.build)
XCTAssertEqual(nil, version?.suffix)
#expect(version != nil)
#expect(version!.version == "1.0.0")
#expect(version!.build == nil)
#expect(version!.suffix == nil)
}
func test_can_parse_cask_version_string() {
@Test func test_can_parse_cask_version_string() {
let version = AppVersion.from("1.0.0_600")
XCTAssertNotNil(version)
XCTAssertEqual("1.0.0", version?.version)
XCTAssertEqual(600, version?.build)
XCTAssertEqual(nil, version?.suffix)
#expect(version != nil)
#expect(version!.version == "1.0.0")
#expect(version!.build == 600)
#expect(version!.suffix == nil)
}
func test_can_parse_dev_version_string_without_build_number() {
@Test func test_can_parse_dev_version_string_without_build_number() {
let version = AppVersion.from("1.0.0-dev")
XCTAssertNotNil(version)
XCTAssertEqual("1.0.0", version?.version)
XCTAssertEqual(nil, version?.build)
XCTAssertEqual("dev", version?.suffix)
#expect(version != nil)
#expect(version!.version == "1.0.0")
#expect(version!.build == nil)
#expect(version!.suffix == "dev")
}
func test_can_parse_dev_version_string_with_build_number() {
@Test func test_can_parse_dev_version_string_with_build_number() {
let version = AppVersion.from("1.0.0-dev,870")
XCTAssertNotNil(version)
XCTAssertEqual("1.0.0", version?.version)
XCTAssertEqual(870, version?.build)
XCTAssertEqual("dev", version?.suffix)
#expect(version != nil)
#expect(version!.version == "1.0.0")
#expect(version!.build == 870)
#expect(version!.suffix == "dev")
}
func test_can_parse_underscores_as_build_separator() {
@Test func test_can_parse_underscores_as_build_separator() {
let version = AppVersion.from("1.0.0-dev_870")
XCTAssertNotNil(version)
XCTAssertEqual("1.0.0", version?.version)
XCTAssertEqual(870, version?.build)
XCTAssertEqual("dev", version?.suffix)
#expect(version != nil)
#expect(version!.version == "1.0.0")
#expect(version!.build == 870)
#expect(version!.suffix == "dev")
}
func test_can_compare_version_numbers() {
@Test func test_can_compare_version_numbers() {
// Build is newer
XCTAssertTrue(AppVersion.from("5.0_101")! > AppVersion.from("5.0_100")!)
#expect(AppVersion.from("5.0_101")! > AppVersion.from("5.0_100")!)
// Version and build is the same
XCTAssertFalse(AppVersion.from("5.0.0_100")! > AppVersion.from("5.0_100")!)
#expect(AppVersion.from("5.0.0_100")! == AppVersion.from("5.0_100")!)
// Version is newer
XCTAssertTrue(AppVersion.from("5.1_100")! > AppVersion.from("5.0_100")!)
#expect(AppVersion.from("5.1_100")! > AppVersion.from("5.0_100")!)
// Build is older
XCTAssertFalse(AppVersion.from("5.0_101")! > AppVersion.from("5.0_102")!)
#expect(AppVersion.from("5.0_101")! < AppVersion.from("5.0_102")!)
}
}

View File

@@ -6,13 +6,14 @@
// Copyright © 2023 Nico Verbruggen. All rights reserved.
//
import XCTest
import Testing
import Foundation
class PhpVersionDetectionTest: XCTestCase {
func test_can_detect_valid_php_versions() async throws {
struct PhpVersionDetectionTest {
@Test func test_can_detect_valid_php_versions() async throws {
let container = Container.real()
let outcome = await container.phpEnvs.extractPhpVersions(
let versions = await container.phpEnvs.extractPhpVersions(
from: [
"", // empty lines should be omitted
"php@8.0",
@@ -29,6 +30,6 @@ class PhpVersionDetectionTest: XCTestCase {
generateHelpers: false
)
XCTAssertEqual(outcome, ["8.0", "7.0", "5.6"])
#expect(versions == ["8.0", "7.0", "5.6"])
}
}

View File

@@ -6,200 +6,200 @@
// Copyright © 2023 Nico Verbruggen. All rights reserved.
//
import XCTest
import Testing
import Foundation
// swiftlint:disable type_body_length file_length
class PhpVersionNumberTest: XCTestCase {
func test_can_deconstruct_php_version() throws {
XCTAssertEqual(
try! VersionNumber.parse("PHP 8.2.0-dev"),
struct PhpVersionNumberTest {
@Test func test_can_deconstruct_php_version() throws {
#expect(
try! VersionNumber.parse("PHP 8.2.0-dev") ==
VersionNumber(major: 8, minor: 2, patch: 0)
)
XCTAssertEqual(
try! VersionNumber.parse("PHP 8.1.0RC5-dev"),
#expect(
try! VersionNumber.parse("PHP 8.1.0RC5-dev") ==
VersionNumber(major: 8, minor: 1, patch: 0)
)
XCTAssertEqual(
try! VersionNumber.parse("8.0.11"),
#expect(
try! VersionNumber.parse("8.0.11") ==
VersionNumber(major: 8, minor: 0, patch: 11)
)
XCTAssertEqual(
try! VersionNumber.parse("7.4.2"),
#expect(
try! VersionNumber.parse("7.4.2") ==
VersionNumber(major: 7, minor: 4, patch: 2)
)
XCTAssertEqual(
try! VersionNumber.parse("7.4"),
#expect(
try! VersionNumber.parse("7.4") ==
VersionNumber(major: 7, minor: 4, patch: nil)
)
XCTAssertEqual(
VersionNumber.make(from: "7"),
#expect(
VersionNumber.make(from: "7") ==
nil
)
}
func test_php_version_number_parse() throws {
XCTAssertThrowsError(try VersionNumber.parse("OOF")) { error in
XCTAssertTrue(error is VersionParseError)
@Test func test_php_version_number_parse() throws {
#expect(throws: VersionParseError.self) {
try VersionNumber.parse("OOF")
}
}
func test_can_parse_wildcard() throws {
@Test func test_can_parse_wildcard() throws {
let version = VersionNumber.make(from: "7.*", type: .wildCardMinor)
XCTAssertNotNil(version)
XCTAssertEqual(version!.major, 7)
XCTAssertEqual(version!.minor, 0)
let unwrappedVersion = try #require(version)
#expect(unwrappedVersion.major == 7)
#expect(unwrappedVersion.minor == 0)
}
func test_can_check_wildcard_version_constraint() throws {
@Test func test_can_check_wildcard_version_constraint() throws {
// Wildcard for patch only
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.3.9"])
.matching(constraint: "7.3.*", strict: false),
.matching(constraint: "7.3.*", strict: false) ==
PhpVersionNumberCollection
.make(from: ["7.3.10", "7.3.9"]).all
)
// Wildcard for minor
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["8.0.0", "7.4.10", "7.3.10", "7.3.9"])
.matching(constraint: "7.*", strict: false),
.matching(constraint: "7.*", strict: false) ==
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.3.9"]).all
)
// Full wildcard
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
.matching(constraint: "*", strict: false),
.matching(constraint: "*", strict: false) ==
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"]).all
)
}
func test_can_check_any_version_constraint() throws {
XCTAssertEqual(
@Test func test_can_check_any_version_constraint() throws {
#expect(
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
.matching(constraint: "*", strict: false),
.matching(constraint: "*", strict: false) ==
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"]).all
)
}
func test_can_check_fixed_constraints() throws {
XCTAssertEqual(
@Test func test_can_check_fixed_constraints() throws {
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "7.0"),
.matching(constraint: "7.0") ==
PhpVersionNumberCollection
.make(from: ["7.0"]).all
)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4.3", "7.3.3", "7.2.3", "7.1.3", "7.0.3"])
.matching(constraint: "7.0.3"),
.matching(constraint: "7.0.3") ==
PhpVersionNumberCollection
.make(from: ["7.0.3"]).all
)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "7.0.3", strict: false),
.matching(constraint: "7.0.3", strict: false) ==
PhpVersionNumberCollection
.make(from: ["7.0"]).all
)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "7.0.3", strict: true),
.matching(constraint: "7.0.3", strict: true) ==
PhpVersionNumberCollection
.make(from: []).all
)
}
func test_can_check_caret_constraints() throws {
@Test func test_can_check_caret_constraints() throws {
// 1. Imprecise checks
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "^7.0", strict: true),
.matching(constraint: "^7.0", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"]).all
)
// 2. Imprecise check with precise constraint (lenient AKA not strict)
// These versions are interpreted as 7.4.999, 7.3.999, 7.2.999, etc.
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "^7.0.1", strict: false),
.matching(constraint: "^7.0.1", strict: false) ==
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"]).all
)
// 3. Imprecise check with precise constraint (strict mode)
// These versions are interpreted as 7.4.0, 7.3.0, 7.2.0, etc.
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "^7.0.1", strict: true),
.matching(constraint: "^7.0.1", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1"]).all
)
// 4. Precise members and constraint all around
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
.matching(constraint: "^7.0.1", strict: true),
.matching(constraint: "^7.0.1", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"]).all
)
// 5. Precise members but imprecise constraint (strict mode)
// In strict mode the constraint's patch version is assumed to be 0
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
.matching(constraint: "^7.0", strict: true),
.matching(constraint: "^7.0", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"]).all
)
// 6. Precise members but imprecise constraint (lenient mode)
// In lenient mode the constraint's patch version is assumed to be equal
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
.matching(constraint: "^7.0", strict: false),
.matching(constraint: "^7.0", strict: false) ==
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"]).all
)
}
func test_can_check_tilde_constraints() throws {
@Test func test_can_check_tilde_constraints() throws {
// 1. Imprecise checks
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "~7.0", strict: true),
.matching(constraint: "~7.0", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"]).all
)
// 2. Imprecise check with precise constraint (lenient AKA not strict)
// These versions are interpreted as 7.4.999, 7.3.999, 7.2.999, etc.
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "~7.0.1", strict: false),
.matching(constraint: "~7.0.1", strict: false) ==
// One result because 7.0.1 to 7.0.x is expected.
// 7.0.999 (assumed due to no strictness) is valid.
// 7.1.0 and up are not valid (minor version is too high).
@@ -209,10 +209,10 @@ class PhpVersionNumberTest: XCTestCase {
// 3. Imprecise check with precise constraint (strict mode)
// These versions are interpreted as 7.4.0, 7.3.0, 7.2.0, etc.
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "~7.0.1", strict: true),
.matching(constraint: "~7.0.1", strict: true) ==
// No results because 7.0.1 to 7.0.x is expected.
// 7.0.0 (assumed due to strictness) is not valid.
// 7.1.0 and up are also not valid (minor version is too high).
@@ -221,10 +221,10 @@ class PhpVersionNumberTest: XCTestCase {
)
// 4. Precise members and constraint all around
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
.matching(constraint: "~7.0.1", strict: true),
.matching(constraint: "~7.0.1", strict: true) ==
// Only 7.0 with a patch version of .1 or higher is OK.
// In this example, 7.0.10 is OK but all other versions are too new.
PhpVersionNumberCollection
@@ -233,10 +233,10 @@ class PhpVersionNumberTest: XCTestCase {
// 5. Precise members but imprecise constraint (strict mode)
// In strict mode the constraint's patch version is assumed to be 0.
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
.matching(constraint: "~7.0", strict: true),
.matching(constraint: "~7.0", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"]).all
)
@@ -244,164 +244,164 @@ class PhpVersionNumberTest: XCTestCase {
// 6. Precise members but imprecise constraint (lenient mode)
// In lenient mode the constraint's patch version is assumed to be equal.
// (Strictness does not make any difference here, but both should be tested.)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
.matching(constraint: "~7.0", strict: false),
.matching(constraint: "~7.0", strict: false) ==
PhpVersionNumberCollection
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"]).all
)
}
func test_can_check_greater_than_or_equal_constraints() throws {
XCTAssertEqual(
@Test func test_can_check_greater_than_or_equal_constraints() throws {
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: ">=7.0", strict: true),
.matching(constraint: ">=7.0", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"]).all
)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: ">=7.0.0", strict: true),
.matching(constraint: ">=7.0.0", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"]).all
)
// Strict check (>7.2.5 is too new for 7.2 which resolves to 7.2.0)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: ">=7.2.5", strict: true),
.matching(constraint: ">=7.2.5", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.4", "7.3"]).all
)
// Non-strict check (ignoring patch, 7.2 resolves to 7.2.999)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: ">=7.2.5", strict: false),
.matching(constraint: ">=7.2.5", strict: false) ==
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2"]).all
)
}
func test_can_check_greater_than_constraints() throws {
XCTAssertEqual(
@Test func test_can_check_greater_than_constraints() throws {
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: ">7.0"),
.matching(constraint: ">7.0") ==
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1"]).all
)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: ">7.2.5"),
.matching(constraint: ">7.2.5") ==
// 7.2 will be valid due to non-strict mode (resolves to 7.2.999)
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2"]).all
)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: ">7.2.5", strict: true),
.matching(constraint: ">7.2.5", strict: true) ==
// 7.2 will not be valid due to strict mode (resolves to 7.2.0)
PhpVersionNumberCollection
.make(from: ["7.4", "7.3"]).all
)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.3.1", "7.2.9", "7.2.8", "7.2.6", "7.2.5", "7.2"])
.matching(constraint: ">7.2.8"),
.matching(constraint: ">7.2.8") ==
// 7.2 will be valid due to non-strict mode (resolves to 7.2.999)
PhpVersionNumberCollection
.make(from: ["7.3.1", "7.2.9", "7.2"]).all
)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.3.1", "7.2.9", "7.2.8", "7.2.6", "7.2.5", "7.2"])
.matching(constraint: ">7.2.8", strict: true),
.matching(constraint: ">7.2.8", strict: true) ==
// 7.2 will not be valid due to strict mode (resolves to 7.2.0)
PhpVersionNumberCollection
.make(from: ["7.3.1", "7.2.9"]).all
)
}
func test_can_check_less_than_or_equal_constraints() throws {
XCTAssertEqual(
@Test func test_can_check_less_than_or_equal_constraints() throws {
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "<=7.2", strict: true),
.matching(constraint: "<=7.2", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.2", "7.1", "7.0"]).all
)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "<=7.2.0", strict: true),
.matching(constraint: "<=7.2.0", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.2", "7.1", "7.0"]).all
)
// Strict check (>7.2.5 is too new for 7.2 which resolves to 7.2.0)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "<=7.2.5", strict: true),
.matching(constraint: "<=7.2.5", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.2", "7.1", "7.0"]).all
)
// Non-strict check (ignoring patch has no effect)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "<=7.2.5", strict: false),
.matching(constraint: "<=7.2.5", strict: false) ==
PhpVersionNumberCollection
.make(from: ["7.2", "7.1", "7.0"]).all
)
}
func test_can_check_less_than_constraints() throws {
XCTAssertEqual(
@Test func test_can_check_less_than_constraints() throws {
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "<7.2", strict: true),
.matching(constraint: "<7.2", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.1", "7.0"]).all
)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "<7.2.0", strict: true),
.matching(constraint: "<7.2.0", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.1", "7.0"]).all
)
// Strict check (>7.2.5 is too new for 7.2 which resolves to 7.2.0)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "<7.2.5", strict: true),
.matching(constraint: "<7.2.5", strict: true) ==
PhpVersionNumberCollection
.make(from: ["7.2", "7.1", "7.0"]).all
)
// Non-strict check (patch resolves to 7.2.999, which is bigger than 7.2.5)
XCTAssertEqual(
#expect(
PhpVersionNumberCollection
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
.matching(constraint: "<7.2.5", strict: false),
.matching(constraint: "<7.2.5", strict: false) ==
PhpVersionNumberCollection
.make(from: ["7.1", "7.0"]).all
)

View File

@@ -6,11 +6,11 @@
// Copyright © 2023 Nico Verbruggen. All rights reserved.
//
import XCTest
import Testing
import Foundation
class ValetVersionExtractorTest: XCTestCase {
func test_can_determine_valet_version_regardless_of_deprecations() async {
class ValetVersionExtractorTest {
@Test func test_can_determine_valet_version_regardless_of_deprecations() async {
let output = """
Deprecated: Return type of Tightenco\\Collect\\Support\\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/dummy/.composer/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1789
@@ -35,6 +35,6 @@ class ValetVersionExtractorTest: XCTestCase {
let version = try! VersionNumber.parse(VersionExtractor.from(versionString)!)
XCTAssertEqual(version.major, 3)
#expect(version.major == 3)
}
}

View File

@@ -6,20 +6,19 @@
// Copyright © 2023 Nico Verbruggen. All rights reserved.
//
import XCTest
import Testing
import Foundation
class VersionExtractorTest: XCTestCase {
func test_extract_version() {
XCTAssertEqual(VersionExtractor.from("Laravel Valet 2.17.1"), "2.17.1")
XCTAssertEqual(VersionExtractor.from("Laravel Valet 2.0"), "2.0")
struct VersionExtractorTest {
@Test func test_extract_version() {
#expect(VersionExtractor.from("Laravel Valet 2.17.1") == "2.17.1")
#expect(VersionExtractor.from("Laravel Valet 2.0") == "2.0")
}
func test_version_comparison() {
XCTAssertEqual("2.0".versionCompare("2.1"), .orderedAscending)
XCTAssertEqual("2.1".versionCompare("2.0"), .orderedDescending)
XCTAssertEqual("2.0".versionCompare("2.0"), .orderedSame)
XCTAssertEqual("2.17.0".versionCompare("2.17.1"), .orderedAscending)
@Test func test_version_comparison() {
#expect("2.0".versionCompare("2.1") == .orderedAscending)
#expect("2.1".versionCompare("2.0") == .orderedDescending)
#expect("2.0".versionCompare("2.0") == .orderedSame)
#expect("2.17.0".versionCompare("2.17.1") == .orderedAscending)
}
}