mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-14 06:40:06 +02:00
🏗 WIP: Much improved Shell protocol
This commit is contained in:
44
phpmon-tests/Next/FakeShellTest.swift
Normal file
44
phpmon-tests/Next/FakeShellTest.swift
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// 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_we_can_predefine_responses_for_dummy_shell() {
|
||||
let expectedPhpOutput = """
|
||||
PHP 8.1.10 (cli) (built: Sep 3 2022 12:09:27) (NTS)
|
||||
Copyright (c) The PHP Group
|
||||
Zend Engine v4.1.10, Copyright (c) Zend Technologies
|
||||
with Zend OPcache v8.1.10, Copyright (c), by Zend Technologies
|
||||
with Xdebug v3.1.4, Copyright (c) 2002-2022, by Derick Rethans
|
||||
"""
|
||||
|
||||
let slowVersionOutput = FakeTerminalOutput(
|
||||
output: expectedPhpOutput,
|
||||
duration: 1000,
|
||||
isError: false
|
||||
)
|
||||
|
||||
ActiveShell.useTestable([
|
||||
"php -v": expectedPhpOutput,
|
||||
"php --version": slowVersionOutput
|
||||
])
|
||||
|
||||
XCTAssertTrue(Shell is TestableShell)
|
||||
|
||||
XCTAssertEqual(expectedPhpOutput, Shell.sync("php -v").output)
|
||||
|
||||
XCTAssertEqual(expectedPhpOutput, Shell.sync("php --version").output)
|
||||
}
|
||||
|
||||
func test_unrecognized_commands_output_stderr() {
|
||||
ActiveShell.useTestable([:])
|
||||
|
||||
XCTAssertEqual("Unexpected Command", Shell.sync("unrecognized command").output)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user