18e58d5e22d4878d895651ea3470948ae5ce643d
[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   /**
15    * Test drush ssh --simulate. No additional bash passed.
16    */
17     public function testInteractive()
18     {
19         if ($this->isWindows()) {
20             $this->markTestSkipped('ssh command not currently available on Windows.');
21         }
22
23         $options = [
24         'simulate' => null,
25         ];
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);
30     }
31
32   /**
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.
36    */
37     public function testNonInteractive()
38     {
39         $options = [
40         'cd' => '0',
41         'simulate' => null,
42         ];
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);
47     }
48
49   /**
50   * Test drush ssh with multiple arguments (preferred form).
51   */
52     public function testSshMultipleArgs()
53     {
54         $options = [
55         'cd' => '0',
56         'simulate' => null,
57         ];
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);
62     }
63
64   /**
65    * Test drush ssh with multiple arguments (legacy form).
66    */
67     public function testSshMultipleArgsLegacy()
68     {
69         $options = [
70         'cd' => '0',
71          'simulate' => null,
72         ];
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);
77     }
78 }