mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-06 19:40:08 +02:00
✅ Checked and updated tests
This commit is contained in:
@ -24,6 +24,9 @@ struct BrewPhpFormula: Equatable {
|
|||||||
/// Whether this formula is a stable version of PHP.
|
/// Whether this formula is a stable version of PHP.
|
||||||
let prerelease: Bool
|
let prerelease: Bool
|
||||||
|
|
||||||
|
/// Whether this formula's associated Homebrew file exists.
|
||||||
|
var hasFormulaFile: Bool = false
|
||||||
|
|
||||||
/// Whether the formula is currently installed.
|
/// Whether the formula is currently installed.
|
||||||
var isInstalled: Bool {
|
var isInstalled: Bool {
|
||||||
return installedVersion != nil
|
return installedVersion != nil
|
||||||
@ -41,6 +44,7 @@ struct BrewPhpFormula: Equatable {
|
|||||||
self.installedVersion = installedVersion
|
self.installedVersion = installedVersion
|
||||||
self.upgradeVersion = upgradeVersion
|
self.upgradeVersion = upgradeVersion
|
||||||
self.prerelease = prerelease
|
self.prerelease = prerelease
|
||||||
|
self.hasFormulaFile = checkFormulaFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the formula can be upgraded.
|
/// Whether the formula can be upgraded.
|
||||||
@ -48,17 +52,6 @@ struct BrewPhpFormula: Equatable {
|
|||||||
return upgradeVersion != nil
|
return upgradeVersion != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasFormulaFile: Bool {
|
|
||||||
guard let version = shortVersion else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return FileSystem.fileExists(
|
|
||||||
"\(Paths.tapPath)/shivammathur/homebrew-php/Formula/php@\(version).rb"
|
|
||||||
.replacingOccurrences(of: "php@" + PhpEnvironments.brewPhpAlias, with: "php")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Whether this formula alias is different.
|
/// Whether this formula alias is different.
|
||||||
var hasUpgradedFormulaAlias: Bool {
|
var hasUpgradedFormulaAlias: Bool {
|
||||||
return self.shortVersion == PhpEnvironments.homebrewBrewPhpAlias
|
return self.shortVersion == PhpEnvironments.homebrewBrewPhpAlias
|
||||||
@ -102,6 +95,21 @@ struct BrewPhpFormula: Equatable {
|
|||||||
return isHealthy() ?? true
|
return isHealthy() ?? true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Verify whether the formula file exists (sourced via `shivammathur/homebrew-php`).
|
||||||
|
If it does not exist, the formula cannot be installed.
|
||||||
|
*/
|
||||||
|
private func checkFormulaFile() -> Bool {
|
||||||
|
guard let version = shortVersion else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return FileSystem.fileExists(
|
||||||
|
"\(Paths.tapPath)/shivammathur/homebrew-php/Formula/php@\(version).rb"
|
||||||
|
.replacingOccurrences(of: "php@" + PhpEnvironments.brewPhpAlias, with: "php")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if this PHP installation is healthy.
|
* Determines if this PHP installation is healthy.
|
||||||
* Uses the cached installation health check as basis.
|
* Uses the cached installation health check as basis.
|
||||||
|
@ -193,6 +193,7 @@ struct PhpVersionManagerView: View {
|
|||||||
.buttonStyle(.automatic)
|
.buttonStyle(.automatic)
|
||||||
.controlSize(.large)
|
.controlSize(.large)
|
||||||
}
|
}
|
||||||
|
.accessibilityIdentifier("RefreshButton")
|
||||||
.focusable(false)
|
.focusable(false)
|
||||||
.disabled(self.status.busy)
|
.disabled(self.status.busy)
|
||||||
|
|
||||||
|
@ -35,6 +35,19 @@ class TestableConfigurations {
|
|||||||
"loopback": "127.0.0.1"
|
"loopback": "127.0.0.1"
|
||||||
}
|
}
|
||||||
"""),
|
"""),
|
||||||
|
"/opt/homebrew/Library/Taps/shivammathur/homebrew-php/Formula/php.rb" : .fake(.text),
|
||||||
|
// "/opt/homebrew/Library/Taps/shivammathur/homebrew-php/Formula/php@8.5.rb" : .fake(.text),
|
||||||
|
"/opt/homebrew/Library/Taps/shivammathur/homebrew-php/Formula/php@8.4.rb" : .fake(.text),
|
||||||
|
"/opt/homebrew/Library/Taps/shivammathur/homebrew-php/Formula/php@8.3.rb" : .fake(.text),
|
||||||
|
"/opt/homebrew/Library/Taps/shivammathur/homebrew-php/Formula/php@8.2.rb" : .fake(.text),
|
||||||
|
"/opt/homebrew/Library/Taps/shivammathur/homebrew-php/Formula/php@8.1.rb" : .fake(.text),
|
||||||
|
"/opt/homebrew/Library/Taps/shivammathur/homebrew-php/Formula/php@8.0.rb" : .fake(.text),
|
||||||
|
"/opt/homebrew/Library/Taps/shivammathur/homebrew-php/Formula/php@7.4.rb" : .fake(.text),
|
||||||
|
"/opt/homebrew/Library/Taps/shivammathur/homebrew-php/Formula/php@7.3.rb" : .fake(.text),
|
||||||
|
"/opt/homebrew/Library/Taps/shivammathur/homebrew-php/Formula/php@7.2.rb" : .fake(.text),
|
||||||
|
"/opt/homebrew/Library/Taps/shivammathur/homebrew-php/Formula/php@7.1.rb" : .fake(.text),
|
||||||
|
"/opt/homebrew/Library/Taps/shivammathur/homebrew-php/Formula/php@7.0.rb" : .fake(.text),
|
||||||
|
"/opt/homebrew/Library/Taps/shivammathur/homebrew-php/Formula/php@5.6.rb" : .fake(.text)
|
||||||
],
|
],
|
||||||
shellOutput: [
|
shellOutput: [
|
||||||
"/opt/homebrew/bin/brew --version"
|
"/opt/homebrew/bin/brew --version"
|
||||||
|
@ -85,22 +85,27 @@ final class MainMenuTest: UITestCase {
|
|||||||
|
|
||||||
final func test_can_open_php_version_manager() throws {
|
final func test_can_open_php_version_manager() throws {
|
||||||
let app = launch(openMenu: true)
|
let app = launch(openMenu: true)
|
||||||
|
|
||||||
app.mainMenuItem(withText: "mi_php_version_manager".localized).click()
|
app.mainMenuItem(withText: "mi_php_version_manager".localized).click()
|
||||||
|
|
||||||
// Should display loader
|
// Should display loader
|
||||||
assertExists(app.staticTexts["phpman.busy.title".localized], 1)
|
assertExists(app.staticTexts["phpman.busy.title".localized], 1)
|
||||||
|
|
||||||
// After loading, should display PHP 8.2 and PHP 8.3
|
// After loading, should display PHP 8.2, PHP 8.3, PHP 8.4
|
||||||
assertExists(app.staticTexts["PHP 8.2"], 5)
|
assertExists(app.staticTexts["PHP 8.2"], 5)
|
||||||
assertExists(app.staticTexts["PHP 8.3"])
|
assertExists(app.staticTexts["PHP 8.3"])
|
||||||
|
assertExists(app.staticTexts["PHP 8.4"])
|
||||||
|
|
||||||
// Should also display pre-release version
|
// Should also display pre-release version
|
||||||
assertExists(app.staticTexts["PHP 8.4"])
|
assertExists(app.staticTexts["PHP 8.5"])
|
||||||
assertExists(app.staticTexts["phpman.version.prerelease".localized.uppercased()])
|
assertExists(app.staticTexts["phpman.version.prerelease".localized.uppercased()])
|
||||||
assertExists(app.staticTexts["phpman.version.available_for_installation".localized])
|
assertExists(app.staticTexts["phpman.version.available_for_installation".localized])
|
||||||
|
|
||||||
// But not PHP 8.5 (yet)
|
// The pre-release version should be unavailable
|
||||||
assertNotExists(app.staticTexts["PHP 8.5"])
|
assertExists(app.staticTexts["phpman.version.unavailable".localized])
|
||||||
|
|
||||||
|
// But not PHP 8.6 (yet)
|
||||||
|
assertNotExists(app.staticTexts["PHP 8.6"])
|
||||||
|
|
||||||
// Also, PHP 8.2 should have an update available
|
// Also, PHP 8.2 should have an update available
|
||||||
assertExists(app.staticTexts["phpman.version.has_update".localized(
|
assertExists(app.staticTexts["phpman.version.has_update".localized(
|
||||||
|
Reference in New Issue
Block a user