siteSshTest.php

  1. 8.0.x tests/siteSshTest.php
  2. 6.x tests/siteSshTest.php
  3. 7.x tests/siteSshTest.php
  4. 5.x tests/siteSshTest.php
  5. master tests/siteSshTest.php

Tests for ssh.drush.inc

@group commands

Namespace

Unish

Classes

Namesort descending Description
siteSshCase @file Tests for ssh.drush.inc

File

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