1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-07 13:20:05 +01:00

♻️ Migrate more tests to Swift Testing (2/?)

This commit is contained in:
2025-09-29 17:12:43 +02:00
parent 5b27d9f0ea
commit ceff52ed11
12 changed files with 119 additions and 133 deletions

View File

@@ -1360,12 +1360,16 @@
036C3A232E5CBC57008DAEDF /* Parsers */ = { 036C3A232E5CBC57008DAEDF /* Parsers */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
C4AF9F76275447F100D44ED0 /* ValetConfigurationTest.swift */, C456A0D12AA6179D0080144F /* BytePhpPreferenceTest.swift */,
C4F780AD25D80B37000DBC97 /* PhpExtensionTest.swift */, C40934AA298EEDA900D25014 /* CaskFileParserTest.swift */,
C4F520662AF03791006787F2 /* ExtensionEnumeratorTest.swift */,
C43A8A2325D9D20D00591B77 /* HomebrewPackageTest.swift */, C43A8A2325D9D20D00591B77 /* HomebrewPackageTest.swift */,
C4AFC4B229C4F43300BF4E0D /* HomebrewUpgradableTest.swift */,
C42CFB1927DFE8BD00862737 /* NginxConfigurationTest.swift */, C42CFB1927DFE8BD00862737 /* NginxConfigurationTest.swift */,
C46FA98A2822F08F00D78807 /* PhpConfigurationFileTest.swift */,
C4F780AD25D80B37000DBC97 /* PhpExtensionTest.swift */,
C4AF9F76275447F100D44ED0 /* ValetConfigurationTest.swift */,
C4551656297AED18009B8466 /* ValetRcTest.swift */, C4551656297AED18009B8466 /* ValetRcTest.swift */,
C456A0D02AA6175D0080144F /* Config */,
); );
path = Parsers; path = Parsers;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -1852,15 +1856,6 @@
path = "PHP Extensions"; path = "PHP Extensions";
sourceTree = "<group>"; sourceTree = "<group>";
}; };
C456A0D02AA6175D0080144F /* Config */ = {
isa = PBXGroup;
children = (
C46FA98A2822F08F00D78807 /* PhpConfigurationFileTest.swift */,
C456A0D12AA6179D0080144F /* BytePhpPreferenceTest.swift */,
);
path = Config;
sourceTree = "<group>";
};
C459B4BE27F6093A00E9B4B4 /* nginx */ = { C459B4BE27F6093A00E9B4B4 /* nginx */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@@ -2190,16 +2185,6 @@
path = Nginx; path = Nginx;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
C4C1019727C65A11001FACC2 /* Parsers */ = {
isa = PBXGroup;
children = (
C40934AA298EEDA900D25014 /* CaskFileParserTest.swift */,
C4AFC4B229C4F43300BF4E0D /* HomebrewUpgradableTest.swift */,
C4F520662AF03791006787F2 /* ExtensionEnumeratorTest.swift */,
);
path = Parsers;
sourceTree = "<group>";
};
C4C1019827C65A1A001FACC2 /* Versions */ = { C4C1019827C65A1A001FACC2 /* Versions */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@@ -2344,7 +2329,6 @@
C471E6D928F9AFC20021E251 /* Testables */, C471E6D928F9AFC20021E251 /* Testables */,
C40C7F1C27720E1400DDDCDC /* Test Files */, C40C7F1C27720E1400DDDCDC /* Test Files */,
C4C1019827C65A1A001FACC2 /* Versions */, C4C1019827C65A1A001FACC2 /* Versions */,
C4C1019727C65A11001FACC2 /* Parsers */,
); );
path = unit; path = unit;
sourceTree = "<group>"; sourceTree = "<group>";

View File

