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

Classes

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

File

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