public function it_gets_servers_for_each_step_and_sets_commands(LoggerInterface $logger, DeployStep $step1, DeployStep $step2, Local $server1, Local $server2) { $server1->setCommands(['echo "step 1: command 1"', 'echo "step 1: command 2"'])->shouldBeCalled(); $server2->setCommands(['echo "step 1: command 1"', 'echo "step 1: command 2"'])->shouldBeCalled(); $server1->setCommands(['echo "step 2: command 1"', 'echo "step 2: command 2"'])->shouldBeCalled(); $server1->setLogger($logger)->shouldBeCalled(); $server2->setLogger($logger)->shouldBeCalled(); $step1->getServers()->willReturn([$server1, $server2]); $step2->getServers()->willReturn([$server1]); $this->getServersForStep($step1)->shouldReturn([$server1, $server2]); $this->getServersForStep($step2)->shouldReturn([$server1]); }
/** * @param string $title * @param array $config * * @return AbstractServer */ private function createServerFromConfig($title, array $config) { $path = $config['path']; switch (true) { case isset($config['user']): case isset($config['host']): $server = new Ssh($title, $path, $config['host'], $config['user']); break; default: $server = new Local($title, $path); $server->setHostname($title); break; } return $server; }