mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-03-26 22:20:06 +01:00
✅ Fix tests
This commit is contained in:
@@ -53,13 +53,14 @@ class HomebrewPackageTest: XCTestCase {
|
|||||||
/// and requires the Valet services to be installed: php, nginx and dnsmasq.
|
/// and requires the Valet services to be installed: php, nginx and dnsmasq.
|
||||||
/// If this test fails, there is an issue with your Homebrew installation
|
/// If this test fails, there is an issue with your Homebrew installation
|
||||||
/// or the JSON API of the Homebrew output may have changed.
|
/// or the JSON API of the Homebrew output may have changed.
|
||||||
func testCanParseServicesJsonFromCliOutput() throws {
|
func testCanParseServicesJsonFromCliOutput() async throws {
|
||||||
|
ActiveShell.useSystem()
|
||||||
|
|
||||||
let services = try! JSONDecoder().decode(
|
let services = try! JSONDecoder().decode(
|
||||||
[HomebrewService].self,
|
[HomebrewService].self,
|
||||||
from: LegacyShell.pipe(
|
from: await Shell.pipe(
|
||||||
"sudo \(Paths.brew) services info --all --json",
|
"sudo \(Paths.brew) services info --all --json"
|
||||||
requiresPath: true
|
).out.data(using: .utf8)!
|
||||||
).data(using: .utf8)!
|
|
||||||
).filter({ service in
|
).filter({ service in
|
||||||
return ["php", "nginx", "dnsmasq"].contains(service.name)
|
return ["php", "nginx", "dnsmasq"].contains(service.name)
|
||||||
})
|
})
|
||||||
@@ -74,10 +75,12 @@ class HomebrewPackageTest: XCTestCase {
|
|||||||
/// and requires the `php` formula to be installed.
|
/// and requires the `php` formula to be installed.
|
||||||
/// If this test fails, there is an issue with your Homebrew installation
|
/// If this test fails, there is an issue with your Homebrew installation
|
||||||
/// or the JSON API of the Homebrew output may have changed.
|
/// or the JSON API of the Homebrew output may have changed.
|
||||||
func testCanLoadExtensionJsonFromCliOutput() throws {
|
func testCanLoadExtensionJsonFromCliOutput() async throws {
|
||||||
|
ActiveShell.useSystem()
|
||||||
|
|
||||||
let package = try! JSONDecoder().decode(
|
let package = try! JSONDecoder().decode(
|
||||||
[HomebrewPackage].self,
|
[HomebrewPackage].self,
|
||||||
from: LegacyShell.pipe("\(Paths.brew) info php --json", requiresPath: true).data(using: .utf8)!
|
from: await Shell.pipe("\(Paths.brew) info php --json").out.data(using: .utf8)!
|
||||||
).first!
|
).first!
|
||||||
|
|
||||||
XCTAssertTrue(package.name == "php")
|
XCTAssertTrue(package.name == "php")
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class PhpExtensionTest: XCTestCase {
|
|||||||
XCTAssertEqual(extensions[1].enabled, false)
|
XCTAssertEqual(extensions[1].enabled, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testToggleWorksAsExpected() throws {
|
func testToggleWorksAsExpected() async throws {
|
||||||
let destination = Utility.copyToTemporaryFile(resourceName: "php", fileExtension: "ini")!
|
let destination = Utility.copyToTemporaryFile(resourceName: "php", fileExtension: "ini")!
|
||||||
let extensions = PhpExtension.from(filePath: destination.path)
|
let extensions = PhpExtension.from(filePath: destination.path)
|
||||||
XCTAssertEqual(extensions.count, 6)
|
XCTAssertEqual(extensions.count, 6)
|
||||||
@@ -58,7 +58,7 @@ class PhpExtensionTest: XCTestCase {
|
|||||||
let xdebug = extensions.first!
|
let xdebug = extensions.first!
|
||||||
XCTAssertTrue(xdebug.name == "xdebug")
|
XCTAssertTrue(xdebug.name == "xdebug")
|
||||||
XCTAssertEqual(xdebug.enabled, true)
|
XCTAssertEqual(xdebug.enabled, true)
|
||||||
xdebug.toggle()
|
await xdebug.toggle()
|
||||||
XCTAssertEqual(xdebug.enabled, false)
|
XCTAssertEqual(xdebug.enabled, false)
|
||||||
|
|
||||||
// Check if the file contains the appropriate data
|
// Check if the file contains the appropriate data
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import XCTest
|
|||||||
|
|
||||||
class AppUpdaterCheckTest: XCTestCase {
|
class AppUpdaterCheckTest: XCTestCase {
|
||||||
|
|
||||||
func testCanRetrieveVersionFromCask() {
|
func testCanRetrieveVersionFromCask() async {
|
||||||
let caskVersion = AppUpdateChecker.retrieveVersionFromCask()
|
let caskVersion = await AppUpdateChecker.retrieveVersionFromCask()
|
||||||
|
|
||||||
let version = VersionExtractor.from(caskVersion)
|
let version = VersionExtractor.from(caskVersion)
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import XCTest
|
|||||||
|
|
||||||
class PhpVersionDetectionTest: XCTestCase {
|
class PhpVersionDetectionTest: XCTestCase {
|
||||||
|
|
||||||
func testCanDetectValidPhpVersions() throws {
|
func testCanDetectValidPhpVersions() async throws {
|
||||||
let outcome = PhpEnv.shared.extractPhpVersions(from: [
|
let outcome = await PhpEnv.shared.extractPhpVersions(from: [
|
||||||
"", // empty lines should be omitted
|
"", // empty lines should be omitted
|
||||||
"php@8.0",
|
"php@8.0",
|
||||||
"php@8.0", // should only be detected once
|
"php@8.0", // should only be detected once
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import XCTest
|
|||||||
|
|
||||||
class ValetVersionExtractorTest: XCTestCase {
|
class ValetVersionExtractorTest: XCTestCase {
|
||||||
|
|
||||||
func testDetermineValetVersion() {
|
func testDetermineValetVersion() async {
|
||||||
let version = valet("--version", sudo: false)
|
let version = await valet("--version", sudo: false)
|
||||||
XCTAssert(version.contains("Laravel Valet 2") || version.contains("Laravel Valet 3"))
|
XCTAssert(version.contains("Laravel Valet 2") || version.contains("Laravel Valet 3"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,19 @@ extension MainMenu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func restartNginx() {
|
||||||
|
Task { // Simple restart service
|
||||||
|
await Actions.restartNginx()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func restartDnsMasq() {
|
||||||
|
Task { // Simple restart service
|
||||||
|
await Actions.restartDnsMasq()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@MainActor @objc func restartValetServices() {
|
@MainActor @objc func restartValetServices() {
|
||||||
Task { // Restart services and show notification
|
Task { // Restart services and show notification
|
||||||
await Actions.restartDnsMasq()
|
await Actions.restartDnsMasq()
|
||||||
@@ -73,18 +86,6 @@ extension MainMenu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func restartNginx() {
|
|
||||||
Task {
|
|
||||||
await Actions.restartNginx()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc func restartDnsMasq() {
|
|
||||||
Task {
|
|
||||||
await Actions.restartDnsMasq()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc func disableAllXdebugModes() {
|
@objc func disableAllXdebugModes() {
|
||||||
guard let file = PhpEnv.shared.getConfigFile(forKey: "xdebug.mode") else {
|
guard let file = PhpEnv.shared.getConfigFile(forKey: "xdebug.mode") else {
|
||||||
Log.info("xdebug.mode could not be found in any .ini file, aborting.")
|
Log.info("xdebug.mode could not be found in any .ini file, aborting.")
|
||||||
|
|||||||
Reference in New Issue
Block a user