mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
✅ Test synchronous shell output
This commit is contained in:
@ -32,10 +32,10 @@ final class ExtensionEnumeratorTest: XCTestCase {
|
||||
func testCanParseFormulaeBasedOnSyntax() throws {
|
||||
let formulae = BrewTapFormulae.from(tap: "shivammathur/homebrew-extensions")
|
||||
|
||||
XCTAssertEqual(formulae["8.1"], Set(["xdebug"]))
|
||||
XCTAssertEqual(formulae["8.2"], Set(["xdebug"]))
|
||||
XCTAssertEqual(formulae["8.3"], Set(["xdebug"]))
|
||||
XCTAssertEqual(formulae["8.4"], Set(["xdebug"]))
|
||||
XCTAssertEqual(formulae["8.1"], [BrewPhpExtension(name: "xdebug", phpVersion: "8.1")])
|
||||
XCTAssertEqual(formulae["8.2"], [BrewPhpExtension(name: "xdebug", phpVersion: "8.2")])
|
||||
XCTAssertEqual(formulae["8.3"], [BrewPhpExtension(name: "xdebug", phpVersion: "8.3")])
|
||||
XCTAssertEqual(formulae["8.4"], [BrewPhpExtension(name: "xdebug", phpVersion: "8.4")])
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,14 @@ class RealShellTest: XCTestCase {
|
||||
XCTAssertTrue(output.out.contains("Copyright (c) The PHP Group"))
|
||||
}
|
||||
|
||||
func test_system_shell_can_be_used_synchronously() {
|
||||
XCTAssertTrue(Shell is RealShell)
|
||||
|
||||
let output = Shell.sync("php -v")
|
||||
|
||||
XCTAssertTrue(output.out.contains("Copyright (c) The PHP Group"))
|
||||
}
|
||||
|
||||
func test_system_shell_has_path() {
|
||||
let systemShell = Shell as! RealShell
|
||||
|
||||
|
@ -30,6 +30,35 @@ class TestableShellTest: XCTestCase {
|
||||
|
||||
XCTAssertEqual("Hello world\nGoodbye world", output.out)
|
||||
}
|
||||
|
||||
func test_fake_shell_synchronous_output() {
|
||||
let greeting = BatchFakeShellOutput(items: [
|
||||
.instant("Hello world\n"),
|
||||
.delayed(0.2, "Goodbye world")
|
||||
])
|
||||
|
||||
let output = greeting.syncOutput()
|
||||
|
||||
XCTAssertEqual("Hello world\nGoodbye world", output.out)
|
||||
}
|
||||
|
||||
func test_fake_shell_usage() {
|
||||
let expectedOutput = """
|
||||
PHP 8.3.0 (cli) (built: Nov 21 2023 14:40:35) (NTS)
|
||||
Copyright (c) The PHP Group
|
||||
Zend Engine v4.3.0, Copyright (c) Zend Technologies
|
||||
with Xdebug v3.2.2, Copyright (c) 2002-2023, by Derick Rethans
|
||||
with Zend OPcache v8.3.0, Copyright (c), by Zend Technologies
|
||||
"""
|
||||
|
||||
let shell = TestableShell(expectations: [
|
||||
"php -v": .instant(expectedOutput),
|
||||
"echo $PATH": .instant("/Users/user/bin:/opt/homebrew/bin")
|
||||
])
|
||||
|
||||
XCTAssertEqual(expectedOutput, shell.sync("php -v").out)
|
||||
XCTAssertEqual("/Users/user/bin:/opt/homebrew/bin", shell.sync("echo $PATH").out)
|
||||
}
|
||||
|
||||
func test_fake_shell_has_path() {
|
||||
ActiveShell.useTestable([:])
|
||||
|
Reference in New Issue
Block a user