aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/installer/binary_installer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/installer/binary_installer.rs')
-rw-r--r--crates/shirabe/src/installer/binary_installer.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/shirabe/src/installer/binary_installer.rs b/crates/shirabe/src/installer/binary_installer.rs
index a76f69e..ea73f6f 100644
--- a/crates/shirabe/src/installer/binary_installer.rs
+++ b/crates/shirabe/src/installer/binary_installer.rs
@@ -17,6 +17,34 @@ use crate::util::Platform;
use crate::util::ProcessExecutor;
use crate::util::Silencer;
+/// Seam over the BinaryInstaller methods reached through LibraryInstaller, so tests can inject a
+/// recording double. Composer has no PHP `BinaryInstallerInterface`; this exists only to allow the
+/// `LibraryInstaller` collaborator to be mocked the way PHPUnit mocks the concrete class.
+pub trait BinaryInstallerInterface: std::fmt::Debug {
+ fn install_binaries(
+ &mut self,
+ package: PackageInterfaceHandle,
+ install_path: &str,
+ warn_on_overwrite: bool,
+ );
+ fn remove_binaries(&mut self, package: PackageInterfaceHandle);
+}
+
+impl BinaryInstallerInterface for BinaryInstaller {
+ fn install_binaries(
+ &mut self,
+ package: PackageInterfaceHandle,
+ install_path: &str,
+ warn_on_overwrite: bool,
+ ) {
+ BinaryInstaller::install_binaries(self, package, install_path, warn_on_overwrite);
+ }
+
+ fn remove_binaries(&mut self, package: PackageInterfaceHandle) {
+ BinaryInstaller::remove_binaries(self, package);
+ }
+}
+
/// Utility to handle installation of package "bin"/binaries
#[derive(Debug)]
pub struct BinaryInstaller {