mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
🚛 Moved tests around, added Feature, UI tests
This commit is contained in:
67
tests/PHP Monitor.xctestplan
Normal file
67
tests/PHP Monitor.xctestplan
Normal file
@ -0,0 +1,67 @@
|
||||
{
|
||||
"configurations" : [
|
||||
{
|
||||
"id" : "98F42C11-E6D2-4AD9-A5CA-40EFE44F384A",
|
||||
"name" : "Configuration 1",
|
||||
"options" : {
|
||||
|
||||
}
|
||||
}
|
||||
],
|
||||
"defaultOptions" : {
|
||||
"codeCoverage" : false,
|
||||
"commandLineArgumentEntries" : [
|
||||
{
|
||||
"argument" : "--v",
|
||||
"enabled" : false
|
||||
}
|
||||
],
|
||||
"environmentVariableEntries" : [
|
||||
{
|
||||
"enabled" : false,
|
||||
"key" : "EXTREME_DOCTOR_MODE",
|
||||
"value" : ""
|
||||
},
|
||||
{
|
||||
"enabled" : false,
|
||||
"key" : "SLOW_SHELL_MODE",
|
||||
"value" : ""
|
||||
},
|
||||
{
|
||||
"enabled" : false,
|
||||
"key" : "PAINT_PHPMON_SWIFTUI_VIEWS",
|
||||
"value" : ""
|
||||
}
|
||||
],
|
||||
"targetForVariableExpansion" : {
|
||||
"containerPath" : "container:PHP Monitor.xcodeproj",
|
||||
"identifier" : "C41C1B3222B0097F00E7CF16",
|
||||
"name" : "PHP Monitor"
|
||||
}
|
||||
},
|
||||
"testTargets" : [
|
||||
{
|
||||
"parallelizable" : true,
|
||||
"target" : {
|
||||
"containerPath" : "container:PHP Monitor.xcodeproj",
|
||||
"identifier" : "C4F7807825D7F84B000DBC97",
|
||||
"name" : "Unit Tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"target" : {
|
||||
"containerPath" : "container:PHP Monitor.xcodeproj",
|
||||
"identifier" : "C471E7AC28F9B4940021E251",
|
||||
"name" : "Feature Tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"target" : {
|
||||
"containerPath" : "container:PHP Monitor.xcodeproj",
|
||||
"identifier" : "C471E7BB28F9B90F0021E251",
|
||||
"name" : "UI Tests"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 1
|
||||
}
|
11
tests/feature/EmptyTest.swift
Normal file
11
tests/feature/EmptyTest.swift
Normal file
@ -0,0 +1,11 @@
|
||||
//
|
||||
// Feature_Tests.swift
|
||||
// Feature Tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 14/10/2022.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
final class Feature_Tests: XCTestCase {}
|
35
tests/ui/UI_Tests.swift
Normal file
35
tests/ui/UI_Tests.swift
Normal file
@ -0,0 +1,35 @@
|
||||
//
|
||||
// UI_Tests.swift
|
||||
// UI Tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 14/10/2022.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
final class UI_Tests: XCTestCase {
|
||||
|
||||
override func setUpWithError() throws {
|
||||
continueAfterFailure = false
|
||||
TestableConfigurations.broken.apply()
|
||||
}
|
||||
|
||||
override func tearDownWithError() throws {
|
||||
}
|
||||
|
||||
func testExample() throws {
|
||||
// UI tests must launch the application that they test.
|
||||
let app = XCUIApplication()
|
||||
app.launchArguments = ["--configuration:broken"]
|
||||
app.launch()
|
||||
}
|
||||
|
||||
/*
|
||||
func testLaunchPerformance() throws {
|
||||
measure(metrics: [XCTApplicationLaunchMetric()]) {
|
||||
XCUIApplication().launch()
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
26
tests/unit/Commands/CommandTest.swift
Normal file
26
tests/unit/Commands/CommandTest.swift
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// CommandTest.swift
|
||||
// phpmon-tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 13/02/2021.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class CommandTest: XCTestCase {
|
||||
|
||||
func testDeterminePhpVersion() {
|
||||
let version = Command.execute(
|
||||
path: Paths.php,
|
||||
arguments: ["-v"],
|
||||
trimNewlines: false
|
||||
)
|
||||
|
||||
XCTAssert(version.contains("(cli)"))
|
||||
XCTAssert(version.contains("NTS"))
|
||||
XCTAssert(version.contains("built"))
|
||||
XCTAssert(version.contains("Zend"))
|
||||
}
|
||||
|
||||
}
|
88
tests/unit/Parsers/HomebrewPackageTest.swift
Normal file
88
tests/unit/Parsers/HomebrewPackageTest.swift
Normal file
@ -0,0 +1,88 @@
|
||||
//
|
||||
// BrewJsonParserTest.swift
|
||||
// phpmon-tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 14/02/2021.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class HomebrewPackageTest: XCTestCase {
|
||||
|
||||
// - MARK: SYNTHETIC TESTS
|
||||
|
||||
static var jsonBrewFile: URL {
|
||||
return Bundle(for: Self.self)
|
||||
.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!, "php@8.1")
|
||||
XCTAssertEqual(package.installed.contains(where: { installed in
|
||||
installed.version.starts(with: "8.1")
|
||||
}), 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,
|
||||
/// 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 {
|
||||
ActiveShell.useSystem()
|
||||
|
||||
let services = try! JSONDecoder().decode(
|
||||
[HomebrewService].self,
|
||||
from: await Shell.pipe(
|
||||
"sudo \(Paths.brew) services info --all --json"
|
||||
).out.data(using: .utf8)!
|
||||
).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"}))
|
||||
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
|
||||
/// or the JSON API of the Homebrew output may have changed.
|
||||
func testCanLoadExtensionJsonFromCliOutput() async throws {
|
||||
ActiveShell.useSystem()
|
||||
|
||||
let package = try! JSONDecoder().decode(
|
||||
[HomebrewPackage].self,
|
||||
from: await Shell.pipe("\(Paths.brew) info php --json").out.data(using: .utf8)!
|
||||
).first!
|
||||
|
||||
XCTAssertTrue(package.name == "php")
|
||||
}
|
||||
}
|
81
tests/unit/Parsers/NginxConfigurationTest.swift
Normal file
81
tests/unit/Parsers/NginxConfigurationTest.swift
Normal file
@ -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",
|
||||
NginxConfigurationFile.from(filePath: NginxConfigurationTest.regularUrl.path)?.domain
|
||||
)
|
||||
XCTAssertEqual(
|
||||
"test",
|
||||
NginxConfigurationFile.from(filePath: NginxConfigurationTest.regularUrl.path)?.tld
|
||||
)
|
||||
}
|
||||
|
||||
func testCanDetermineIsolation() throws {
|
||||
XCTAssertNil(
|
||||
NginxConfigurationFile.from(filePath: NginxConfigurationTest.regularUrl.path)?.isolatedVersion
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
"8.1",
|
||||
NginxConfigurationFile.from(filePath: NginxConfigurationTest.isolatedUrl.path)?.isolatedVersion
|
||||
)
|
||||
}
|
||||
|
||||
func testCanDetermineProxy() 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)
|
||||
|
||||
let normal = NginxConfigurationFile.from(filePath: NginxConfigurationTest.regularUrl.path)!
|
||||
XCTAssertFalse(normal.contents.contains("# valet stub: proxy.valet.conf"))
|
||||
XCTAssertEqual(nil, normal.proxy)
|
||||
}
|
||||
|
||||
func testCanDetermineSecuredProxy() 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 {
|
||||
let proxied = NginxConfigurationFile.from(filePath: NginxConfigurationTest.customTldProxyUrl.path)!
|
||||
XCTAssertTrue(proxied.contents.contains("# valet stub: secure.proxy.valet.conf"))
|
||||
XCTAssertEqual("http://localhost:8080", proxied.proxy)
|
||||
}
|
||||
|
||||
}
|
84
tests/unit/Parsers/PhpConfigurationTest.swift
Normal file
84
tests/unit/Parsers/PhpConfigurationTest.swift
Normal file
@ -0,0 +1,84 @@
|
||||
//
|
||||
// PhpConfigurationTest.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 04/05/2022.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class PhpConfigurationTest: XCTestCase {
|
||||
|
||||
static var phpIniFileUrl: URL {
|
||||
return Bundle(for: Self.self).url(forResource: "php", withExtension: "ini")!
|
||||
}
|
||||
|
||||
func testCanLoadExtension() throws {
|
||||
let iniFile = PhpConfigurationFile.from(filePath: Self.phpIniFileUrl.path)!
|
||||
|
||||
XCTAssertNotNil(iniFile)
|
||||
|
||||
XCTAssertGreaterThan(iniFile.extensions.count, 0)
|
||||
}
|
||||
|
||||
func testCanCheckKeyExistence() throws {
|
||||
let iniFile = PhpConfigurationFile.from(filePath: Self.phpIniFileUrl.path)!
|
||||
|
||||
XCTAssertTrue(iniFile.has(key: "error_reporting"))
|
||||
XCTAssertTrue(iniFile.has(key: "display_errors"))
|
||||
XCTAssertFalse(iniFile.has(key: "my_unknown_key"))
|
||||
}
|
||||
|
||||
func testCanCheckKeyValue() throws {
|
||||
let iniFile = PhpConfigurationFile.from(filePath: Self.phpIniFileUrl.path)!
|
||||
|
||||
XCTAssertNotNil(iniFile.get(for: "error_reporting"))
|
||||
XCTAssert(iniFile.get(for: "error_reporting") == "E_ALL")
|
||||
|
||||
XCTAssertNotNil(iniFile.get(for: "display_errors"))
|
||||
XCTAssert(iniFile.get(for: "display_errors") == "On")
|
||||
}
|
||||
|
||||
func testCanCustomizeConfigurationValue() throws {
|
||||
let destination = Utility
|
||||
.copyToTemporaryFile(resourceName: "php", fileExtension: "ini")!
|
||||
|
||||
let configurationFile = PhpConfigurationFile
|
||||
.from(filePath: destination.path)!
|
||||
|
||||
// 0. Verify the original value
|
||||
XCTAssertEqual(configurationFile.get(for: "error_reporting"), "E_ALL")
|
||||
|
||||
// 1. Change the value
|
||||
try! configurationFile.replace(
|
||||
key: "error_reporting",
|
||||
value: "E_ALL & ~E_DEPRECATED & ~E_STRICT"
|
||||
)
|
||||
XCTAssertEqual(
|
||||
configurationFile.get(for: "error_reporting"),
|
||||
"E_ALL & ~E_DEPRECATED & ~E_STRICT"
|
||||
)
|
||||
|
||||
// 2. Ensure that same key and value doesn't break subsequent saves
|
||||
try! configurationFile.replace(
|
||||
key: "error_reporting",
|
||||
value: "error_reporting"
|
||||
)
|
||||
XCTAssertEqual(
|
||||
configurationFile.get(for: "error_reporting"),
|
||||
"error_reporting"
|
||||
)
|
||||
|
||||
// 3. Verify subsequent saves weren't broken
|
||||
try! configurationFile.replace(
|
||||
key: "error_reporting",
|
||||
value: "E_ALL"
|
||||
)
|
||||
XCTAssertEqual(
|
||||
configurationFile.get(for: "error_reporting"),
|
||||
"E_ALL"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
72
tests/unit/Parsers/PhpExtensionTest.swift
Normal file
72
tests/unit/Parsers/PhpExtensionTest.swift
Normal file
@ -0,0 +1,72 @@
|
||||
//
|
||||
// ExtensionParserTest.swift
|
||||
// phpmon-tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 13/02/2021.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class PhpExtensionTest: XCTestCase {
|
||||
|
||||
static var phpIniFileUrl: URL {
|
||||
return Bundle(for: Self.self).url(forResource: "php", withExtension: "ini")!
|
||||
}
|
||||
|
||||
func testCanLoadExtension() throws {
|
||||
let extensions = PhpExtension.from(filePath: Self.phpIniFileUrl.path)
|
||||
|
||||
XCTAssertGreaterThan(extensions.count, 0)
|
||||
}
|
||||
|
||||
func testExtensionNameIsCorrect() throws {
|
||||
let extensions = PhpExtension.from(filePath: Self.phpIniFileUrl.path)
|
||||
|
||||
let extensionNames = extensions.map { (ext) -> String in
|
||||
return ext.name
|
||||
}
|
||||
|
||||
// These 6 should be found
|
||||
XCTAssertTrue(extensionNames.contains("xdebug"))
|
||||
XCTAssertTrue(extensionNames.contains("imagick"))
|
||||
XCTAssertTrue(extensionNames.contains("sodium-next"))
|
||||
XCTAssertTrue(extensionNames.contains("opcache"))
|
||||
XCTAssertTrue(extensionNames.contains("yaml"))
|
||||
XCTAssertTrue(extensionNames.contains("custom"))
|
||||
|
||||
XCTAssertFalse(extensionNames.contains("fake"))
|
||||
XCTAssertFalse(extensionNames.contains("nice"))
|
||||
}
|
||||
|
||||
func testExtensionStatusIsCorrect() throws {
|
||||
let extensions = PhpExtension.from(filePath: Self.phpIniFileUrl.path)
|
||||
|
||||
// xdebug should be enabled
|
||||
XCTAssertEqual(extensions[0].enabled, true)
|
||||
|
||||
// imagick should be disabled
|
||||
XCTAssertEqual(extensions[1].enabled, false)
|
||||
}
|
||||
|
||||
func testToggleWorksAsExpected() async throws {
|
||||
let destination = Utility.copyToTemporaryFile(resourceName: "php", fileExtension: "ini")!
|
||||
let extensions = PhpExtension.from(filePath: destination.path)
|
||||
XCTAssertEqual(extensions.count, 6)
|
||||
|
||||
// Try to disable xdebug (should be detected first)!
|
||||
let xdebug = extensions.first!
|
||||
XCTAssertTrue(xdebug.name == "xdebug")
|
||||
XCTAssertEqual(xdebug.enabled, true)
|
||||
await xdebug.toggle()
|
||||
XCTAssertEqual(xdebug.enabled, false)
|
||||
|
||||
// Check if the file contains the appropriate data
|
||||
let file = try! String(contentsOf: destination, encoding: .utf8)
|
||||
XCTAssertTrue(file.contains("; zend_extension=\"xdebug.so\""))
|
||||
|
||||
// Make sure if we load the data again, it's disabled
|
||||
XCTAssertEqual(PhpExtension.from(filePath: destination.path).first!.enabled, false)
|
||||
}
|
||||
|
||||
}
|
39
tests/unit/Parsers/ValetConfigurationTest.swift
Normal file
39
tests/unit/Parsers/ValetConfigurationTest.swift
Normal file
@ -0,0 +1,39 @@
|
||||
//
|
||||
// ValetConfigParserTest.swift
|
||||
// phpmon-tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 29/11/2021.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class ValetConfigurationTest: XCTestCase {
|
||||
|
||||
static var jsonConfigFileUrl: URL {
|
||||
return Bundle(for: Self.self).url(
|
||||
forResource: "valet-config",
|
||||
withExtension: "json"
|
||||
)!
|
||||
}
|
||||
|
||||
func testCanLoadConfigFile() throws {
|
||||
let json = try? String(
|
||||
contentsOf: Self.jsonConfigFileUrl,
|
||||
encoding: .utf8
|
||||
)
|
||||
let config = try! JSONDecoder().decode(
|
||||
Valet.Configuration.self,
|
||||
from: json!.data(using: .utf8)!
|
||||
)
|
||||
|
||||
XCTAssertEqual(config.tld, "test")
|
||||
XCTAssertEqual(config.paths, [
|
||||
"/Users/username/.config/valet/Sites",
|
||||
"/Users/username/Sites"
|
||||
])
|
||||
XCTAssertEqual(config.defaultSite, "/Users/username/default-site")
|
||||
XCTAssertEqual(config.loopback, "127.0.0.1")
|
||||
}
|
||||
|
||||
}
|
395
tests/unit/Test Files/brew/brew-formula.json
Normal file
395
tests/unit/Test Files/brew/brew-formula.json
Normal file
@ -0,0 +1,395 @@
|
||||
[
|
||||
{
|
||||
"name": "php",
|
||||
"full_name": "php",
|
||||
"tap": "homebrew/core",
|
||||
"oldname": null,
|
||||
"aliases": [
|
||||
"php@8.1"
|
||||
],
|
||||
"versioned_formulae": [
|
||||
"php@8.0",
|
||||
"php@7.4",
|
||||
"php@7.3",
|
||||
"php@7.2"
|
||||
],
|
||||
"desc": "General-purpose scripting language",
|
||||
"license": "PHP-3.01",
|
||||
"homepage": "https://www.php.net/",
|
||||
"versions": {
|
||||
"stable": "8.1.10",
|
||||
"head": "HEAD",
|
||||
"bottle": true
|
||||
},
|
||||
"urls": {
|
||||
"stable": {
|
||||
"url": "https://www.php.net/distributions/php-8.1.10.tar.xz",
|
||||
"tag": null,
|
||||
"revision": null
|
||||
}
|
||||
},
|
||||
"revision": 1,
|
||||
"version_scheme": 0,
|
||||
"bottle": {
|
||||
"stable": {
|
||||
"rebuild": 0,
|
||||
"root_url": "https://ghcr.io/v2/homebrew/core",
|
||||
"files": {
|
||||
"arm64_monterey": {
|
||||
"cellar": "/opt/homebrew/Cellar",
|
||||
"url": "https://ghcr.io/v2/homebrew/core/php/blobs/sha256:dcee33c9f445db3026a7e867805eb8f6d82e9e5599599b8c6cd8645475f7961c",
|
||||
"sha256": "dcee33c9f445db3026a7e867805eb8f6d82e9e5599599b8c6cd8645475f7961c"
|
||||
},
|
||||
"arm64_big_sur": {
|
||||
"cellar": "/opt/homebrew/Cellar",
|
||||
"url": "https://ghcr.io/v2/homebrew/core/php/blobs/sha256:e0590064cd32f2baa4102fa49c80056f3886a0a89aec0589d0134ecbf0e7923e",
|
||||
"sha256": "e0590064cd32f2baa4102fa49c80056f3886a0a89aec0589d0134ecbf0e7923e"
|
||||
},
|
||||
"monterey": {
|
||||
"cellar": "/usr/local/Cellar",
|
||||
"url": "https://ghcr.io/v2/homebrew/core/php/blobs/sha256:62481320613b19c6ff310bf6ed50c7d2a2253cdbf403af12ec97bccd8a97a84c",
|
||||
"sha256": "62481320613b19c6ff310bf6ed50c7d2a2253cdbf403af12ec97bccd8a97a84c"
|
||||
},
|
||||
"big_sur": {
|
||||
"cellar": "/usr/local/Cellar",
|
||||
"url": "https://ghcr.io/v2/homebrew/core/php/blobs/sha256:b34d96f7aad3c580a7cbdaadb8054fb9b6872111a5eec8e1bcb4a529970c8e03",
|
||||
"sha256": "b34d96f7aad3c580a7cbdaadb8054fb9b6872111a5eec8e1bcb4a529970c8e03"
|
||||
},
|
||||
"catalina": {
|
||||
"cellar": "/usr/local/Cellar",
|
||||
"url": "https://ghcr.io/v2/homebrew/core/php/blobs/sha256:cc0b85dcfdd60e1d8d7fa74c9f53be5d249d068835dbc7a81edacb7a076b6c76",
|
||||
"sha256": "cc0b85dcfdd60e1d8d7fa74c9f53be5d249d068835dbc7a81edacb7a076b6c76"
|
||||
},
|
||||
"x86_64_linux": {
|
||||
"cellar": "/home/linuxbrew/.linuxbrew/Cellar",
|
||||
"url": "https://ghcr.io/v2/homebrew/core/php/blobs/sha256:b934a5a4ad2d29b629f83962b57f638a654801d1ba21ba659a42da2e5afe3fae",
|
||||
"sha256": "b934a5a4ad2d29b629f83962b57f638a654801d1ba21ba659a42da2e5afe3fae"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"keg_only": false,
|
||||
"keg_only_reason": null,
|
||||
"options": [
|
||||
|
||||
],
|
||||
"build_dependencies": [
|
||||
"httpd",
|
||||
"pkg-config"
|
||||
],
|
||||
"dependencies": [
|
||||
"apr",
|
||||
"apr-util",
|
||||
"argon2",
|
||||
"aspell",
|
||||
"autoconf",
|
||||
"curl",
|
||||
"freetds",
|
||||
"gd",
|
||||
"gettext",
|
||||
"gmp",
|
||||
"icu4c",
|
||||
"krb5",
|
||||
"libpq",
|
||||
"libsodium",
|
||||
"libzip",
|
||||
"oniguruma",
|
||||
"openldap",
|
||||
"openssl@1.1",
|
||||
"pcre2",
|
||||
"sqlite",
|
||||
"tidy-html5",
|
||||
"unixodbc"
|
||||
],
|
||||
"test_dependencies": [
|
||||
"httpd"
|
||||
],
|
||||
"recommended_dependencies": [
|
||||
|
||||
],
|
||||
"optional_dependencies": [
|
||||
|
||||
],
|
||||
"uses_from_macos": [
|
||||
{
|
||||
"xz": "build"
|
||||
},
|
||||
"bzip2",
|
||||
"libedit",
|
||||
"libffi",
|
||||
"libxml2",
|
||||
"libxslt",
|
||||
"zlib"
|
||||
],
|
||||
"requirements": [
|
||||
|
||||
],
|
||||
"conflicts_with": [
|
||||
|
||||
],
|
||||
"caveats": "To enable PHP in Apache add the following to httpd.conf and restart Apache:\n LoadModule php_module $(brew --prefix)/opt/php/lib/httpd/modules/libphp.so\n\n <FilesMatch \\.php$>\n SetHandler application/x-httpd-php\n </FilesMatch>\n\nFinally, check DirectoryIndex includes index.php\n DirectoryIndex index.php index.html\n\nThe php.ini and php-fpm.ini file can be found in:\n $(brew --prefix)/etc/php/8.1/\n",
|
||||
"installed": [
|
||||
{
|
||||
"version": "8.1.10_1",
|
||||
"used_options": [
|
||||
|
||||
],
|
||||
"built_as_bottle": true,
|
||||
"poured_from_bottle": true,
|
||||
"runtime_dependencies": [
|
||||
{
|
||||
"full_name": "apr",
|
||||
"version": "1.7.0",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "ca-certificates",
|
||||
"version": "2022-07-19",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "openssl@1.1",
|
||||
"version": "1.1.1q",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "apr-util",
|
||||
"version": "1.6.1",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "argon2",
|
||||
"version": "20190702",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "aspell",
|
||||
"version": "0.60.8",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "m4",
|
||||
"version": "1.4.19",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "autoconf",
|
||||
"version": "2.71",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "brotli",
|
||||
"version": "1.0.9",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "gettext",
|
||||
"version": "0.21",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "libunistring",
|
||||
"version": "1.0",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "libidn2",
|
||||
"version": "2.3.3",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "libnghttp2",
|
||||
"version": "1.49.0",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "libssh2",
|
||||
"version": "1.10.0",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "openldap",
|
||||
"version": "2.6.3",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "rtmpdump",
|
||||
"version": "2.4+20151223",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "lz4",
|
||||
"version": "1.9.4",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "xz",
|
||||
"version": "5.2.6",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "zstd",
|
||||
"version": "1.5.2",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "curl",
|
||||
"version": "7.85.0",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "libtool",
|
||||
"version": "2.4.7",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "unixodbc",
|
||||
"version": "2.3.11",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "freetds",
|
||||
"version": "1.3.13",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "libpng",
|
||||
"version": "1.6.37",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "freetype",
|
||||
"version": "2.12.1",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "fontconfig",
|
||||
"version": "2.14.0",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "jpeg-turbo",
|
||||
"version": "2.1.4",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "giflib",
|
||||
"version": "5.2.1",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "imath",
|
||||
"version": "3.1.5",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "openexr",
|
||||
"version": "3.1.5",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "libtiff",
|
||||
"version": "4.4.0",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "webp",
|
||||
"version": "1.2.4",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "jpeg-xl",
|
||||
"version": "0.6.1",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "libvmaf",
|
||||
"version": "2.3.1",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "aom",
|
||||
"version": "3.4.0",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "libavif",
|
||||
"version": "0.10.1",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "gd",
|
||||
"version": "2.3.3",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "gmp",
|
||||
"version": "6.2.1",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "icu4c",
|
||||
"version": "71.1",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "krb5",
|
||||
"version": "1.20",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "libpq",
|
||||
"version": "14.5",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "libsodium",
|
||||
"version": "1.0.18",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "libzip",
|
||||
"version": "1.9.2",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "oniguruma",
|
||||
"version": "6.9.8",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "pcre2",
|
||||
"version": "10.40",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "readline",
|
||||
"version": "8.1.2",
|
||||
"declared_directly": false
|
||||
},
|
||||
{
|
||||
"full_name": "sqlite",
|
||||
"version": "3.39.2",
|
||||
"declared_directly": true
|
||||
},
|
||||
{
|
||||
"full_name": "tidy-html5",
|
||||
"version": "5.8.0",
|
||||
"declared_directly": true
|
||||
}
|
||||
],
|
||||
"installed_as_dependency": false,
|
||||
"installed_on_request": true
|
||||
}
|
||||
],
|
||||
"linked_keg": "8.1.10_1",
|
||||
"pinned": false,
|
||||
"outdated": false,
|
||||
"deprecated": false,
|
||||
"deprecation_date": null,
|
||||
"deprecation_reason": null,
|
||||
"disabled": false,
|
||||
"disable_date": null,
|
||||
"disable_reason": null
|
||||
}
|
||||
]
|
135
tests/unit/Test Files/brew/brew-services.json
Normal file
135
tests/unit/Test Files/brew/brew-services.json
Normal file
@ -0,0 +1,135 @@
|
||||
[
|
||||
{
|
||||
"name": "dnsmasq",
|
||||
"service_name": "homebrew.mxcl.dnsmasq",
|
||||
"running": true,
|
||||
"loaded": true,
|
||||
"schedulable": false,
|
||||
"pid": 106,
|
||||
"exit_code": 0,
|
||||
"user": "root",
|
||||
"status": "started",
|
||||
"file": "/Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist",
|
||||
"command": "/opt/homebrew/opt/dnsmasq/sbin/dnsmasq --keep-in-foreground -C /opt/homebrew/etc/dnsmasq.conf -7 /opt/homebrew/etc/dnsmasq.d,*.conf",
|
||||
"working_dir": null,
|
||||
"root_dir": null,
|
||||
"log_path": null,
|
||||
"error_log_path": null,
|
||||
"interval": null,
|
||||
"cron": null
|
||||
},
|
||||
{
|
||||
"name": "httpd",
|
||||
"service_name": "homebrew.mxcl.httpd",
|
||||
"running": false,
|
||||
"loaded": false,
|
||||
"schedulable": false,
|
||||
"pid": null,
|
||||
"exit_code": null,
|
||||
"user": null,
|
||||
"status": "none",
|
||||
"file": "/opt/homebrew/opt/httpd/homebrew.mxcl.httpd.plist",
|
||||
"command": "/opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND",
|
||||
"working_dir": null,
|
||||
"root_dir": null,
|
||||
"log_path": null,
|
||||
"error_log_path": null,
|
||||
"interval": null,
|
||||
"cron": null
|
||||
},
|
||||
{
|
||||
"name": "mailhog",
|
||||
"service_name": "homebrew.mxcl.mailhog",
|
||||
"running": false,
|
||||
"loaded": false,
|
||||
"schedulable": false,
|
||||
"pid": null,
|
||||
"exit_code": null,
|
||||
"user": null,
|
||||
"status": "none",
|
||||
"file": "/opt/homebrew/opt/mailhog/homebrew.mxcl.mailhog.plist",
|
||||
"command": "/opt/homebrew/opt/mailhog/bin/MailHog",
|
||||
"working_dir": null,
|
||||
"root_dir": null,
|
||||
"log_path": "/opt/homebrew/var/log/mailhog.log",
|
||||
"error_log_path": "/opt/homebrew/var/log/mailhog.log",
|
||||
"interval": null,
|
||||
"cron": null
|
||||
},
|
||||
{
|
||||
"name": "nginx",
|
||||
"service_name": "homebrew.mxcl.nginx",
|
||||
"running": true,
|
||||
"loaded": true,
|
||||
"schedulable": false,
|
||||
"pid": 116,
|
||||
"exit_code": 0,
|
||||
"user": "root",
|
||||
"status": "started",
|
||||
"file": "/Library/LaunchDaemons/homebrew.mxcl.nginx.plist",
|
||||
"command": "/opt/homebrew/opt/nginx/bin/nginx -g daemon off;",
|
||||
"working_dir": "/opt/homebrew",
|
||||
"root_dir": null,
|
||||
"log_path": null,
|
||||
"error_log_path": null,
|
||||
"interval": null,
|
||||
"cron": null
|
||||
},
|
||||
{
|
||||
"name": "php",
|
||||
"service_name": "homebrew.mxcl.php",
|
||||
"running": true,
|
||||
"loaded": true,
|
||||
"schedulable": false,
|
||||
"pid": 142,
|
||||
"exit_code": 0,
|
||||
"user": "root",
|
||||
"status": "started",
|
||||
"file": "/Library/LaunchDaemons/homebrew.mxcl.php.plist",
|
||||
"command": "/opt/homebrew/opt/php/sbin/php-fpm --nodaemonize",
|
||||
"working_dir": "/opt/homebrew/var",
|
||||
"root_dir": null,
|
||||
"log_path": null,
|
||||
"error_log_path": "/opt/homebrew/var/log/php-fpm.log",
|
||||
"interval": null,
|
||||
"cron": null
|
||||
},
|
||||
{
|
||||
"name": "php@8.0",
|
||||
"service_name": "homebrew.mxcl.php@8.0",
|
||||
"running": false,
|
||||
"loaded": false,
|
||||
"schedulable": false,
|
||||
"pid": null,
|
||||
"exit_code": null,
|
||||
"user": null,
|
||||
"status": "none",
|
||||
"file": "/opt/homebrew/opt/php@8.0/homebrew.mxcl.php@8.0.plist",
|
||||
"command": "/opt/homebrew/opt/php@8.0/sbin/php-fpm --nodaemonize",
|
||||
"working_dir": "/opt/homebrew/var",
|
||||
"root_dir": null,
|
||||
"log_path": null,
|
||||
"error_log_path": "/opt/homebrew/var/log/php-fpm.log",
|
||||
"interval": null,
|
||||
"cron": null
|
||||
},
|
||||
{
|
||||
"name": "unbound",
|
||||
"service_name": "homebrew.mxcl.unbound",
|
||||
"running": false,
|
||||
"loaded": false,
|
||||
"schedulable": false,
|
||||
"pid": null,
|
||||
"exit_code": null,
|
||||
"user": null,
|
||||
"status": "none",
|
||||
"file": "/opt/homebrew/opt/unbound/homebrew.mxcl.unbound.plist",
|
||||
"command": "/opt/homebrew/opt/unbound/sbin/unbound -d -c /opt/homebrew/etc/unbound/unbound.conf",
|
||||
"working_dir": null,
|
||||
"root_dir": null,
|
||||
"log_path": null,
|
||||
"error_log_path": null,
|
||||
"interval": null,
|
||||
"cron": null
|
||||
}
|
||||
]
|
81
tests/unit/Test Files/nginx/nginx-proxy.test
Normal file
81
tests/unit/Test Files/nginx/nginx-proxy.test
Normal file
@ -0,0 +1,81 @@
|
||||
# valet stub: proxy.valet.conf
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:80;
|
||||
#listen 127.0.0.1:80; # valet loopback
|
||||
server_name my-proxy.test www.my-proxy.test *.my-proxy.test;
|
||||
root /;
|
||||
charset utf-8;
|
||||
client_max_body_size 128M;
|
||||
|
||||
location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
|
||||
internal;
|
||||
alias /;
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
access_log off;
|
||||
error_log "/Users/nicoverbruggen/.config/valet/Log/my-proxy.test-error.log";
|
||||
|
||||
error_page 404 "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:90;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Client-Verify SUCCESS;
|
||||
proxy_set_header X-Client-DN $ssl_client_s_dn;
|
||||
proxy_set_header X-SSL-Subject $ssl_client_s_dn;
|
||||
proxy_set_header X-SSL-Issuer $ssl_client_i_dn;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_http_version 1.1;
|
||||
proxy_read_timeout 1800;
|
||||
proxy_connect_timeout 1800;
|
||||
chunked_transfer_encoding on;
|
||||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:60;
|
||||
#listen 127.0.0.1:60; # valet loopback
|
||||
server_name my-proxy.test www.my-proxy.test *.my-proxy.test;
|
||||
root /;
|
||||
charset utf-8;
|
||||
client_max_body_size 128M;
|
||||
|
||||
add_header X-Robots-Tag 'noindex, nofollow, nosnippet, noarchive';
|
||||
|
||||
location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
|
||||
internal;
|
||||
alias /;
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
access_log off;
|
||||
error_log "/Users/nicoverbruggen/.config/valet/Log/my-proxy.test-error.log";
|
||||
|
||||
error_page 404 "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:90;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,57 @@
|
||||
# valet stub: secure.proxy.valet.conf
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:80;
|
||||
#listen 127.0.0.1:80; # valet loopback
|
||||
server_name live.whatagraph.dev.com www.live.whatagraph.dev.com *.live.whatagraph.dev.com;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:443 ssl http2;
|
||||
#listen 127.0.0.1:443 ssl http2; # valet loopback
|
||||
server_name live.whatagraph.dev.com www.live.whatagraph.dev.com *.live.whatagraph.dev.com;
|
||||
root /;
|
||||
charset utf-8;
|
||||
client_max_body_size 128M;
|
||||
http2_push_preload on;
|
||||
|
||||
location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
|
||||
internal;
|
||||
alias /;
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
ssl_certificate "/Users/phpmon/.config/valet/Certificates/live.whatagraph.dev.com.crt";
|
||||
ssl_certificate_key "/Users/phpmon/.config/valet/Certificates/live.whatagraph.dev.com.key";
|
||||
|
||||
access_log off;
|
||||
error_log "/Users/phpmon/.config/valet/Log/live.whatagraph.dev.com-error.log";
|
||||
|
||||
error_page 404 "/Users/phpmon/.composer/vendor/laravel/valet/server.php";
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:8080/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Client-Verify SUCCESS;
|
||||
proxy_set_header X-Client-DN $ssl_client_s_dn;
|
||||
proxy_set_header X-SSL-Subject $ssl_client_s_dn;
|
||||
proxy_set_header X-SSL-Issuer $ssl_client_i_dn;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_http_version 1.1;
|
||||
proxy_read_timeout 1800;
|
||||
proxy_connect_timeout 1800;
|
||||
chunked_transfer_encoding on;
|
||||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
57
tests/unit/Test Files/nginx/nginx-secure-proxy.test
Normal file
57
tests/unit/Test Files/nginx/nginx-secure-proxy.test
Normal file
@ -0,0 +1,57 @@
|
||||
# valet stub: secure.proxy.valet.conf
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:80;
|
||||
#listen 127.0.0.1:80; # valet loopback
|
||||
server_name my-proxy.test www.my-proxy.test *.my-proxy.test;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:443 ssl http2;
|
||||
#listen 127.0.0.1:443 ssl http2; # valet loopback
|
||||
server_name my-proxy.test www.my-proxy.test *.my-proxy.test;
|
||||
root /;
|
||||
charset utf-8;
|
||||
client_max_body_size 128M;
|
||||
http2_push_preload on;
|
||||
|
||||
location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
|
||||
internal;
|
||||
alias /;
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
ssl_certificate "/Users/nicoverbruggen/.config/valet/Certificates/my-proxy.test.crt";
|
||||
ssl_certificate_key "/Users/nicoverbruggen/.config/valet/Certificates/my-proxy.test.key";
|
||||
|
||||
access_log off;
|
||||
error_log "/Users/nicoverbruggen/.config/valet/Log/my-proxy.test-error.log";
|
||||
|
||||
error_page 404 "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:90;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Client-Verify SUCCESS;
|
||||
proxy_set_header X-Client-DN $ssl_client_s_dn;
|
||||
proxy_set_header X-SSL-Subject $ssl_client_s_dn;
|
||||
proxy_set_header X-SSL-Issuer $ssl_client_i_dn;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_http_version 1.1;
|
||||
proxy_read_timeout 1800;
|
||||
proxy_connect_timeout 1800;
|
||||
chunked_transfer_encoding on;
|
||||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
94
tests/unit/Test Files/nginx/nginx-site-isolated.test
Normal file
94
tests/unit/Test Files/nginx/nginx-site-isolated.test
Normal file
@ -0,0 +1,94 @@
|
||||
server {
|
||||
listen 127.0.0.1:80;
|
||||
#listen 127.0.0.1:80; # valet loopback
|
||||
server_name nicoverbruggen.test www.nicoverbruggen.test *.nicoverbruggen.test;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:443 ssl http2;
|
||||
#listen 127.0.0.1:443 ssl http2; # valet loopback
|
||||
server_name nicoverbruggen.test www.nicoverbruggen.test *.nicoverbruggen.test;
|
||||
root /;
|
||||
charset utf-8;
|
||||
client_max_body_size 512M;
|
||||
http2_push_preload on;
|
||||
|
||||
location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
|
||||
internal;
|
||||
alias /;
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
ssl_certificate "/Users/nicoverbruggen/.config/valet/Certificates/nicoverbruggen.test.crt";
|
||||
ssl_certificate_key "/Users/nicoverbruggen/.config/valet/Certificates/nicoverbruggen.test.key";
|
||||
|
||||
location / {
|
||||
rewrite ^ "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php" last;
|
||||
}
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
access_log off;
|
||||
error_log "/Users/nicoverbruggen/.config/valet/Log/nginx-error.log";
|
||||
|
||||
error_page 404 "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
# ISOLATED_PHP_VERSION=php@8.1
|
||||
fastcgi_pass "unix:/Users/nicoverbruggen/.config/valet/valet81.sock";
|
||||
fastcgi_index "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:60;
|
||||
#listen 127.0.0.1:60; # valet loopback
|
||||
server_name nicoverbruggen.test www.nicoverbruggen.test *.nicoverbruggen.test;
|
||||
root /;
|
||||
charset utf-8;
|
||||
client_max_body_size 128M;
|
||||
|
||||
add_header X-Robots-Tag 'noindex, nofollow, nosnippet, noarchive';
|
||||
|
||||
location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
|
||||
internal;
|
||||
alias /;
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
location / {
|
||||
rewrite ^ "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php" last;
|
||||
}
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
access_log off;
|
||||
error_log "/Users/nicoverbruggen/.config/valet/Log/nginx-error.log";
|
||||
|
||||
error_page 404 "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass "unix:/Users/nicoverbruggen/.config/valet/valet.sock";
|
||||
fastcgi_index "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
|
93
tests/unit/Test Files/nginx/nginx-site.test
Normal file
93
tests/unit/Test Files/nginx/nginx-site.test
Normal file
@ -0,0 +1,93 @@
|
||||
server {
|
||||
listen 127.0.0.1:80;
|
||||
#listen 127.0.0.1:80; # valet loopback
|
||||
server_name nicoverbruggen.test www.nicoverbruggen.test *.nicoverbruggen.test;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:443 ssl http2;
|
||||
#listen 127.0.0.1:443 ssl http2; # valet loopback
|
||||
server_name nicoverbruggen.test www.nicoverbruggen.test *.nicoverbruggen.test;
|
||||
root /;
|
||||
charset utf-8;
|
||||
client_max_body_size 512M;
|
||||
http2_push_preload on;
|
||||
|
||||
location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
|
||||
internal;
|
||||
alias /;
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
ssl_certificate "/Users/nicoverbruggen/.config/valet/Certificates/nicoverbruggen.test.crt";
|
||||
ssl_certificate_key "/Users/nicoverbruggen/.config/valet/Certificates/nicoverbruggen.test.key";
|
||||
|
||||
location / {
|
||||
rewrite ^ "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php" last;
|
||||
}
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
access_log off;
|
||||
error_log "/Users/nicoverbruggen/.config/valet/Log/nginx-error.log";
|
||||
|
||||
error_page 404 "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass "unix:/Users/nicoverbruggen/.config/valet/valet.sock";
|
||||
fastcgi_index "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:60;
|
||||
#listen 127.0.0.1:60; # valet loopback
|
||||
server_name nicoverbruggen.test www.nicoverbruggen.test *.nicoverbruggen.test;
|
||||
root /;
|
||||
charset utf-8;
|
||||
client_max_body_size 128M;
|
||||
|
||||
add_header X-Robots-Tag 'noindex, nofollow, nosnippet, noarchive';
|
||||
|
||||
location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
|
||||
internal;
|
||||
alias /;
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
location / {
|
||||
rewrite ^ "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php" last;
|
||||
}
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
access_log off;
|
||||
error_log "/Users/nicoverbruggen/.config/valet/Log/nginx-error.log";
|
||||
|
||||
error_page 404 "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass "unix:/Users/nicoverbruggen/.config/valet/valet.sock";
|
||||
fastcgi_index "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME "/Users/nicoverbruggen/.composer/vendor/laravel/valet/server.php";
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
|
1957
tests/unit/Test Files/php/php.ini
Normal file
1957
tests/unit/Test Files/php/php.ini
Normal file
File diff suppressed because it is too large
Load Diff
34
tests/unit/Test Files/phpmon/phpmon-config.json
Normal file
34
tests/unit/Test Files/phpmon/phpmon-config.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"scan_apps": [],
|
||||
"presets": [
|
||||
{
|
||||
"name": "Default PHP",
|
||||
"extensions": {
|
||||
"xdebug": false
|
||||
},
|
||||
"configuration": {
|
||||
"memory_limit": "128M"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Personal Site",
|
||||
"extensions": {
|
||||
"xdebug": true
|
||||
},
|
||||
"configuration": {
|
||||
"xdebug.mode": "coverage",
|
||||
"memory_limit": "512M"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "PHP Monitor",
|
||||
"extensions": {
|
||||
"xdebug": true
|
||||
},
|
||||
"configuration": {
|
||||
"xdebug.mode": "coverage",
|
||||
"memory_limit": "512M"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
9
tests/unit/Test Files/valet/valet-config.json
Normal file
9
tests/unit/Test Files/valet/valet-config.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"tld": "test",
|
||||
"paths": [
|
||||
"/Users/username/.config/valet/Sites",
|
||||
"/Users/username/Sites"
|
||||
],
|
||||
"loopback": "127.0.0.1",
|
||||
"default": "/Users/username/default-site"
|
||||
}
|
39
tests/unit/Testables/Shell/FakeShellTest.swift
Normal file
39
tests/unit/Testables/Shell/FakeShellTest.swift
Normal file
@ -0,0 +1,39 @@
|
||||
//
|
||||
// ShellTest.swift
|
||||
// phpmon-tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 20/09/2022.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class FakeShellTest: XCTestCase {
|
||||
func test_fake_shell_output_can_be_declared() async {
|
||||
let greeting = BatchFakeShellOutput(items: [
|
||||
.instant("Hello world\n"),
|
||||
.delayed(0.3, "Goodbye world")
|
||||
])
|
||||
|
||||
let output = await greeting.outputInstantaneously()
|
||||
|
||||
XCTAssertEqual("Hello world\nGoodbye world", output.out)
|
||||
}
|
||||
|
||||
func test_fake_shell_can_output_in_realtime() async {
|
||||
let greeting = BatchFakeShellOutput(items: [
|
||||
.instant("Hello world\n"),
|
||||
.delayed(2, "Goodbye world")
|
||||
])
|
||||
|
||||
let output = await greeting.output(didReceiveOutput: { _, _ in })
|
||||
|
||||
XCTAssertEqual("Hello world\nGoodbye world", output.out)
|
||||
}
|
||||
|
||||
func test_fake_shell_has_path() {
|
||||
ActiveShell.useTestable([:])
|
||||
|
||||
XCTAssertEqual(Shell.PATH, "/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin")
|
||||
}
|
||||
}
|
79
tests/unit/Testables/Shell/SystemShellTest.swift
Normal file
79
tests/unit/Testables/Shell/SystemShellTest.swift
Normal file
@ -0,0 +1,79 @@
|
||||
//
|
||||
// SystemShellTest.swift
|
||||
// phpmon-tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 28/09/2022.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class SystemShellTest: XCTestCase {
|
||||
|
||||
override class func setUp() {
|
||||
// Reset to the default shell
|
||||
ActiveShell.useSystem()
|
||||
}
|
||||
|
||||
func test_system_shell_is_default() async {
|
||||
XCTAssertTrue(Shell is RealShell)
|
||||
|
||||
let output = await Shell.pipe("php -v")
|
||||
|
||||
XCTAssertTrue(output.out.contains("Copyright (c) The PHP Group"))
|
||||
}
|
||||
|
||||
func test_system_shell_has_path() {
|
||||
let systemShell = Shell as! RealShell
|
||||
|
||||
XCTAssertTrue(systemShell.PATH.contains(":/usr/local/bin"))
|
||||
XCTAssertTrue(systemShell.PATH.contains(":/usr/bin"))
|
||||
}
|
||||
|
||||
func test_system_shell_can_buffer_output() async {
|
||||
var bits: [String] = []
|
||||
|
||||
let (_, shellOutput) = try! await Shell.attach(
|
||||
"php -r \"echo 'Hello world' . PHP_EOL; usleep(200); echo 'Goodbye world';\"",
|
||||
didReceiveOutput: { incoming, _ in
|
||||
bits.append(incoming)
|
||||
},
|
||||
withTimeout: 2.0
|
||||
)
|
||||
|
||||
XCTAssertTrue(bits.contains("Hello world\n"))
|
||||
XCTAssertTrue(bits.contains("Goodbye world"))
|
||||
XCTAssertEqual("Hello world\nGoodbye world", shellOutput.out)
|
||||
}
|
||||
|
||||
func test_system_shell_can_timeout_and_throw_error() async {
|
||||
let expectation = XCTestExpectation(description: #function)
|
||||
|
||||
do {
|
||||
_ = try await Shell.attach(
|
||||
"php -r \"sleep(1);\"",
|
||||
didReceiveOutput: { _, _ in },
|
||||
withTimeout: 0.1
|
||||
)
|
||||
} catch {
|
||||
XCTAssertEqual(error as? ShellError, ShellError.timedOut)
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_system_processes_run_in_parallel() async {
|
||||
let expectation = XCTestExpectation(description: #function)
|
||||
|
||||
let thing = {
|
||||
await Shell.quiet("php -r \"usleep(700);\"")
|
||||
await Shell.quiet("php -r \"usleep(700);\"")
|
||||
await Shell.quiet("php -r \"usleep(700);\"")
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
||||
await thing()
|
||||
wait(for: [expectation], timeout: 1.0)
|
||||
}
|
||||
}
|
28
tests/unit/Utility.swift
Normal file
28
tests/unit/Utility.swift
Normal file
@ -0,0 +1,28 @@
|
||||
//
|
||||
// Utility.swift
|
||||
// phpmon-tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 14/02/2021.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class Utility {
|
||||
|
||||
public static func copyToTemporaryFile(resourceName: String, fileExtension: String) -> URL? {
|
||||
if let bundleURL = Bundle(for: Self.self).url(forResource: resourceName, withExtension: fileExtension) {
|
||||
let tempDirectoryURL = NSURL.fileURL(withPath: NSTemporaryDirectory(), isDirectory: true)
|
||||
let targetURL = tempDirectoryURL.appendingPathComponent("\(UUID().uuidString).\(fileExtension)")
|
||||
|
||||
do {
|
||||
try FileManager.default.copyItem(at: bundleURL, to: targetURL)
|
||||
return targetURL
|
||||
} catch let error {
|
||||
Log.err("Unable to copy file: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
47
tests/unit/Versions/AppUpdaterCheckTest.swift
Normal file
47
tests/unit/Versions/AppUpdaterCheckTest.swift
Normal file
@ -0,0 +1,47 @@
|
||||
//
|
||||
// AppUpdaterCheckTest.swift
|
||||
// phpmon-tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 10/05/2022.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class AppUpdaterCheckTest: XCTestCase {
|
||||
|
||||
func testCanRetrieveVersionFromCask() async {
|
||||
let caskVersion = await AppUpdateChecker.retrieveVersionFromCask()
|
||||
|
||||
let version = VersionExtractor.from(caskVersion)
|
||||
|
||||
XCTAssertNotNil(version)
|
||||
}
|
||||
|
||||
func testTaggedReleaseOmitsZeroPatch() {
|
||||
let version = AppVersion.from("3.5.0_333")!
|
||||
|
||||
XCTAssertEqual(version.tagged, "3.5")
|
||||
XCTAssertEqual(version.version, "3.5.0")
|
||||
}
|
||||
|
||||
func testTaggedReleaseDoesntOmitNonZeroPatch() {
|
||||
let version = AppVersion.from("3.5.1_333")!
|
||||
|
||||
XCTAssertEqual(version.tagged, "3.5.1")
|
||||
XCTAssertEqual(version.version, "3.5.1")
|
||||
}
|
||||
|
||||
func testTagTruncationDoesntAffectMajorVersions() {
|
||||
var version = AppVersion.from("5.0_333")!
|
||||
|
||||
XCTAssertEqual(version.tagged, "5.0")
|
||||
XCTAssertEqual(version.version, "5.0")
|
||||
|
||||
version = AppVersion.from("5.0.0_333")!
|
||||
|
||||
XCTAssertEqual(version.tagged, "5.0")
|
||||
XCTAssertEqual(version.version, "5.0.0")
|
||||
}
|
||||
|
||||
}
|
62
tests/unit/Versions/AppVersionTest.swift
Normal file
62
tests/unit/Versions/AppVersionTest.swift
Normal file
@ -0,0 +1,62 @@
|
||||
//
|
||||
// AppVersionTest.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 10/05/2022.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class AppVersionTest: XCTestCase {
|
||||
|
||||
func testCanRetrieveInternalAppVersion() {
|
||||
XCTAssertNotNil(AppVersion.fromCurrentVersion())
|
||||
}
|
||||
|
||||
func testCanParseNormalVersionString() {
|
||||
let version = AppVersion.from("1.0.0")
|
||||
|
||||
XCTAssertNotNil(version)
|
||||
XCTAssertEqual("1.0.0", version?.version)
|
||||
XCTAssertEqual(nil, version?.build)
|
||||
XCTAssertEqual(nil, version?.suffix)
|
||||
}
|
||||
|
||||
func testCanParseCaskVersionString() {
|
||||
let version = AppVersion.from("1.0.0_600")
|
||||
|
||||
XCTAssertNotNil(version)
|
||||
XCTAssertEqual("1.0.0", version?.version)
|
||||
XCTAssertEqual("600", version?.build)
|
||||
XCTAssertEqual(nil, version?.suffix)
|
||||
}
|
||||
|
||||
func testCanParseDevVersionStringWithoutBuildNumber() {
|
||||
let version = AppVersion.from("1.0.0-dev")
|
||||
|
||||
XCTAssertNotNil(version)
|
||||
XCTAssertEqual("1.0.0", version?.version)
|
||||
XCTAssertEqual(nil, version?.build)
|
||||
XCTAssertEqual("dev", version?.suffix)
|
||||
}
|
||||
|
||||
func testCanParseDevVersionStringWithBuildNumber() {
|
||||
let version = AppVersion.from("1.0.0-dev,870")
|
||||
|
||||
XCTAssertNotNil(version)
|
||||
XCTAssertEqual("1.0.0", version?.version)
|
||||
XCTAssertEqual("870", version?.build)
|
||||
XCTAssertEqual("dev", version?.suffix)
|
||||
}
|
||||
|
||||
func testCanParseUnderscoresAsBuildSeparatorToo() {
|
||||
let version = AppVersion.from("1.0.0-dev_870")
|
||||
|
||||
XCTAssertNotNil(version)
|
||||
XCTAssertEqual("1.0.0", version?.version)
|
||||
XCTAssertEqual("870", version?.build)
|
||||
XCTAssertEqual("dev", version?.suffix)
|
||||
}
|
||||
|
||||
}
|
29
tests/unit/Versions/PhpVersionDetectionTest.swift
Normal file
29
tests/unit/Versions/PhpVersionDetectionTest.swift
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// PhpVersionDetectionTest.swift
|
||||
// phpmon-tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 01/04/2021.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class PhpVersionDetectionTest: XCTestCase {
|
||||
|
||||
func testCanDetectValidPhpVersions() async throws {
|
||||
let outcome = await PhpEnv.shared.extractPhpVersions(from: [
|
||||
"", // empty lines should be omitted
|
||||
"php@8.0",
|
||||
"php@8.0", // should only be detected once
|
||||
"meta-php@8.0", // should be omitted, invalid
|
||||
"php@8.0-coolio", // should be omitted, invalid
|
||||
"php@7.0",
|
||||
"",
|
||||
"unrelatedphp@1.0", // should be omitted, invalid
|
||||
"php@5.6",
|
||||
"php@5.4" // should be omitted, not supported
|
||||
], checkBinaries: false, generateHelpers: false)
|
||||
|
||||
XCTAssertEqual(outcome, ["8.0", "7.0"])
|
||||
}
|
||||
}
|
363
tests/unit/Versions/PhpVersionNumberTest.swift
Normal file
363
tests/unit/Versions/PhpVersionNumberTest.swift
Normal file
@ -0,0 +1,363 @@
|
||||
//
|
||||
// PhpVersionNumberTest.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 23/01/2022.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
// swiftlint:disable type_body_length
|
||||
class PhpVersionNumberTest: XCTestCase {
|
||||
|
||||
func testCanDeconstructPhpVersion() throws {
|
||||
XCTAssertEqual(
|
||||
try! PhpVersionNumber.parse("PHP 8.2.0-dev"),
|
||||
PhpVersionNumber(major: 8, minor: 2, patch: 0)
|
||||
)
|
||||
XCTAssertEqual(
|
||||
try! PhpVersionNumber.parse("PHP 8.1.0RC5-dev"),
|
||||
PhpVersionNumber(major: 8, minor: 1, patch: 0)
|
||||
)
|
||||
XCTAssertEqual(
|
||||
try! PhpVersionNumber.parse("8.0.11"),
|
||||
PhpVersionNumber(major: 8, minor: 0, patch: 11)
|
||||
)
|
||||
XCTAssertEqual(
|
||||
try! PhpVersionNumber.parse("7.4.2"),
|
||||
PhpVersionNumber(major: 7, minor: 4, patch: 2)
|
||||
)
|
||||
XCTAssertEqual(
|
||||
try! PhpVersionNumber.parse("7.4"),
|
||||
PhpVersionNumber(major: 7, minor: 4, patch: nil)
|
||||
)
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumber.make(from: "7"),
|
||||
nil
|
||||
)
|
||||
}
|
||||
|
||||
func testPhpVersionNumberParse() throws {
|
||||
XCTAssertThrowsError(try PhpVersionNumber.parse("OOF")) { error in
|
||||
XCTAssertTrue(error is VersionParseError)
|
||||
}
|
||||
}
|
||||
|
||||
func testCanCheckFixedConstraints() throws {
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "7.0"),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.0"]).all
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4.3", "7.3.3", "7.2.3", "7.1.3", "7.0.3"])
|
||||
.matching(constraint: "7.0.3"),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.0.3"]).all
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "7.0.3", strict: false),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.0"]).all
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "7.0.3", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: []).all
|
||||
)
|
||||
}
|
||||
|
||||
func testCanCheckCaretConstraints() throws {
|
||||
// 1. Imprecise checks
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "^7.0", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"]).all
|
||||
)
|
||||
|
||||
// 2. Imprecise check with precise constraint (lenient AKA not strict)
|
||||
// These versions are interpreted as 7.4.999, 7.3.999, 7.2.999, etc.
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "^7.0.1", strict: false),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"]).all
|
||||
)
|
||||
|
||||
// 3. Imprecise check with precise constraint (strict mode)
|
||||
// These versions are interpreted as 7.4.0, 7.3.0, 7.2.0, etc.
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "^7.0.1", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1"]).all
|
||||
)
|
||||
|
||||
// 4. Precise members and constraint all around
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
|
||||
.matching(constraint: "^7.0.1", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"]).all
|
||||
)
|
||||
|
||||
// 5. Precise members but imprecise constraint (strict mode)
|
||||
// In strict mode the constraint's patch version is assumed to be 0
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
|
||||
.matching(constraint: "^7.0", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"]).all
|
||||
)
|
||||
|
||||
// 6. Precise members but imprecise constraint (lenient mode)
|
||||
// In lenient mode the constraint's patch version is assumed to be equal
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
|
||||
.matching(constraint: "^7.0", strict: false),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"]).all
|
||||
)
|
||||
}
|
||||
|
||||
func testCanCheckTildeConstraints() throws {
|
||||
// 1. Imprecise checks
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "~7.0", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"]).all
|
||||
)
|
||||
|
||||
// 2. Imprecise check with precise constraint (lenient AKA not strict)
|
||||
// These versions are interpreted as 7.4.999, 7.3.999, 7.2.999, etc.
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "~7.0.1", strict: false),
|
||||
// One result because 7.0.1 to 7.0.x is expected.
|
||||
// 7.0.999 (assumed due to no strictness) is valid.
|
||||
// 7.1.0 and up are not valid (minor version is too high).
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.0"]).all
|
||||
)
|
||||
|
||||
// 3. Imprecise check with precise constraint (strict mode)
|
||||
// These versions are interpreted as 7.4.0, 7.3.0, 7.2.0, etc.
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "~7.0.1", strict: true),
|
||||
// No results because 7.0.1 to 7.0.x is expected.
|
||||
// 7.0.0 (assumed due to strictness) is not valid.
|
||||
// 7.1.0 and up are also not valid (minor version is too high).
|
||||
PhpVersionNumberCollection
|
||||
.make(from: []).all
|
||||
)
|
||||
|
||||
// 4. Precise members and constraint all around
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
|
||||
.matching(constraint: "~7.0.1", strict: true),
|
||||
// Only 7.0 with a patch version of .1 or higher is OK.
|
||||
// In this example, 7.0.10 is OK but all other versions are too new.
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.0.10"]).all
|
||||
)
|
||||
|
||||
// 5. Precise members but imprecise constraint (strict mode)
|
||||
// In strict mode the constraint's patch version is assumed to be 0.
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
|
||||
.matching(constraint: "~7.0", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"]).all
|
||||
)
|
||||
|
||||
// 6. Precise members but imprecise constraint (lenient mode)
|
||||
// In lenient mode the constraint's patch version is assumed to be equal.
|
||||
// (Strictness does not make any difference here, but both should be tested.)
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"])
|
||||
.matching(constraint: "~7.0", strict: false),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4.10", "7.3.10", "7.2.10", "7.1.10", "7.0.10"]).all
|
||||
)
|
||||
}
|
||||
|
||||
func testCanCheckGreaterThanOrEqualConstraints() throws {
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: ">=7.0", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"]).all
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: ">=7.0.0", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"]).all
|
||||
)
|
||||
|
||||
// Strict check (>7.2.5 is too new for 7.2 which resolves to 7.2.0)
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: ">=7.2.5", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3"]).all
|
||||
)
|
||||
|
||||
// Non-strict check (ignoring patch, 7.2 resolves to 7.2.999)
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: ">=7.2.5", strict: false),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2"]).all
|
||||
)
|
||||
}
|
||||
|
||||
func testCanCheckGreaterThanConstraints() throws {
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: ">7.0"),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1"]).all
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: ">7.2.5"),
|
||||
// 7.2 will be valid due to non-strict mode (resolves to 7.2.999)
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2"]).all
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: ">7.2.5", strict: true),
|
||||
// 7.2 will not be valid due to strict mode (resolves to 7.2.0)
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3"]).all
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.3.1", "7.2.9", "7.2.8", "7.2.6", "7.2.5", "7.2"])
|
||||
.matching(constraint: ">7.2.8"),
|
||||
// 7.2 will be valid due to non-strict mode (resolves to 7.2.999)
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.3.1", "7.2.9", "7.2"]).all
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.3.1", "7.2.9", "7.2.8", "7.2.6", "7.2.5", "7.2"])
|
||||
.matching(constraint: ">7.2.8", strict: true),
|
||||
// 7.2 will not be valid due to strict mode (resolves to 7.2.0)
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.3.1", "7.2.9"]).all
|
||||
)
|
||||
}
|
||||
|
||||
func testCanCheckLessThanOrEqualConstraints() throws {
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "<=7.2", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.2", "7.1", "7.0"]).all
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "<=7.2.0", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.2", "7.1", "7.0"]).all
|
||||
)
|
||||
|
||||
// Strict check (>7.2.5 is too new for 7.2 which resolves to 7.2.0)
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "<=7.2.5", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.2", "7.1", "7.0"]).all
|
||||
)
|
||||
|
||||
// Non-strict check (ignoring patch has no effect)
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "<=7.2.5", strict: false),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.2", "7.1", "7.0"]).all
|
||||
)
|
||||
}
|
||||
|
||||
func testCanCheckLessThanConstraints() throws {
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "<7.2", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.1", "7.0"]).all
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "<7.2.0", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.1", "7.0"]).all
|
||||
)
|
||||
|
||||
// Strict check (>7.2.5 is too new for 7.2 which resolves to 7.2.0)
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "<7.2.5", strict: true),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.2", "7.1", "7.0"]).all
|
||||
)
|
||||
|
||||
// Non-strict check (patch resolves to 7.2.999, which is bigger than 7.2.5)
|
||||
XCTAssertEqual(
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.4", "7.3", "7.2", "7.1", "7.0"])
|
||||
.matching(constraint: "<7.2.5", strict: false),
|
||||
PhpVersionNumberCollection
|
||||
.make(from: ["7.1", "7.0"]).all
|
||||
)
|
||||
}
|
||||
}
|
18
tests/unit/Versions/ValetVersionExtractorTest.swift
Normal file
18
tests/unit/Versions/ValetVersionExtractorTest.swift
Normal file
@ -0,0 +1,18 @@
|
||||
//
|
||||
// ValetTest.swift
|
||||
// phpmon-tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 29/11/2021.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class ValetVersionExtractorTest: XCTestCase {
|
||||
|
||||
func testDetermineValetVersion() async {
|
||||
let version = await valet("--version", sudo: false)
|
||||
XCTAssert(version.contains("Laravel Valet 2") || version.contains("Laravel Valet 3"))
|
||||
}
|
||||
|
||||
}
|
25
tests/unit/Versions/VersionExtractorTest.swift
Normal file
25
tests/unit/Versions/VersionExtractorTest.swift
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// VersionExtractorTest.swift
|
||||
// phpmon-tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 16/12/2021.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class VersionExtractorTest: XCTestCase {
|
||||
|
||||
func testExtractVersion() {
|
||||
XCTAssertEqual(VersionExtractor.from("Laravel Valet 2.17.1"), "2.17.1")
|
||||
XCTAssertEqual(VersionExtractor.from("Laravel Valet 2.0"), "2.0")
|
||||
}
|
||||
|
||||
func testVersionComparison() {
|
||||
XCTAssertEqual("2.0".versionCompare("2.1"), .orderedAscending)
|
||||
XCTAssertEqual("2.1".versionCompare("2.0"), .orderedDescending)
|
||||
XCTAssertEqual("2.0".versionCompare("2.0"), .orderedSame)
|
||||
XCTAssertEqual("2.17.0".versionCompare("2.17.1"), .orderedAscending)
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user