-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev/5.3'
- Loading branch information
Showing
141 changed files
with
4,351 additions
and
2,083 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
disabled_rules: | ||
- todo | ||
- identifier_name | ||
- force_try | ||
- force_cast | ||
|
||
opt_in_rules: | ||
- empty_count | ||
|
||
included: | ||
- phpmon | ||
- phpmon-tests | ||
|
||
excluded: | ||
- phpmon/Vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,50 +3,50 @@ | |
// phpmon-tests | ||
// | ||
// Created by Nico Verbruggen on 14/02/2021. | ||
// Copyright © 2021 Nico Verbruggen. All rights reserved. | ||
// Copyright © 2022 Nico Verbruggen. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
|
||
class BrewJsonParserTest: XCTestCase { | ||
class HomebrewPackageTest: XCTestCase { | ||
|
||
// - MARK: SYNTHETIC TESTS | ||
|
||
static var jsonBrewFile: URL { | ||
return Bundle(for: Self.self) | ||
.url(forResource: "brew", withExtension: "json")! | ||
.url(forResource: "brew-formula", withExtension: "json")! | ||
} | ||
|
||
func testCanLoadExtensionJson() throws { | ||
let json = try! String(contentsOf: Self.jsonBrewFile, encoding: .utf8) | ||
let package = try! JSONDecoder().decode( | ||
[HomebrewPackage].self, from: json.data(using: .utf8)! | ||
).first! | ||
|
||
XCTAssertEqual(package.name, "php") | ||
XCTAssertEqual(package.full_name, "php") | ||
XCTAssertEqual(package.aliases.first!, "[email protected]") | ||
XCTAssertEqual(package.installed.contains(where: { installed in | ||
installed.version.starts(with: "8.0") | ||
}), true) | ||
} | ||
|
||
static var jsonBrewServicesFile: URL { | ||
return Bundle(for: Self.self) | ||
.url(forResource: "brew-services", withExtension: "json")! | ||
} | ||
|
||
func testCanParseServicesJson() throws { | ||
let json = try! String(contentsOf: Self.jsonBrewServicesFile, encoding: .utf8) | ||
let services = try! JSONDecoder().decode( | ||
[HomebrewService].self, from: json.data(using: .utf8)! | ||
) | ||
|
||
XCTAssertGreaterThan(services.count, 0) | ||
XCTAssertEqual(services.first?.name, "dnsmasq") | ||
XCTAssertEqual(services.first?.service_name, "homebrew.mxcl.dnsmasq") | ||
} | ||
|
||
// - MARK: LIVE TESTS | ||
|
||
/// This test requires that you have a valid Homebrew installation set up, | ||
|
@@ -63,13 +63,13 @@ class BrewJsonParserTest: XCTestCase { | |
).filter({ service in | ||
return ["php", "nginx", "dnsmasq"].contains(service.name) | ||
}) | ||
XCTAssertTrue(services.contains(where: {$0.name == "php"} )) | ||
XCTAssertTrue(services.contains(where: {$0.name == "nginx"} )) | ||
XCTAssertTrue(services.contains(where: {$0.name == "dnsmasq"} )) | ||
|
||
XCTAssertTrue(services.contains(where: {$0.name == "php"})) | ||
XCTAssertTrue(services.contains(where: {$0.name == "nginx"})) | ||
XCTAssertTrue(services.contains(where: {$0.name == "dnsmasq"})) | ||
XCTAssertEqual(services.count, 3) | ||
} | ||
|
||
/// 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 | ||
|
@@ -79,7 +79,7 @@ class BrewJsonParserTest: XCTestCase { | |
[HomebrewPackage].self, | ||
from: Shell.pipe("\(Paths.brew) info php --json", requiresPath: true).data(using: .utf8)! | ||
).first! | ||
|
||
XCTAssertTrue(package.name == "php") | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// NginxConfigurationTest.swift | ||
// phpmon-tests | ||
// | ||
// Created by Nico Verbruggen on 29/11/2021. | ||
// Copyright © 2022 Nico Verbruggen. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
|
||
class NginxConfigurationTest: XCTestCase { | ||
|
||
// MARK: - Test Files | ||
|
||
static var regularUrl: URL { | ||
return Bundle(for: Self.self).url(forResource: "nginx-site", withExtension: "test")! | ||
} | ||
|
||
static var isolatedUrl: URL { | ||
return Bundle(for: Self.self).url(forResource: "nginx-site-isolated", withExtension: "test")! | ||
} | ||
|
||
static var proxyUrl: URL { | ||
return Bundle(for: Self.self).url(forResource: "nginx-proxy", withExtension: "test")! | ||
} | ||
|
||
static var secureProxyUrl: URL { | ||
return Bundle(for: Self.self).url(forResource: "nginx-secure-proxy", withExtension: "test")! | ||
} | ||
|
||
static var customTldProxyUrl: URL { | ||
return Bundle(for: Self.self).url(forResource: "nginx-secure-proxy-custom-tld", withExtension: "test")! | ||
} | ||
|
||
// MARK: - Tests | ||
|
||
func testCanDetermineSiteNameAndTld() throws { | ||
XCTAssertEqual( | ||
"nginx-site", | ||
NginxConfiguration.from(filePath: NginxConfigurationTest.regularUrl.path)?.domain | ||
) | ||
XCTAssertEqual( | ||
"test", | ||
NginxConfiguration.from(filePath: NginxConfigurationTest.regularUrl.path)?.tld | ||
) | ||
} | ||
|
||
func testCanDetermineIsolation() throws { | ||
XCTAssertNil( | ||
NginxConfiguration.from(filePath: NginxConfigurationTest.regularUrl.path)?.isolatedVersion | ||
) | ||
|
||
XCTAssertEqual( | ||
"8.1", | ||
NginxConfiguration.from(filePath: NginxConfigurationTest.isolatedUrl.path)?.isolatedVersion | ||
) | ||
} | ||
|
||
func testCanDetermineProxy() throws { | ||
let proxied = NginxConfiguration.from(filePath: NginxConfigurationTest.proxyUrl.path)! | ||
XCTAssertTrue(proxied.contents.contains("# valet stub: proxy.valet.conf")) | ||
XCTAssertEqual("http://127.0.0.1:90", proxied.proxy) | ||
|
||
let normal = NginxConfiguration.from(filePath: NginxConfigurationTest.regularUrl.path)! | ||
XCTAssertFalse(normal.contents.contains("# valet stub: proxy.valet.conf")) | ||
XCTAssertEqual(nil, normal.proxy) | ||
} | ||
|
||
func testCanDetermineSecuredProxy() throws { | ||
let proxied = NginxConfiguration.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 { | ||
let proxied = NginxConfiguration.from(filePath: NginxConfigurationTest.customTldProxyUrl.path)! | ||
XCTAssertTrue(proxied.contents.contains("# valet stub: secure.proxy.valet.conf")) | ||
XCTAssertEqual("http://localhost:8080", proxied.proxy) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.