diff --git a/test/unit/SelfManage/BuildTools/BinaryBuildToolFinderTest.php b/test/unit/SelfManage/BuildTools/BinaryBuildToolFinderTest.php new file mode 100644 index 0000000..ac7c27d --- /dev/null +++ b/test/unit/SelfManage/BuildTools/BinaryBuildToolFinderTest.php @@ -0,0 +1,74 @@ +check()); + } + + public function testCheckFindsTool(): void + { + self::assertTrue((new BinaryBuildToolFinder('echo', []))->check()); + } + + public function testPackageNameIsNullWhenNoPackageConfiguredForPackageManager(): void + { + self::assertNull( + (new BinaryBuildToolFinder('a', [])) + ->packageNameFor( + PackageManager::Test, + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null), + ), + ); + } + + public function testPackageNameIsNullWhenPackageConfiguredForPackageManagerIsNull(): void + { + self::assertNull( + (new BinaryBuildToolFinder('a', [PackageManager::Test->value => null])) + ->packageNameFor( + PackageManager::Test, + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null), + ), + ); + } + + public function testPackageNameIsReturnedWhenPackageConfiguredForPackageManager(): void + { + self::assertSame( + 'the-package', + (new BinaryBuildToolFinder('a', [PackageManager::Test->value => 'the-package'])) + ->packageNameFor( + PackageManager::Test, + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null), + ), + ); + } + + public function testPackageNameIsReturnedWithFormattingWhenPackageConfiguredForPackageManager(): void + { + $phpBinary = PhpBinaryPath::fromCurrentProcess(); + + self::assertSame( + 'php' . $phpBinary->majorVersion() . $phpBinary->minorVersion() . '-dev', + (new BinaryBuildToolFinder('a', [PackageManager::Test->value => 'php{major}{minor}-dev'])) + ->packageNameFor( + PackageManager::Test, + TargetPlatform::fromPhpBinaryPath($phpBinary, null), + ), + ); + } +} diff --git a/test/unit/SelfManage/BuildTools/PackageManagerTest.php b/test/unit/SelfManage/BuildTools/PackageManagerTest.php new file mode 100644 index 0000000..53a4092 --- /dev/null +++ b/test/unit/SelfManage/BuildTools/PackageManagerTest.php @@ -0,0 +1,29 @@ +installCommand(['a', 'b']), + ); + self::assertSame( + ['apt-get', 'install', '-y', '--no-install-recommends', '--no-install-suggests', 'a', 'b'], + PackageManager::Apt->installCommand(['a', 'b']), + ); + self::assertSame( + ['apk', 'add', '--no-cache', 'a', 'b'], + PackageManager::Apk->installCommand(['a', 'b']), + ); + } +}