7 * Tests for ssh.drush.inc
11 class SiteSshCase extends CommandUnishTestCase
15 * Test drush ssh --simulate. No additional bash passed.
17 public function testInteractive()
19 if ($this->isWindows()) {
20 $this->markTestSkipped('ssh command not currently available on Windows.');
26 $this->drush('ssh', [], $options, 'user@server/path/to/drupal#sitename', null, self::EXIT_SUCCESS, '2>&1');
27 $output = $this->getOutput();
28 $expected = sprintf('Calling proc_open(ssh -o PasswordAuthentication=no -t %s@%s %s);', self::escapeshellarg('user'), self::escapeshellarg('server'), "'cd /path/to/drupal && bash -l'");
29 $this->assertEquals($expected, $output);
33 * Test drush ssh --simulate 'date'.
34 * @todo Run over a site list. drush_sitealias_get_record() currently cannot
35 * handle a site list comprised of longhand site specifications.
37 public function testNonInteractive()
43 $this->drush('ssh', ['date'], $options, 'user@server/path/to/drupal#sitename', null, self::EXIT_SUCCESS, '2>&1');
44 $output = $this->getOutput();
45 $expected = sprintf('Calling proc_open(ssh -o PasswordAuthentication=no %s@%s %s);', self::escapeshellarg('user'), self::escapeshellarg('server'), self::escapeshellarg('date'));
46 $this->assertEquals($expected, $output);
50 * Test drush ssh with multiple arguments (preferred form).
52 public function testSshMultipleArgs()
58 $this->drush('ssh', ['ls', '/path1', '/path2'], $options, 'user@server/path/to/drupal#sitename', null, self::EXIT_SUCCESS, '2>&1');
59 $output = $this->getOutput();
60 $expected = sprintf('Calling proc_open(ssh -o PasswordAuthentication=no %s@%s %s);', self::escapeshellarg('user'), self::escapeshellarg('server'), self::escapeshellarg('ls /path1 /path2'));
61 $this->assertEquals($expected, $output);
65 * Test drush ssh with multiple arguments (legacy form).
67 public function testSshMultipleArgsLegacy()
73 $this->drush('ssh', ['ls /path1 /path2'], $options, 'user@server/path/to/drupal#sitename', null, self::EXIT_SUCCESS, '2>&1');
74 $output = $this->getOutput();
75 $expected = sprintf('Calling proc_open(ssh -o PasswordAuthentication=no %s@%s %s);', self::escapeshellarg('user'), self::escapeshellarg('server'), self::escapeshellarg('ls /path1 /path2'));
76 $this->assertEquals($expected, $output);