command) ? implode(' ', $process->command) : (string) $process->command; return is_string($process->input) && $process->input !== '' ? $command."\n".$process->input : $command; } /** * Process::fake() with command patterns that also match the SSH command batch on stdin. * Unmatched processes get an empty successful result. * * @param array $handlers pattern => result or closure, as for Process::fake() */ function fakeRemoteProcesses(array $handlers): void { Process::fake(function (PendingProcess $process) use ($handlers) { $script = remoteProcessScript($process); foreach ($handlers as $pattern => $handler) { if (is_numeric($pattern) || $pattern === '*' || Str::is($pattern, $script)) { return $handler instanceof Closure ? $handler($process) : $handler; } } return Process::result(); }); } /** * The output of LocalFileVolume::remoteFileStateCommand() when every checked path has the same state. */ function remoteFileStatesOutput(string $state, int $paths = 20): string { return implode("\n", array_map(fn (int $index) => "{$index}:{$state}", range(1, $paths))); }