mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
The version constraint checks will also be used in the future to evaluate whether any given site's PHP constraint (if set) is valid for the currently linked version of PHP. For example, assuming you have PHP 8.1.2 linked, we could evaluate: * A site requires "8.0" -> invalid * A site requires "^8.0" -> valid * A site requires "^8.0.0" -> valid * A site requires "~8.0" -> valid * A site requires "~8.0.0" -> invalid Currently, this constraint check is used to determine which versions that are currently installed are good suggestions to switch to. If you have a site with constraint "^8.0" for example, and you have PHP 8.0 and 8.1 installed (with 8.1 linked), then you will get a suggestion to switch back to 8.0.
30 lines
872 B
Swift
30 lines
872 B
Swift
//
|
|
// PhpVersionDetectionTest.swift
|
|
// phpmon-tests
|
|
//
|
|
// Created by Nico Verbruggen on 01/04/2021.
|
|
// Copyright © 2021 Nico Verbruggen. All rights reserved.
|
|
//
|
|
|
|
import XCTest
|
|
|
|
class PhpVersionDetectionTest: XCTestCase {
|
|
|
|
func testCanDetectValidPhpVersions() throws {
|
|
let outcome = PhpEnv.shared.extractPhpVersions(from: [
|
|
"", // empty lines should be omitted
|
|
"php@8.0",
|
|
"php@8.0", // should only be detected once
|
|
"meta-php@8.0", // should be omitted, invalid
|
|
"php@8.0-coolio", // should be omitted, invalid
|
|
"php@7.0",
|
|
"",
|
|
"unrelatedphp@1.0", // should be omitted, invalid
|
|
"php@5.6",
|
|
"php@5.4" // should be omitted, not supported
|
|
], checkBinaries: false)
|
|
|
|
XCTAssertEqual(outcome, ["8.0", "7.0", "5.6"])
|
|
}
|
|
}
|