forked from drush-ops/drush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsiteSshTest.php
73 lines (66 loc) · 2.61 KB
/
siteSshTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace Unish;
/**
* @file
* Tests for ssh.drush.inc
*
* @group commands
*/
class siteSshCase extends CommandUnishTestCase {
/**
* Test drush ssh --simulate. No additional bash passed.
*/
public function testInteractive() {
if ($this->is_windows()) {
$this->markTestSkipped('ssh command not currently available on Windows.');
}
$options = array(
'simulate' => NULL,
);
$this->drush('ssh', array(), $options, 'user@server/path/to/drupal#sitename', NULL, self::EXIT_SUCCESS, '2>&1');
$output = $this->getOutput();
$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'");
$this->assertEquals($expected, $output);
}
/**
* Test drush ssh --simulate 'date'.
* @todo Run over a site list. drush_sitealias_get_record() currently cannot
* handle a site list comprised of longhand site specifications.
*/
public function testNonInteractive() {
$options = array(
'cd' => '0',
'simulate' => NULL,
);
$this->drush('ssh', array('date'), $options, 'user@server/path/to/drupal#sitename', NULL, self::EXIT_SUCCESS, '2>&1');
$output = $this->getOutput();
$expected = sprintf('Calling proc_open(ssh -o PasswordAuthentication=no %s@%s %s);', self::escapeshellarg('user'), self::escapeshellarg('server'), self::escapeshellarg('date'));
$this->assertEquals($expected, $output);
}
/**
* Test drush ssh with multiple arguments (preferred form).
*/
public function testSshMultipleArgs() {
$options = array(
'cd' => '0',
'simulate' => NULL,
);
$this->drush('ssh', array('ls', '/path1', '/path2'), $options, 'user@server/path/to/drupal#sitename', NULL, self::EXIT_SUCCESS, '2>&1');
$output = $this->getOutput();
$expected = sprintf('Calling proc_open(ssh -o PasswordAuthentication=no %s@%s \'ls /path1 /path2\');', self::escapeshellarg('user'), self::escapeshellarg('server'));
$this->assertEquals($expected, $output);
}
/**
* Test drush ssh with multiple arguments (legacy form).
*/
public function testSshMultipleArgsLegacy() {
$options = array(
'cd' => '0',
'simulate' => NULL,
);
$this->drush('ssh', array('ls /path1 /path2'), $options, 'user@server/path/to/drupal#sitename', NULL, self::EXIT_SUCCESS, '2>&1');
$output = $this->getOutput();
$expected = sprintf('Calling proc_open(ssh -o PasswordAuthentication=no %s@%s \'ls /path1 /path2\');', self::escapeshellarg('user'), self::escapeshellarg('server'));
$this->assertEquals($expected, $output);
}
}