2323use FastForward \DevTools \Console \Command \Traits \LogsCommandResults ;
2424use FastForward \DevTools \Config \ComposerDependencyAnalyserConfig ;
2525use FastForward \DevTools \Path \DevToolsPathResolver ;
26+ use FastForward \DevTools \Path \WorkingProjectPathResolver ;
2627use FastForward \DevTools \Process \ProcessBuilder ;
2728use FastForward \DevTools \Process \ProcessBuilderInterface ;
2829use FastForward \DevTools \Process \ProcessQueueInterface ;
4445
4546#[CoversClass(DependenciesCommand::class)]
4647#[UsesClass(DevToolsPathResolver::class)]
48+ #[UsesClass(WorkingProjectPathResolver::class)]
4749#[UsesClass(ProcessBuilder::class)]
4850#[UsesTrait(LogsCommandResults::class)]
4951final class DependenciesCommandTest extends TestCase
@@ -225,7 +227,9 @@ private function assertComposerDependencyAnalyserEnvironment(string $expectedVal
225227 $ processBuilder ->withArgument ('--config ' , '/app/composer-dependency-analyser.php ' )
226228 ->willReturn ($ configuredProcessBuilder ->reveal ())
227229 ->shouldBeCalledOnce ();
228- $ configuredProcessBuilder ->build ('vendor/bin/composer-dependency-analyser ' )
230+ $ configuredProcessBuilder ->build (
231+ DevToolsPathResolver::getPreferredToolBinaryPath ('composer-dependency-analyser ' )
232+ )
229233 ->willReturn ($ process ->reveal ())
230234 ->shouldBeCalledOnce ();
231235 $ process ->setEnv ([
@@ -236,4 +240,75 @@ private function assertComposerDependencyAnalyserEnvironment(string $expectedVal
236240 (new ReflectionMethod ($ command , 'getComposerDependencyAnalyserCommand ' ))
237241 ->invoke ($ command , $ this ->input ->reveal ());
238242 }
243+
244+ /**
245+ * @return void
246+ */
247+ #[Test]
248+ public function jackBreakpointProcessWillUseTheResolvedJackBinary (): void
249+ {
250+ $ processBuilder = $ this ->prophesize (ProcessBuilderInterface::class);
251+ $ process = $ this ->prophesize (Process::class);
252+ $ command = new DependenciesCommand (
253+ $ processBuilder ->reveal (),
254+ $ this ->processQueue ->reveal (),
255+ $ this ->fileLocator ->reveal (),
256+ $ this ->logger ->reveal (),
257+ );
258+
259+ $ processBuilder ->build (DevToolsPathResolver::getPreferredToolBinaryPath ('jack ' ) . ' breakpoint --limit 5 ' )
260+ ->willReturn ($ process ->reveal ())
261+ ->shouldBeCalledOnce ();
262+
263+ (new ReflectionMethod ($ command , 'getJackBreakpointCommand ' ))
264+ ->invoke ($ command , $ this ->input ->reveal (), 5 );
265+ }
266+
267+ /**
268+ * @return void
269+ */
270+ #[Test]
271+ public function openVersionsProcessWillUseTheResolvedJackBinary (): void
272+ {
273+ $ processBuilder = $ this ->prophesize (ProcessBuilderInterface::class);
274+ $ process = $ this ->prophesize (Process::class);
275+ $ command = new DependenciesCommand (
276+ $ processBuilder ->reveal (),
277+ $ this ->processQueue ->reveal (),
278+ $ this ->fileLocator ->reveal (),
279+ $ this ->logger ->reveal (),
280+ );
281+
282+ $ processBuilder ->build (DevToolsPathResolver::getPreferredToolBinaryPath ('jack ' ) . ' open-versions --dry-run ' )
283+ ->willReturn ($ process ->reveal ())
284+ ->shouldBeCalledOnce ();
285+
286+ (new ReflectionMethod ($ command , 'getOpenVersionsCommand ' ))
287+ ->invoke ($ command , $ this ->input ->reveal ());
288+ }
289+
290+ /**
291+ * @return void
292+ */
293+ #[Test]
294+ public function raiseToInstalledProcessWillUseTheResolvedJackBinary (): void
295+ {
296+ $ processBuilder = $ this ->prophesize (ProcessBuilderInterface::class);
297+ $ process = $ this ->prophesize (Process::class);
298+ $ command = new DependenciesCommand (
299+ $ processBuilder ->reveal (),
300+ $ this ->processQueue ->reveal (),
301+ $ this ->fileLocator ->reveal (),
302+ $ this ->logger ->reveal (),
303+ );
304+
305+ $ processBuilder ->build (
306+ DevToolsPathResolver::getPreferredToolBinaryPath ('jack ' ) . ' raise-to-installed --dry-run '
307+ )
308+ ->willReturn ($ process ->reveal ())
309+ ->shouldBeCalledOnce ();
310+
311+ (new ReflectionMethod ($ command , 'getRaiseToInstalledCommand ' ))
312+ ->invoke ($ command , $ this ->input ->reveal ());
313+ }
239314}
0 commit comments