coreTest.php

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

Classes

Namesort descending Description
coreCase

File

tests/coreTest.php
View source
  1. <?php
  2. /*
  3. * @file
  4. * Tests for core commands.
  5. */
  6. class coreCase extends Drush_TestCase {
  7. /*
  8. * Test standalone php-script scripts. Assure that script args and options work.
  9. */
  10. public function testStandaloneScript() {
  11. $this->drush('version', array('drush_version'), array('pipe' => NULL));
  12. $standard = $this->getOutput();
  13. // Write out a hellounish.script into the sandbox. The correct /path/to/drush
  14. // is in the shebang line.
  15. $filename = 'hellounish.script';
  16. $data = '#!/usr/bin/env [PATH-TO-DRUSH]
  17. $arg = drush_shift();
  18. drush_invoke("version", $arg);
  19. ';
  20. $data = str_replace('[PATH-TO-DRUSH]', UNISH_DRUSH, $data);
  21. $script = UNISH_SANDBOX . '/' . $filename;
  22. file_put_contents($script, $data);
  23. chmod($script, 0755);
  24. $this->execute("$script drush_version --pipe");
  25. $standalone = $this->getOutput();
  26. $this->assertEquals($standard, $standalone);
  27. }
  28. function testDrupalDirectory() {
  29. $this->setUpDrupal('dev', TRUE);
  30. $root = $this->sites['dev']['root'];
  31. $options = array(
  32. 'root' => $root,
  33. 'uri' => 'dev',
  34. 'verbose' => NULL,
  35. 'yes' => NULL,
  36. );
  37. $this->drush('pm-download', array('devel-7.x-1.0'), $options);
  38. $this->drush('pm-enable', array('menu', 'devel'), $options);
  39. $this->drush('drupal-directory', array('devel'), $options);
  40. $output = $this->getOutput();
  41. $this->assertEquals($root . '/sites/all/modules/devel', $output);
  42. $this->drush('drupal-directory', array('%files'), $options);
  43. $output = $this->getOutput();
  44. $this->assertEquals($root . '/sites/dev/files', $output);
  45. $this->drush('drupal-directory', array('%modules'), $options);
  46. $output = $this->getOutput();
  47. $this->assertEquals($root . '/sites/all/modules', $output);
  48. }
  49. function testCoreCLI() {
  50. /*
  51. * @todo
  52. * - BASHRC_PATH. Same file cleanup woes as contextTest.
  53. * - DRUSH_CLI
  54. * - INITIAL_SITE
  55. * - PS1. Hard to test in non interactive session?
  56. * - on
  57. * - use
  58. * - cd, cdd, lsd
  59. * - override, contextual
  60. */
  61. // Exercise core-cli's interactive mode.
  62. // Include unit.drush.inc commandfile.
  63. $options = array(
  64. 'include' => dirname(__FILE__),
  65. );
  66. // These commands will throw a failure if they return non-zero exit code.
  67. // Assure that we create a bash function for command names.
  68. $options['unit-extra'] = 'core-status;exit';
  69. $this->drush('core-cli', array(), $options);
  70. // Assure that we create a bash function for command aliases.
  71. $options['unit-extra'] = 'st;exit';
  72. $this->drush('core-cli', array(), $options);
  73. // Assure that we create a bash alias for site aliases.
  74. // First, write an alias file to the sandbox.
  75. $path = UNISH_SANDBOX . '/aliases.drushrc.php';
  76. $aliases['cliAlias'] = array(
  77. 'root' => $this->sites['dev']['root'],
  78. 'uri' => 'dev',
  79. );
  80. $contents = $this->file_aliases($aliases);
  81. $return = file_put_contents($path, $contents);
  82. // Append a bash command which starts with alias name (i.e. @cliAlias).
  83. $options['unit-extra'] = sprintf('@cliAlias core-status --alias-path=%s;exit', UNISH_SANDBOX);
  84. $options['alias-path'] = UNISH_SANDBOX;
  85. $this->drush('core-cli', array(), $options);
  86. // $this->markTestIncomplete('In progress below.');
  87. // Exercise core-cli's non-interactive mode.
  88. // We spawn our own bash session using the --pipe feature of core-cli.
  89. //$options = array(
  90. // 'pipe' => NULL,
  91. // 'alias-path' => UNISH_SANDBOX,
  92. //);
  93. //$this->drush('core-cli', array(), $options);
  94. //$bashrc_data = $this->getOutput();
  95. //$bashrc_file = UNISH_SANDBOX . '/.bashrc';
  96. //$extra = 'cd @cliAlias;exit;';
  97. //$return = file_put_contents($bashrc_file, $bashrc_data . $extra);
  98. //$this->setUpDrupal('dev', FALSE);
  99. //$this->execute('bash --rcfile ' . $bashrc_file);
  100. //$output = $this->getOutput();
  101. //$this->assertContains('????', $output);
  102. }
  103. }