siteAliasTest.php

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

Classes

Namesort descending Description
saCase

File

tests/siteAliasTest.php
View source
  1. <?php
  2. /*
  3. * @file
  4. * Tests for sitealias.inc
  5. *
  6. * @group base
  7. */
  8. class saCase extends Drush_CommandTestCase {
  9. /*
  10. * Covers the following responsibilities.
  11. * - Dispatching a Drush command that uses strict option handling
  12. * using a site alias that contains a generic option (e.g. 'site'
  13. * or 'env') that is not a recognized Drush option (maybe for
  14. * use in an init hook, etc.) places the generic option BEFORE
  15. * the command name.
  16. * - Dispatching a Drush command that uses strict option handling
  17. * using a site alias that contains a command-specific option
  18. * places said option AFTER the command name.
  19. */
  20. function testDispatchStrictOptions() {
  21. $aliasPath = UNISH_SANDBOX . '/aliases';
  22. mkdir($aliasPath);
  23. $aliasFile = $aliasPath . '/bar.aliases.drushrc.php';
  24. $aliasContents = <<<EOD
  25. <?php
  26. // Writtne by Unish. This file is safe to delete.
  27. \$aliases['test'] = array(
  28. 'remote-host' => 'fake.remote-host.com',
  29. 'remote-user' => 'www-admin',
  30. 'root' => '/fake/path/to/root',
  31. 'uri' => 'default',
  32. 'site' => 'stage',
  33. 'command-specific' => array(
  34. 'rsync' => array(
  35. 'delete' => TRUE,
  36. ),
  37. ),
  38. );
  39. EOD;
  40. file_put_contents($aliasFile, $aliasContents);
  41. $options = array(
  42. 'alias-path' => $aliasPath,
  43. 'include' => dirname(__FILE__), // Find unit.drush.inc commandfile.
  44. 'simulate' => TRUE,
  45. );
  46. $this->drush('core-rsync', array('/a', '/b'), $options, '@test');
  47. $output = $this->getOutput();
  48. $command_position = strpos($output, 'core-rsync');
  49. $special_option_position = strpos($output, '--site=stage');
  50. $command_specific_position = strpos($output, '--delete');
  51. $this->assertTrue($command_position !== FALSE);
  52. $this->assertTrue($special_option_position !== FALSE);
  53. $this->assertTrue($command_specific_position !== FALSE);
  54. $this->assertTrue($command_position > $special_option_position);
  55. $this->assertTrue($command_position < $command_specific_position);
  56. }
  57. /*
  58. * Assure that site lists work as expected.
  59. * @todo Use --backend for structured return data. Depends on http://drupal.org/node/1043922
  60. */
  61. public function testSAList() {
  62. $sites = $this->setUpDrupal(2);
  63. $subdirs = array_keys($sites);
  64. $eval = 'print "bon";';
  65. $options = array(
  66. 'yes' => NULL,
  67. 'verbose' => NULL,
  68. 'root' => $this->webroot(),
  69. );
  70. foreach ($subdirs as $dir) {
  71. $dirs[] = "#$dir";
  72. }
  73. $this->drush('php-eval', array($eval), $options, implode(',', $dirs));
  74. $output = $this->getOutputAsList();
  75. $expected = "You are about to execute 'php-eval print \"bon\";' non-interactively (--yes forced) on all of the following targets:
  76. #dev
  77. #stage
  78. Continue? (y/n): y
  79. #stage >> bon
  80. #dev >> bon";
  81. $this->assertEquals($expected, implode("\n", $output));
  82. }
  83. }