diff --git a/phpmon/Common/Testables/TestableConfiguration.swift b/phpmon/Common/Testables/TestableConfiguration.swift index 0b2d3b6..0f6d230 100644 --- a/phpmon/Common/Testables/TestableConfiguration.swift +++ b/phpmon/Common/Testables/TestableConfiguration.swift @@ -73,12 +73,22 @@ public struct TestableConfiguration: Codable { : .fake(.text) ]) { (_, new) in new } - self.commandOutput["/opt/homebrew/opt/php@\(version.short)/bin/php-config --version"] - = version.long + self.shellOutput["/opt/homebrew/opt/php@\(version.short)/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'"] = + .instant("/opt/homebrew/etc/php/\(version.short)/conf.d/php-memory-limits.ini") + + self.shellOutput["/opt/homebrew/bin/brew unlink php@\(version.short)"] = .delayed(0.2, "OK") + self.shellOutput["sudo /opt/homebrew/bin/brew services stop php@\(version.short)"] = .delayed(0.2, "OK") + self.shellOutput["sudo /opt/homebrew/bin/brew services start php@\(version.short)"] = .delayed(0.2, "OK") + self.shellOutput["/opt/homebrew/bin/brew link php@\(version.short) --overwrite --force"] = .delayed(0.2, "OK") + + self.commandOutput["/opt/homebrew/opt/php@\(version.short)/bin/php-config --version"] = version.long + self.commandOutput["/opt/homebrew/opt/php@\(version.short)/bin/php -v"] = "OK" if primary { - self.shellOutput["ls /opt/homebrew/opt | grep php"] - = .instant("php") + self.shellOutput["ls /opt/homebrew/opt | grep php"] = + .instant("php") + self.shellOutput["/opt/homebrew/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'"] = + .instant("/opt/homebrew/etc/php/\(version.short)/conf.d/php-memory-limits.ini") self.filesystem["/opt/homebrew/opt/php"] = .fake(.symlink, "/opt/homebrew/Cellar/php/\(version.long)") self.filesystem["/opt/homebrew/opt/php/bin/php"] @@ -89,10 +99,6 @@ public struct TestableConfiguration: Codable { = .fake(.symlink, "/opt/homebrew/Cellar/php/\(version.short)/bin/php-config") self.commandOutput["/opt/homebrew/bin/php-config --version"] = version.long - self.commandOutput["/opt/homebrew/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'"] = - """ - /opt/homebrew/etc/php/\(version.short)/conf.d/php-memory-limits.ini, - """ } else { self.shellOutput["ls /opt/homebrew/opt | grep php@"] = BatchFakeShellOutput.instant( diff --git a/phpmon/Domain/App/AppDelegate.swift b/phpmon/Domain/App/AppDelegate.swift index d736251..5755588 100644 --- a/phpmon/Domain/App/AppDelegate.swift +++ b/phpmon/Domain/App/AppDelegate.swift @@ -109,6 +109,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele static func initializeTestingProfile(_ path: String) { Log.info("The configuration with path `\(path)` is being requested...") + // Clear for PHP Guard + Stats.clearCurrentGlobalPhpVersion() + // Load the configuration file TestableConfiguration.loadFrom(path: path).apply() } diff --git a/phpmon/Domain/Preferences/Stats.swift b/phpmon/Domain/Preferences/Stats.swift index 1af2aed..1b912a2 100644 --- a/phpmon/Domain/Preferences/Stats.swift +++ b/phpmon/Domain/Preferences/Stats.swift @@ -84,6 +84,10 @@ class Stats { ) } + public static func clearCurrentGlobalPhpVersion() { + UserDefaults.standard.removeObject(forKey: InternalStats.lastGlobalPhpVersion.rawValue) + } + /** Determine if the sponsor message should be displayed. diff --git a/tests/Shared/TestableConfigurations.swift b/tests/Shared/TestableConfigurations.swift index 6a7eff1..017e551 100644 --- a/tests/Shared/TestableConfigurations.swift +++ b/tests/Shared/TestableConfigurations.swift @@ -181,9 +181,6 @@ class TestableConfigurations { "/opt/homebrew/bin/php -r echo ini_get('memory_limit');": "512M", "/opt/homebrew/bin/php -r echo ini_get('upload_max_filesize');": "512M", "/opt/homebrew/bin/php -r echo ini_get('post_max_size');": "512M", - "/opt/homebrew/opt/php@8.2/bin/php -v": "OK (no full output needed for testing)", - "/opt/homebrew/opt/php@8.1/bin/php -v": "OK (no full output needed for testing)", - "/opt/homebrew/opt/php@8.0/bin/php -v": "OK (no full output needed for testing)" ], preferenceOverrides: [ .automaticBackgroundUpdateCheck: false @@ -191,7 +188,8 @@ class TestableConfigurations { phpVersions: [ VersionNumber(major: 8, minor: 2, patch: 6), VersionNumber(major: 8, minor: 1, patch: 0), - VersionNumber(major: 8, minor: 0, patch: 0) + VersionNumber(major: 8, minor: 0, patch: 0), + VersionNumber(major: 7, minor: 4, patch: 33) ] ) }