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

Classes

Namesort descending Description
siteSshCase

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 %s@%s);', self::escapeshellarg('user'), self::escapeshellarg('server'));
  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. 'simulate' => NULL,
  32. );
  33. $this->drush('ssh', array('date'), $options, 'user@server/path/to/drupal#sitename', NULL, self::EXIT_SUCCESS, '2>&1');
  34. $output = $this->getOutput();
  35. $expected = sprintf('Calling proc_open(ssh -o PasswordAuthentication=no %s@%s %s);', self::escapeshellarg('user'), self::escapeshellarg('server'), self::escapeshellarg('date'));
  36. $this->assertEquals($expected, $output);
  37. }
  38. /**
  39. * Test drush ssh with multiple arguments (preferred form).
  40. */
  41. public function testSshMultipleArgs() {
  42. $options = array(
  43. 'simulate' => NULL,
  44. );
  45. $this->drush('ssh', array('ls', '/path1', '/path2'), $options, 'user@server/path/to/drupal#sitename', NULL, self::EXIT_SUCCESS, '2>&1');
  46. $output = $this->getOutput();
  47. $expected = sprintf('Calling proc_open(ssh -o PasswordAuthentication=no %s@%s \'ls /path1 /path2\');', self::escapeshellarg('user'), self::escapeshellarg('server'));
  48. $this->assertEquals($expected, $output);
  49. }
  50. /**
  51. * Test drush ssh with multiple arguments (legacy form).
  52. */
  53. public function testSshMultipleArgsLegacy() {
  54. $options = array(
  55. 'simulate' => NULL,
  56. );
  57. $this->drush('ssh', array('ls /path1 /path2'), $options, 'user@server/path/to/drupal#sitename', NULL, self::EXIT_SUCCESS, '2>&1');
  58. $output = $this->getOutput();
  59. $expected = sprintf('Calling proc_open(ssh -o PasswordAuthentication=no %s@%s \'ls /path1 /path2\');', self::escapeshellarg('user'), self::escapeshellarg('server'));
  60. $this->assertEquals($expected, $output);
  61. }
  62. }