1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-04-03 09:50:10 +02:00

🚧 WIP: Test refactoring

This commit is contained in:
2025-10-09 16:21:46 +02:00
parent 9e76ca7b25
commit 8af304979b
3 changed files with 51 additions and 46 deletions

View File

@@ -9,39 +9,33 @@
import XCTest
class FeatureTestCase: XCTestCase {
var fakeFileSystem: TestableFileSystem {
let fs = ActiveFileSystem.shared
if fs is TestableFileSystem {
return fs as! TestableFileSystem
}
fatalError("The active filesystem is not a TestableFileSystem. Please use `ActiveFileSystem`.")
}
// TODO: make fake filesystem accessible via test case
public func assertFileSystemHas(
_ path: String,
file: StaticString = #filePath,
line: UInt = #line
line: UInt = #line,
fs: TestableFileSystem
) {
XCTAssertTrue(fakeFileSystem.files.keys.contains(path), file: file, line: line)
XCTAssertTrue(fs.files.keys.contains(path), file: file, line: line)
}
public func assertFileSystemDoesNotHave(
_ path: String,
file: StaticString = #filePath,
line: UInt = #line
line: UInt = #line,
fs: TestableFileSystem
) {
XCTAssertFalse(fakeFileSystem.files.keys.contains(path), file: file, line: line)
XCTAssertFalse(fs.files.keys.contains(path), file: file, line: line)
}
public func assertFileHasContents(
_ path: String,
contents: String,
file: StaticString = #filePath,
line: UInt = #line
line: UInt = #line,
fs: TestableFileSystem
) {
XCTAssertEqual(contents, fakeFileSystem.files[path]?.content, file: file, line: line)
XCTAssertEqual(contents, fs.files[path]?.content, file: file, line: line)
}
}