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