1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 20:10:08 +02:00

👌 Snake case for tests

This commit is contained in:
2022-10-18 14:11:55 +02:00
parent 83657fee6f
commit ea5dd3bc46
15 changed files with 50 additions and 47 deletions

View File

@ -17,7 +17,7 @@ class HomebrewPackageTest: XCTestCase {
.url(forResource: "brew-formula", withExtension: "json")!
}
func testCanLoadExtensionJson() throws {
func test_can_load_extension_json() throws {
let json = try! String(contentsOf: Self.jsonBrewFile, encoding: .utf8)
let package = try! JSONDecoder().decode(
[HomebrewPackage].self, from: json.data(using: .utf8)!
@ -36,7 +36,7 @@ class HomebrewPackageTest: XCTestCase {
.url(forResource: "brew-services", withExtension: "json")!
}
func testCanParseServicesJson() throws {
func test_can_parse_services_json() throws {
let json = try! String(contentsOf: Self.jsonBrewServicesFile, encoding: .utf8)
let services = try! JSONDecoder().decode(
[HomebrewService].self, from: json.data(using: .utf8)!
@ -49,11 +49,12 @@ class HomebrewPackageTest: XCTestCase {
// - MARK: LIVE TESTS
/// TODO: Use fake data or make this an integration test
/// This test requires that you have a valid Homebrew installation set up,
/// and requires the Valet services to be installed: php, nginx and dnsmasq.
/// If this test fails, there is an issue with your Homebrew installation
/// or the JSON API of the Homebrew output may have changed.
func testCanParseServicesJsonFromCliOutput() async throws {
func test_can_parse_services_json_from_cli_output() async throws {
ActiveShell.useSystem()
let services = try! JSONDecoder().decode(
@ -71,11 +72,12 @@ class HomebrewPackageTest: XCTestCase {
XCTAssertEqual(services.count, 3)
}
/// TODO: Use fake data or make this an integration test
/// This test requires that you have a valid Homebrew installation set up,
/// and requires the `php` formula to be installed.
/// If this test fails, there is an issue with your Homebrew installation
/// or the JSON API of the Homebrew output may have changed.
func testCanLoadExtensionJsonFromCliOutput() async throws {
func test_can_load_extension_json_from_cli_output() async throws {
ActiveShell.useSystem()
let package = try! JSONDecoder().decode(

View File

@ -34,7 +34,7 @@ class NginxConfigurationTest: XCTestCase {
// MARK: - Tests
func testCanDetermineSiteNameAndTld() throws {
func test_can_determine_site_name_and_tld() throws {
XCTAssertEqual(
"nginx-site",
NginxConfigurationFile.from(filePath: NginxConfigurationTest.regularUrl.path)?.domain
@ -45,7 +45,7 @@ class NginxConfigurationTest: XCTestCase {
)
}
func testCanDetermineIsolation() throws {
func test_can_determine_isolation() throws {
XCTAssertNil(
NginxConfigurationFile.from(filePath: NginxConfigurationTest.regularUrl.path)?.isolatedVersion
)
@ -56,7 +56,7 @@ class NginxConfigurationTest: XCTestCase {
)
}
func testCanDetermineProxy() throws {
func test_can_determine_proxy() throws {
let proxied = NginxConfigurationFile.from(filePath: NginxConfigurationTest.proxyUrl.path)!
XCTAssertTrue(proxied.contents.contains("# valet stub: proxy.valet.conf"))
XCTAssertEqual("http://127.0.0.1:90", proxied.proxy)
@ -66,13 +66,13 @@ class NginxConfigurationTest: XCTestCase {
XCTAssertEqual(nil, normal.proxy)
}
func testCanDetermineSecuredProxy() throws {
func test_can_determine_secured_proxy() throws {
let proxied = NginxConfigurationFile.from(filePath: NginxConfigurationTest.secureProxyUrl.path)!
XCTAssertTrue(proxied.contents.contains("# valet stub: secure.proxy.valet.conf"))
XCTAssertEqual("http://127.0.0.1:90", proxied.proxy)
}
func testCanDetermineProxyWithCustomTld() throws {
func test_can_determine_proxy_with_custom_tld() throws {
let proxied = NginxConfigurationFile.from(filePath: NginxConfigurationTest.customTldProxyUrl.path)!
XCTAssertTrue(proxied.contents.contains("# valet stub: secure.proxy.valet.conf"))
XCTAssertEqual("http://localhost:8080", proxied.proxy)

View File

@ -14,7 +14,7 @@ class PhpConfigurationTest: XCTestCase {
return Bundle(for: Self.self).url(forResource: "php", withExtension: "ini")!
}
func testCanLoadExtension() throws {
func test_can_load_extension() throws {
let iniFile = PhpConfigurationFile.from(filePath: Self.phpIniFileUrl.path)!
XCTAssertNotNil(iniFile)
@ -22,7 +22,7 @@ class PhpConfigurationTest: XCTestCase {
XCTAssertGreaterThan(iniFile.extensions.count, 0)
}
func testCanCheckKeyExistence() throws {
func test_can_check_key_existence() throws {
let iniFile = PhpConfigurationFile.from(filePath: Self.phpIniFileUrl.path)!
XCTAssertTrue(iniFile.has(key: "error_reporting"))
@ -30,7 +30,7 @@ class PhpConfigurationTest: XCTestCase {
XCTAssertFalse(iniFile.has(key: "my_unknown_key"))
}
func testCanCheckKeyValue() throws {
func test_can_check_key_value() throws {
let iniFile = PhpConfigurationFile.from(filePath: Self.phpIniFileUrl.path)!
XCTAssertNotNil(iniFile.get(for: "error_reporting"))
@ -40,7 +40,7 @@ class PhpConfigurationTest: XCTestCase {
XCTAssert(iniFile.get(for: "display_errors") == "On")
}
func testCanCustomizeConfigurationValue() throws {
func test_can_customize_configuration_value() throws {
let destination = Utility
.copyToTemporaryFile(resourceName: "php", fileExtension: "ini")!

View File

@ -14,13 +14,13 @@ class PhpExtensionTest: XCTestCase {
return Bundle(for: Self.self).url(forResource: "php", withExtension: "ini")!
}
func testCanLoadExtension() throws {
func test_can_load_extension() throws {
let extensions = PhpExtension.from(filePath: Self.phpIniFileUrl.path)
XCTAssertGreaterThan(extensions.count, 0)
}
func testExtensionNameIsCorrect() throws {
func test_extension_name_is_correct() throws {
let extensions = PhpExtension.from(filePath: Self.phpIniFileUrl.path)
let extensionNames = extensions.map { (ext) -> String in
@ -39,7 +39,7 @@ class PhpExtensionTest: XCTestCase {
XCTAssertFalse(extensionNames.contains("nice"))
}
func testExtensionStatusIsCorrect() throws {
func test_extension_status_is_correct() throws {
let extensions = PhpExtension.from(filePath: Self.phpIniFileUrl.path)
// xdebug should be enabled
@ -49,7 +49,7 @@ class PhpExtensionTest: XCTestCase {
XCTAssertEqual(extensions[1].enabled, false)
}
func testToggleWorksAsExpected() async throws {
func test_toggle_works_as_expected() async throws {
let destination = Utility.copyToTemporaryFile(resourceName: "php", fileExtension: "ini")!
let extensions = PhpExtension.from(filePath: destination.path)
XCTAssertEqual(extensions.count, 6)

View File

@ -17,7 +17,7 @@ class ValetConfigurationTest: XCTestCase {
)!
}
func testCanLoadConfigFile() throws {
func test_can_load_config_file() throws {
let json = try? String(
contentsOf: Self.jsonConfigFileUrl,
encoding: .utf8