@@ -1,53 +0,0 @@
//
// CaskFileParserTest.swift
// Unit Tests
//
// Created by Nico Verbruggen on 04/02/2023.
// Copyright © 2023 Nico Verbruggen. All rights reserved.
//
import XCTest
class CaskFileParserTest: XCTestCase {
// MARK: - Test Files
static var exampleFilePath: URL {
return Bundle(for: Self.self)
.url(forResource: "phpmon-dev", withExtension: "rb")!
}
func test_can_extract_fields_from_cask_file() async throws {
guard let caskFile = await CaskFile.from(url: CaskFileParserTest.exampleFilePath) else {
return XCTFail("The CaskFile could not be parsed, check the log for more info")
}
XCTAssertEqual(
caskFile.version,
"5.7.2_1035"
)
XCTAssertEqual(
caskFile.sha256,
"1cb147bd1b1fbd52971d90dff577465b644aee7c878f15ede57f46e8f217067a"
)
XCTAssertEqual(
caskFile.name,
"PHP Monitor DEV"
)
XCTAssertEqual(
caskFile.url,
"https://github.com/nicoverbruggen/phpmon/releases/download/v5.7.2/phpmon-dev.zip"
)
}
func test_can_extract_fields_from_remote_cask_file() async throws {
let url = URL(string: "https://raw.githubusercontent.com/nicoverbruggen/homebrew-cask/master/Casks/phpmon.rb")!
guard let caskFile = await CaskFile.from(url: url) else {
return XCTFail("The remote CaskFile could not be parsed, check the log for more info")
}
XCTAssertTrue(caskFile.properties.keys.contains("version"))
XCTAssertTrue(caskFile.properties.keys.contains("homepage"))
XCTAssertTrue(caskFile.properties.keys.contains("url"))
}
}

View File

