cli icon indicating copy to clipboard operation
cli copied to clipboard

Create LocalProcess helper

Open danepowell opened this issue 3 years ago • 0 comments

https://github.com/acquia/cli/pull/713 resulted in a drop in code coverage because we added new methods to LocalMachineHelper that had to be mocked and therefore aren't tested. The problem is that LocalMachineHelper as a whole was already being mocked and there's no way to call just some of the original methods with Prophecy (https://github.com/phpspec/prophecy/issues/332#issuecomment-299428349).

Per the Prophecy maintainer, this is a sign that LocalMachineHelper violates SRP and I'm inclined to agree.

I propose refactoring LocalMachineHelper to move execute() and executeCommand() into a dedicated LocalProcess class. This could be mocked on its own and neatly encapsulates and isolates interaction with the local shell, which is 90% of what's being mocked today.

We could even extend this class later on to create helpers for specific oft-used processes like Git.

danepowell avatar Nov 03 '21 18:11 danepowell