1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-06 11:30:08 +02:00
Files
app/tests/Shared/XCPMApplication.swift
2023-01-19 18:11:25 +01:00

24 lines
821 B
Swift

//
// XCPMApplication.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 16/10/2022.
// Copyright © 2023 Nico Verbruggen. All rights reserved.
//
import XCTest
class XCPMApplication: XCUIApplication {
public func withConfiguration(_ configuration: TestableConfiguration) {
let path = persistTestable(configuration)
self.launchArguments = ["--configuration:\(path)"]
}
private func persistTestable(_ configuration: TestableConfiguration) -> String {
let tempDirectoryURL = NSURL.fileURL(withPath: NSTemporaryDirectory(), isDirectory: true)
let targetURL = tempDirectoryURL.appendingPathComponent("\(UUID().uuidString).json")
try! configuration.toJson().write(toFile: targetURL.path, atomically: true, encoding: .utf8)
return targetURL.path
}
}