public function testConnect() { $sshClient = new SshClient(new FakeSsh2Proxy($this)); $sshClient->setParameters($this->params); $sshClient->setHost('localhost'); $sshClient->connect(); $this->assertEquals('text', $sshClient->exec('text')); $this->assertEquals('test out text', $sshClient->getLastOutput()); $this->assertEquals('test err text', $sshClient->getLastError()); $this->assertEquals('test', $sshClient->getUser()); $this->assertEquals('23', $sshClient->getPort()); $this->assertEquals('localhost', $sshClient->getHost()); $sshClient->setHost('host'); $this->assertEquals('host', $sshClient->getHost()); }
public function getIdephixMock($targets, $targetName) { $this->output = fopen("php://memory", 'r+'); $output = new StreamOutput($this->output); $currentTarget = new Config($targets[$targetName]); $sshClient = new SshClient(new FakeSsh2Proxy($this)); $sshClient->setParameters($currentTarget->get('ssh_params')); $sshClient->setHost(current($currentTarget->get('hosts'))); $sshClient->connect(); $idx = $this->getMock('\\Idephix\\IdephixInterface'); $idx->sshClient = $sshClient; $idx->output = $output; $idx->expects($this->any())->method('getCurrentTarget')->will($this->returnValue($currentTarget)); $idx->expects($this->any())->method('getCurrentTargetName')->will($this->returnValue($targetName)); $idx->expects($this->any())->method('local')->will($this->returnCallback(function ($cmd) use($output) { $output->writeln('Local: ' . $cmd); })); $idx->expects($this->any())->method('remote')->will($this->returnCallback(function ($cmd) use($output) { $output->writeln('Remote: ' . $cmd); })); return $idx; }