mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-03-28 23:00:07 +01:00
♻️ All unit tests pass w/ DI container
This commit is contained in:
@@ -9,39 +9,36 @@
|
||||
import XCTest
|
||||
|
||||
final class InternalSwitcherTest: FeatureTestCase {
|
||||
|
||||
public func testDefaultPhpFpmPoolIsMoved() async {
|
||||
ActiveFileSystem.useTestable([
|
||||
let c = Container.fake(files: [
|
||||
"/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf": .fake(.text)
|
||||
])
|
||||
]), fs = c.filesystem as! TestableFileSystem
|
||||
|
||||
let outcome = await InternalSwitcher().disableDefaultPhpFpmPool("8.1")
|
||||
let outcome = await InternalSwitcher(container: c).disableDefaultPhpFpmPool("8.1")
|
||||
XCTAssertTrue(outcome)
|
||||
|
||||
assertFileSystemHas("/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf.disabled-by-phpmon")
|
||||
assertFileSystemDoesNotHave("/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf")
|
||||
assertFileSystemHas("/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf.disabled-by-phpmon", in: fs)
|
||||
assertFileSystemDoesNotHave("/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf", in: fs)
|
||||
}
|
||||
|
||||
public func testExistingDisabledByPhpMonFileIsRemoved() async {
|
||||
ActiveFileSystem.useTestable([
|
||||
let c = Container.fake(files: [
|
||||
"/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf": .fake(.text, "system generated"),
|
||||
"/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf.disabled-by-phpmon": .fake(.text, "phpmon generated")
|
||||
])
|
||||
]), fs = c.filesystem as! TestableFileSystem
|
||||
|
||||
assertFileHasContents(
|
||||
"/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf.disabled-by-phpmon",
|
||||
contents: "phpmon generated"
|
||||
)
|
||||
assertFileHasContents("/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf.disabled-by-phpmon",
|
||||
contents: "phpmon generated", in: fs)
|
||||
|
||||
let outcome = await InternalSwitcher().disableDefaultPhpFpmPool("8.1")
|
||||
let outcome = await InternalSwitcher(container: c).disableDefaultPhpFpmPool("8.1")
|
||||
XCTAssertTrue(outcome)
|
||||
|
||||
assertFileSystemHas("/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf.disabled-by-phpmon")
|
||||
assertFileSystemDoesNotHave("/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf")
|
||||
assertFileSystemHas("/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf.disabled-by-phpmon", in: fs)
|
||||
assertFileSystemDoesNotHave("/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf", in: fs)
|
||||
|
||||
assertFileHasContents(
|
||||
"/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf.disabled-by-phpmon",
|
||||
contents: "system generated"
|
||||
contents: "system generated", in: fs
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user