From d83c629a7ba6aa059d0be6efa6189d102ac49bf0 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sat, 13 Jan 2024 12:46:33 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Fix=20some=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PHP Monitor.xcodeproj/project.pbxproj | 6 ++++++ phpmon/Common/Testables/TestableConfiguration.swift | 3 +-- tests/unit/Parsers/ExtensionEnumeratorTest.swift | 8 ++++---- tests/unit/Parsers/HomebrewUpgradableTest.swift | 10 +++++++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 4d4d289..a1e6718 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -145,6 +145,9 @@ C42337A3281F19F000459A48 /* Xdebug.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42337A2281F19F000459A48 /* Xdebug.swift */; }; C42759672627662800093CAE /* NSMenuExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42759662627662800093CAE /* NSMenuExtension.swift */; }; C42759682627662800093CAE /* NSMenuExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42759662627662800093CAE /* NSMenuExtension.swift */; }; + C428311E2B52AD6F0009F9F1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C41C1B3A22B0098000E7CF16 /* Assets.xcassets */; }; + C428311F2B52AD6F0009F9F1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C41C1B3A22B0098000E7CF16 /* Assets.xcassets */; }; + C42831202B52AD700009F9F1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C41C1B3A22B0098000E7CF16 /* Assets.xcassets */; }; C4292D542B023F61004F0D2A /* PhpExtensionManagerWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4292D532B023F61004F0D2A /* PhpExtensionManagerWindowController.swift */; }; C4292D562B024006004F0D2A /* PhpExtensionManagerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4292D552B024006004F0D2A /* PhpExtensionManagerView.swift */; }; C4297F7A28970D59004C4630 /* WarningView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4297F7928970D59004C4630 /* WarningView.swift */; }; @@ -2412,6 +2415,7 @@ C4E2E85528FC256B003B070C /* brew-services-sudo.json in Resources */, C4E2E85928FC256B003B070C /* brew-services-normal.json in Resources */, C40934A8298EEB8700D25014 /* phpmon-dev.rb in Resources */, + C428311F2B52AD6F0009F9F1 /* Assets.xcassets in Resources */, C4E2E84F28FC22E4003B070C /* brew-formula.json in Resources */, C4E2E86228FC28A6003B070C /* brew-services.json in Resources */, ); @@ -2425,6 +2429,7 @@ C4E2E85628FC256B003B070C /* brew-services-sudo.json in Resources */, C4E2E85A28FC256B003B070C /* brew-services-normal.json in Resources */, C40934A9298EEB8700D25014 /* phpmon-dev.rb in Resources */, + C42831202B52AD700009F9F1 /* Assets.xcassets in Resources */, C4E2E85028FC22E4003B070C /* brew-formula.json in Resources */, C4E2E86128FC28A6003B070C /* brew-services.json in Resources */, ); @@ -2436,6 +2441,7 @@ files = ( C4551659297AED7D009B8466 /* valetrc.valid in Resources */, C4FC8D3E2A49816300FBBD16 /* Localizable.strings in Resources */, + C428311E2B52AD6F0009F9F1 /* Assets.xcassets in Resources */, 54FCFD27276C883F004CE748 /* SelectPreferenceView.xib in Resources */, 54FCFD2E276C8D67004CE748 /* HotkeyPreferenceView.xib in Resources */, C42CFB1827DFDFDC00862737 /* nginx-site-isolated.test in Resources */, diff --git a/phpmon/Common/Testables/TestableConfiguration.swift b/phpmon/Common/Testables/TestableConfiguration.swift index eeedf39..0b2d3b6 100644 --- a/phpmon/Common/Testables/TestableConfiguration.swift +++ b/phpmon/Common/Testables/TestableConfiguration.swift @@ -89,12 +89,11 @@ public struct TestableConfiguration: Codable { = .fake(.symlink, "/opt/homebrew/Cellar/php/\(version.short)/bin/php-config") self.commandOutput["/opt/homebrew/bin/php-config --version"] = version.long - self.commandOutput["/opt/homebrew/bin/php -r echo php_ini_scanned_files();"] = + self.commandOutput["/opt/homebrew/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'"] = """ /opt/homebrew/etc/php/\(version.short)/conf.d/php-memory-limits.ini, """ } else { - self.shellOutput["ls /opt/homebrew/opt | grep php@"] = BatchFakeShellOutput.instant( self.secondaryPhpVersions diff --git a/tests/unit/Parsers/ExtensionEnumeratorTest.swift b/tests/unit/Parsers/ExtensionEnumeratorTest.swift index 730f709..8ea8111 100644 --- a/tests/unit/Parsers/ExtensionEnumeratorTest.swift +++ b/tests/unit/Parsers/ExtensionEnumeratorTest.swift @@ -32,10 +32,10 @@ final class ExtensionEnumeratorTest: XCTestCase { func testCanParseFormulaeBasedOnSyntax() throws { let formulae = BrewTapFormulae.from(tap: "shivammathur/homebrew-extensions") - 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")]) + XCTAssertEqual(formulae["8.1"], [BrewPhpExtension(path: "/", name: "xdebug", phpVersion: "8.1")]) + XCTAssertEqual(formulae["8.2"], [BrewPhpExtension(path: "/", name: "xdebug", phpVersion: "8.2")]) + XCTAssertEqual(formulae["8.3"], [BrewPhpExtension(path: "/", name: "xdebug", phpVersion: "8.3")]) + XCTAssertEqual(formulae["8.4"], [BrewPhpExtension(path: "/", name: "xdebug", phpVersion: "8.4")]) } } diff --git a/tests/unit/Parsers/HomebrewUpgradableTest.swift b/tests/unit/Parsers/HomebrewUpgradableTest.swift index 160c92a..11d082e 100644 --- a/tests/unit/Parsers/HomebrewUpgradableTest.swift +++ b/tests/unit/Parsers/HomebrewUpgradableTest.swift @@ -17,7 +17,15 @@ class HomebrewUpgradableTest: XCTestCase { func test_upgradable_php_versions_can_be_parsed() async throws { ActiveShell.useTestable([ "/opt/homebrew/bin/brew update >/dev/null && /opt/homebrew/bin/brew outdated --json --formulae" - : .instant(try! String(contentsOf: Self.outdatedFileUrl)) + : .instant(try! String(contentsOf: Self.outdatedFileUrl)), + "/opt/homebrew/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'" + : .instant("/opt/homebrew/etc/php/8.2/conf.d/php-memory-limits.ini"), + "/opt/homebrew/opt/php@8.1.16/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'" + : .instant("/opt/homebrew/etc/php/8.1/conf.d/php-memory-limits.ini"), + "/opt/homebrew/opt/php@8.2.3/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'" + : .instant("/opt/homebrew/etc/php/8.2/conf.d/php-memory-limits.ini"), + "/opt/homebrew/opt/php@7.4.11/bin/php --ini | grep -E -o '(/[^ ]+\\.ini)'" + : .instant("/opt/homebrew/etc/php/7.4/conf.d/php-memory-limits.ini") ]) let env = PhpEnvironments.shared