@@ -9,7 +9,7 @@
import Testing import Testing
struct BytePhpPreferenceTest { struct BytePhpPreferenceTest {
@Test func test_can_extract_memory_value() throws { @Test func can_extract_memory_value() throws {
let pref = BytePhpPreference(key: "memory_limit") let pref = BytePhpPreference(key: "memory_limit")
#expect(pref.internalValue == "512M") #expect(pref.internalValue == "512M")
@@ -17,7 +17,7 @@ struct BytePhpPreferenceTest {
#expect(pref.value == 512) #expect(pref.value == 512)
} }
@Test func test_can_parse_all_kinds_of_values() throws { @Test func can_parse_all_kinds_of_values() throws {
var (unit, value) = BytePhpPreference.readFrom(internalValue: "1G")! var (unit, value) = BytePhpPreference.readFrom(internalValue: "1G")!
#expect(unit == .gigabyte) #expect(unit == .gigabyte)
#expect(value == 1) #expect(value == 1)

View File

@@ -0,0 +1,55 @@
//
// CaskFileParserTest.swift
// Unit Tests
//
// Created by Nico Verbruggen on 04/02/2023.
// Copyright © 2023 Nico Verbruggen. All rights reserved.
//
import Testing
import Foundation
struct CaskFileParserTest {
// MARK: - Test Files
static var exampleFilePath: URL {
TestBundle.url(forResource: "phpmon-dev", withExtension: "rb")!
}
@Test func can_extract_fields_from_cask_file() async throws {
guard let caskFile = await CaskFile.from(url: CaskFileParserTest.exampleFilePath) else {
Issue.record("The CaskFile could not be parsed, check the log for more info")
return
}
#expect(
caskFile.version ==
"5.7.2_1035"
)
#expect(
caskFile.sha256 ==
"1cb147bd1b1fbd52971d90dff577465b644aee7c878f15ede57f46e8f217067a"
)
#expect(
caskFile.name ==
"PHP Monitor DEV"
)
#expect(
caskFile.url ==
"https://github.com/nicoverbruggen/phpmon/releases/download/v5.7.2/phpmon-dev.zip"
)
}
@Test func can_extract_fields_from_remote_cask_file() async throws {
let url = URL(string: "https://raw.githubusercontent.com/nicoverbruggen/homebrew-cask/master/Casks/phpmon.rb")!
guard let caskFile = await CaskFile.from(url: url) else {
Issue.record("The remote CaskFile could not be parsed, check the log for more info")
return
}
#expect(caskFile.properties.keys.contains("version"))
#expect(caskFile.properties.keys.contains("homepage"))
#expect(caskFile.properties.keys.contains("url"))
}
}

View File

@@ -6,11 +6,11 @@
// Copyright © 2023 Nico Verbruggen. All rights reserved. // Copyright © 2023 Nico Verbruggen. All rights reserved.
// //
import XCTest import Testing
import Foundation
final class ExtensionEnumeratorTest: XCTestCase { struct ExtensionEnumeratorTest {
init() async throws {
override func setUp() async throws {
ActiveFileSystem.useTestable([ ActiveFileSystem.useTestable([
"\(Paths.tapPath)/shivammathur/homebrew-extensions/Formula/xdebug@8.1.rb": .fake(.text, "<test>"), "\(Paths.tapPath)/shivammathur/homebrew-extensions/Formula/xdebug@8.1.rb": .fake(.text, "<test>"),
"\(Paths.tapPath)/shivammathur/homebrew-extensions/Formula/xdebug@8.2.rb": .fake(.text, "<test>"), "\(Paths.tapPath)/shivammathur/homebrew-extensions/Formula/xdebug@8.2.rb": .fake(.text, "<test>"),
@@ -19,22 +19,19 @@ final class ExtensionEnumeratorTest: XCTestCase {
]) ])
} }
func testCanReadFormulae() throws { @Test func can_read_formulae() throws {
let directory = "\(Paths.tapPath)/shivammathur/homebrew-extensions/Formula" let directory = "\(Paths.tapPath)/shivammathur/homebrew-extensions/Formula"
let files = try FileSystem.getShallowContentsOfDirectory(directory) let files = try FileSystem.getShallowContentsOfDirectory(directory)
XCTAssertEqual( #expect(Set(files) == Set(["xdebug@8.1.rb", "xdebug@8.2.rb", "xdebug@8.3.rb", "xdebug@8.4.rb"]))
Set(["xdebug@8.1.rb", "xdebug@8.2.rb", "xdebug@8.3.rb", "xdebug@8.4.rb"]),
Set(files)
)
} }
func testCanParseFormulaeBasedOnSyntax() throws { @Test func can_parse_formulae_based_on_syntax() throws {
let formulae = BrewTapFormulae.from(tap: "shivammathur/homebrew-extensions") let formulae = BrewTapFormulae.from(tap: "shivammathur/homebrew-extensions")
XCTAssertEqual(formulae["8.1"], [BrewPhpExtension(path: "/", name: "xdebug", phpVersion: "8.1")]) #expect(formulae["8.1"] == [BrewPhpExtension(path: "/", name: "xdebug", phpVersion: "8.1")])
XCTAssertEqual(formulae["8.2"], [BrewPhpExtension(path: "/", name: "xdebug", phpVersion: "8.2")]) #expect(formulae["8.2"] == [BrewPhpExtension(path: "/", name: "xdebug", phpVersion: "8.2")])
XCTAssertEqual(formulae["8.3"], [BrewPhpExtension(path: "/", name: "xdebug", phpVersion: "8.3")]) #expect(formulae["8.3"] == [BrewPhpExtension(path: "/", name: "xdebug", phpVersion: "8.3")])
XCTAssertEqual(formulae["8.4"], [BrewPhpExtension(path: "/", name: "xdebug", phpVersion: "8.4")]) #expect(formulae["8.4"] == [BrewPhpExtension(path: "/", name: "xdebug", phpVersion: "8.4")])
} }
} }

View File

@@ -14,16 +14,14 @@ struct HomebrewPackageTest {
// - MARK: SYNTHETIC TESTS // - MARK: SYNTHETIC TESTS
static var jsonBrewFile: URL { static var jsonBrewFile: URL {
return TestBundle TestBundle.url(forResource: "brew-formula", withExtension: "json")!
.url(forResource: "brew-formula", withExtension: "json")!
} }
static var jsonBrewServicesFile: URL { static var jsonBrewServicesFile: URL {
return TestBundle TestBundle.url(forResource: "brew-services", withExtension: "json")!
.url(forResource: "brew-services", withExtension: "json")!
} }
@Test func test_can_load_extension_json() throws { @Test func can_load_extension_json() throws {
let json = try! String(contentsOf: Self.jsonBrewFile, encoding: .utf8) let json = try! String(contentsOf: Self.jsonBrewFile, encoding: .utf8)
let package = try! JSONDecoder().decode( let package = try! JSONDecoder().decode(
[HomebrewPackage].self, from: json.data(using: .utf8)! [HomebrewPackage].self, from: json.data(using: .utf8)!
@@ -36,7 +34,7 @@ struct HomebrewPackageTest {
}) == true) }) == true)
} }
@Test func test_can_parse_services_json() throws { @Test func can_parse_services_json() throws {
let json = try! String(contentsOf: Self.jsonBrewServicesFile, encoding: .utf8) let json = try! String(contentsOf: Self.jsonBrewServicesFile, encoding: .utf8)
let services = try! JSONDecoder().decode( let services = try! JSONDecoder().decode(
[HomebrewService].self, from: json.data(using: .utf8)! [HomebrewService].self, from: json.data(using: .utf8)!
@@ -54,7 +52,7 @@ struct HomebrewPackageTest {
/// 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.
@Test(.disabled("Uses system command; enable at your own risk")) @Test(.disabled("Uses system command; enable at your own risk"))
func test_can_parse_services_json_from_cli_output() async throws { func can_parse_services_json_from_cli_output() async throws {
ActiveShell.useSystem() ActiveShell.useSystem()
let services = try! JSONDecoder().decode( let services = try! JSONDecoder().decode(
@@ -77,7 +75,7 @@ struct HomebrewPackageTest {
/// 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.
@Test(.disabled("Uses system command; enable at your own risk")) @Test(.disabled("Uses system command; enable at your own risk"))
func test_can_load_extension_json_from_cli_output() async throws { func can_load_extension_json_from_cli_output() async throws {
ActiveShell.useSystem() ActiveShell.useSystem()

View File

@@ -6,26 +6,34 @@
// Copyright © 2023 Nico Verbruggen. All rights reserved. // Copyright © 2023 Nico Verbruggen. All rights reserved.
// //
import XCTest import Testing
import Foundation
class HomebrewUpgradableTest: XCTestCase { struct HomebrewUpgradableTest {
static var outdatedFileUrl: URL { static var outdatedFileUrl: URL {
return Bundle(for: Self.self) return TestBundle.url(forResource: "brew-outdated", withExtension: "json")!
.url(forResource: "brew-outdated", withExtension: "json")!
} }
func test_upgradable_php_versions_can_be_parsed() async throws { @Test func upgradable_php_versions_can_be_determined() async throws {
// Do not execute production cli commands
ActiveShell.useTestable([ ActiveShell.useTestable([
"/opt/homebrew/bin/brew update >/dev/null && /opt/homebrew/bin/brew outdated --json --formulae" "/opt/homebrew/bin/brew update >/dev/null && /opt/homebrew/bin/brew outdated --json --formulae"
: .instant(try! String(contentsOf: Self.outdatedFileUrl)), : .instant(try! String(contentsOf: Self.outdatedFileUrl)),
"/opt/homebrew/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'" "/opt/homebrew/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'"
: .instant("/opt/homebrew/etc/php/8.2/conf.d/php-memory-limits.ini"), : .instant("/opt/homebrew/etc/php/8.2/conf.d/php-memory-limits.ini"),
"/opt/homebrew/opt/php@8.1.16/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'" "/opt/homebrew/opt/php@8.1.16/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'"
: .instant("/opt/homebrew/etc/php/8.1/conf.d/php-memory-limits.ini"), : .instant("/opt/homebrew/etc/php/8.1/conf.d/php-memory-limits.ini"),
"/opt/homebrew/opt/php@8.2.3/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'" "/opt/homebrew/opt/php@8.2.3/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'"
: .instant("/opt/homebrew/etc/php/8.2/conf.d/php-memory-limits.ini"), : .instant("/opt/homebrew/etc/php/8.2/conf.d/php-memory-limits.ini"),
"/opt/homebrew/opt/php@7.4.11/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'" "/opt/homebrew/opt/php@7.4.11/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'"
: .instant("/opt/homebrew/etc/php/7.4/conf.d/php-memory-limits.ini") : .instant("/opt/homebrew/etc/php/7.4/conf.d/php-memory-limits.ini")
])
// Do not read our production files
ActiveFileSystem.useTestable([
"/opt/homebrew/etc/php/8.2/conf.d/php-memory-limits.ini": .fake(.text),
"/opt/homebrew/etc/php/8.1/conf.d/php-memory-limits.ini": .fake(.text),
"/opt/homebrew/etc/php/7.4/conf.d/php-memory-limits.ini": .fake(.text)
]) ])
// This config file assumes our PHP alias (`php`) is v8.2 // This config file assumes our PHP alias (`php`) is v8.2
@@ -39,11 +47,11 @@ class HomebrewUpgradableTest: XCTestCase {
let data = await BrewPhpFormulaeHandler().loadPhpVersions(loadOutdated: true) let data = await BrewPhpFormulaeHandler().loadPhpVersions(loadOutdated: true)
XCTAssertTrue(data.contains(where: { formula in #expect(true == data.contains(where: { formula in
formula.installedVersion == "8.1.16" && formula.upgradeVersion == "8.1.17" formula.installedVersion == "8.1.16" && formula.upgradeVersion == "8.1.17"
})) }))
XCTAssertTrue(data.contains(where: { formula in #expect(true == data.contains(where: { formula in
formula.installedVersion == "8.2.3" && formula.upgradeVersion == "8.2.4" formula.installedVersion == "8.2.3" && formula.upgradeVersion == "8.2.4"
})) }))
} }

View File

@@ -35,17 +35,17 @@ struct NginxConfigurationTest {
// MARK: - Tests // MARK: - Tests
@Test func test_can_determine_site_name_and_tld() throws { @Test func can_determine_site_name_and_tld() throws {
#expect("nginx-site" == NginxConfigurationFile.from(filePath: Self.regularUrl.path)?.domain) #expect("nginx-site" == NginxConfigurationFile.from(filePath: Self.regularUrl.path)?.domain)
#expect("test" == NginxConfigurationFile.from(filePath: Self.regularUrl.path)?.tld) #expect("test" == NginxConfigurationFile.from(filePath: Self.regularUrl.path)?.tld)
} }
@Test func test_can_determine_isolation() throws { @Test func can_determine_isolation() throws {
#expect(nil == NginxConfigurationFile.from(filePath: Self.regularUrl.path)?.isolatedVersion) #expect(nil == NginxConfigurationFile.from(filePath: Self.regularUrl.path)?.isolatedVersion)
#expect("8.1" == NginxConfigurationFile.from(filePath: Self.isolatedUrl.path)?.isolatedVersion) #expect("8.1" == NginxConfigurationFile.from(filePath: Self.isolatedUrl.path)?.isolatedVersion)
} }
@Test func test_can_determine_proxy() throws { @Test func can_determine_proxy() throws {
let proxied = NginxConfigurationFile.from(filePath: Self.proxyUrl.path)! let proxied = NginxConfigurationFile.from(filePath: Self.proxyUrl.path)!
#expect(proxied.contents.contains("# valet stub: proxy.valet.conf")) #expect(proxied.contents.contains("# valet stub: proxy.valet.conf"))
#expect("http://127.0.0.1:90" == proxied.proxy) #expect("http://127.0.0.1:90" == proxied.proxy)
@@ -55,13 +55,13 @@ struct NginxConfigurationTest {
#expect(nil == normal.proxy) #expect(nil == normal.proxy)
} }
@Test func test_can_determine_secured_proxy() throws { @Test func can_determine_secured_proxy() throws {
let proxied = NginxConfigurationFile.from(filePath: Self.secureProxyUrl.path)! let proxied = NginxConfigurationFile.from(filePath: Self.secureProxyUrl.path)!
#expect(proxied.contents.contains("# valet stub: secure.proxy.valet.conf")) #expect(proxied.contents.contains("# valet stub: secure.proxy.valet.conf"))
#expect("http://127.0.0.1:90" == proxied.proxy) #expect("http://127.0.0.1:90" == proxied.proxy)
} }
@Test func test_can_determine_proxy_with_custom_tld() throws { @Test func can_determine_proxy_with_custom_tld() throws {
let proxied = NginxConfigurationFile.from(filePath: Self.customTldProxyUrl.path)! let proxied = NginxConfigurationFile.from(filePath: Self.customTldProxyUrl.path)!
#expect(proxied.contents.contains("# valet stub: secure.proxy.valet.conf")) #expect(proxied.contents.contains("# valet stub: secure.proxy.valet.conf"))
#expect("http://localhost:8080" == proxied.proxy) #expect("http://localhost:8080" == proxied.proxy)

View File

@@ -15,14 +15,14 @@ class PhpConfigurationFileTest {
return TestBundle.url(forResource: "php", withExtension: "ini")! return TestBundle.url(forResource: "php", withExtension: "ini")!
} }
@Test func test_can_load_extension() throws { @Test func can_load_extension() throws {
let iniFile = PhpConfigurationFile.from(filePath: Self.phpIniFileUrl.path) let iniFile = PhpConfigurationFile.from(filePath: Self.phpIniFileUrl.path)
#expect(iniFile != nil) #expect(iniFile != nil)
#expect(!iniFile!.extensions.isEmpty) #expect(!iniFile!.extensions.isEmpty)
} }
@Test func test_can_check_key_existence() throws { @Test func can_check_key_existence() throws {
let iniFile = PhpConfigurationFile.from(filePath: Self.phpIniFileUrl.path)! let iniFile = PhpConfigurationFile.from(filePath: Self.phpIniFileUrl.path)!
#expect(iniFile.has(key: "error_reporting")) #expect(iniFile.has(key: "error_reporting"))
@@ -30,7 +30,7 @@ class PhpConfigurationFileTest {
#expect(false == iniFile.has(key: "my_unknown_key")) #expect(false == iniFile.has(key: "my_unknown_key"))
} }
@Test func test_can_check_key_value() throws { @Test func can_check_key_value() throws {
let iniFile = PhpConfigurationFile.from(filePath: Self.phpIniFileUrl.path)! let iniFile = PhpConfigurationFile.from(filePath: Self.phpIniFileUrl.path)!
#expect(iniFile.get(for: "error_reporting") != nil) #expect(iniFile.get(for: "error_reporting") != nil)
@@ -40,7 +40,7 @@ class PhpConfigurationFileTest {
#expect(iniFile.get(for: "display_errors") == "On") #expect(iniFile.get(for: "display_errors") == "On")
} }
@Test func test_can_customize_configuration_value() throws { @Test func can_customize_configuration_value() throws {
let destination = Utility let destination = Utility
.copyToTemporaryFile(resourceName: "php", fileExtension: "ini")! .copyToTemporaryFile(resourceName: "php", fileExtension: "ini")!

View File

@@ -11,16 +11,16 @@ import Foundation
struct PhpExtensionTest { struct PhpExtensionTest {
static var phpIniFileUrl: URL { static var phpIniFileUrl: URL {
return TestBundle.url(forResource: "php", withExtension: "ini")! TestBundle.url(forResource: "php", withExtension: "ini")!
} }
@Test func test_can_load_extension() throws { @Test func can_load_extension() throws {
let extensions = PhpExtension.from(filePath: Self.phpIniFileUrl.path) let extensions = PhpExtension.from(filePath: Self.phpIniFileUrl.path)
#expect(!extensions.isEmpty) #expect(!extensions.isEmpty)
} }
@Test func test_extension_name_is_correct() throws { @Test func extension_name_is_correct() throws {
let extensions = PhpExtension.from(filePath: Self.phpIniFileUrl.path) let extensions = PhpExtension.from(filePath: Self.phpIniFileUrl.path)
let extensionNames = extensions.map { (ext) -> String in let extensionNames = extensions.map { (ext) -> String in
@@ -39,7 +39,7 @@ struct PhpExtensionTest {
#expect(extensionNames.contains("nice") == false) #expect(extensionNames.contains("nice") == false)
} }
@Test func test_extension_status_is_correct() throws { @Test func extension_status_is_correct() throws {
let extensions = PhpExtension.from(filePath: Self.phpIniFileUrl.path) let extensions = PhpExtension.from(filePath: Self.phpIniFileUrl.path)
// xdebug should be enabled // xdebug should be enabled
@@ -49,7 +49,7 @@ struct PhpExtensionTest {
#expect(extensions[1].enabled == false) #expect(extensions[1].enabled == false)
} }
@Test func test_toggle_works_as_expected() async throws { @Test func toggle_works_as_expected() 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)
#expect(extensions.count == 6) #expect(extensions.count == 6)

View File

@@ -11,10 +11,7 @@ import Foundation
struct ValetConfigurationTest { struct ValetConfigurationTest {
static var jsonConfigFileUrl: URL { static var jsonConfigFileUrl: URL {
return TestBundle.url( TestBundle.url(forResource: "valet-config", withExtension: "json")!
forResource: "valet-config",
withExtension: "json"
)!
} }
@Test func can_load_config_file() throws { @Test func can_load_config_file() throws {

View File

@@ -12,15 +12,15 @@ import Foundation
struct ValetRcTest { struct ValetRcTest {
// MARK: - Test Files // MARK: - Test Files
static var validPath: URL { static var validPath: URL {
return TestBundle.url(forResource: "valetrc", withExtension: "valid")! TestBundle.url(forResource: "valetrc", withExtension: "valid")!
} }
static var brokenPath: URL { static var brokenPath: URL {
return TestBundle.url(forResource: "valetrc", withExtension: "broken")! TestBundle.url(forResource: "valetrc", withExtension: "broken")!
} }
// MARK: - Tests // MARK: - Tests
@Test func test_can_extract_fields_from_valet_rc_file() throws { @Test func can_extract_fields_from_valet_rc_file() throws {
let fakeFile = RCFile.fromPath("/Users/fake/file.rc") let fakeFile = RCFile.fromPath("/Users/fake/file.rc")
#expect(nil == fakeFile) #expect(nil == fakeFile)