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. * @group commands
  7. */
  8. class coreCase extends Drush_CommandTestCase {
  9. /**
  10. * Test to see if rsync @site:%files calculates the %files path correctly.
  11. * This tests the non-optimized code path in drush_sitealias_resolve_path_references.
  12. */
  13. function testRsyncPercentFiles() {
  14. $this->setUpDrupal(1, TRUE);
  15. $root = $this->webroot();
  16. $site = key($this->sites);
  17. $options = array(
  18. 'root' => $root,
  19. 'uri' => key($this->sites),
  20. 'simulate' => NULL,
  21. 'include-conf' => NULL,
  22. 'include-vcs' => NULL,
  23. 'yes' => NULL,
  24. 'invoke' => NULL, // invoke from script: do not verify options
  25. );
  26. $this->drush('core-rsync', array("@$site:%files", "/tmp"), $options, NULL, NULL, self::EXIT_SUCCESS, '2>&1;');
  27. $output = $this->getOutput();
  28. $level = $this->log_level();
  29. $pattern = in_array($level, array('verbose', 'debug')) ? "Calling system(rsync -e 'ssh ' -akzv --stats --progress --yes --invoke %s /tmp);" : "Calling system(rsync -e 'ssh ' -akz --yes --invoke %s /tmp);";
  30. $expected = sprintf($pattern, UNISH_SANDBOX . "/web/sites/$site/files");
  31. $this->assertEquals($expected, $output);
  32. }
  33. /**
  34. * Test to see if the optimized code path in drush_sitealias_resolve_path_references
  35. * that avoids a call to backend invoke when evaluating %files works.
  36. */
  37. function testPercentFilesOptimization() {
  38. $this->setUpDrupal(1, TRUE);
  39. $root = $this->webroot();
  40. $site = key($this->sites);
  41. $options = array(
  42. 'root' => $root,
  43. 'uri' => key($this->sites),
  44. 'simulate' => NULL,
  45. 'include-conf' => NULL,
  46. 'include-vcs' => NULL,
  47. 'yes' => NULL,
  48. 'invoke' => NULL, // invoke from script: do not verify options
  49. );
  50. $php = '$a=drush_sitealias_get_record("@' . $site . '"); drush_sitealias_resolve_path_references($a, "%files"); print_r($a["path-aliases"]["%files"]);';
  51. $this->drush('ev', array($php), $options);
  52. $output = $this->getOutput();
  53. $expected = "sites/dev/files";
  54. $this->assertEquals($expected, $output);
  55. }
  56. /*
  57. * Test standalone php-script scripts. Assure that script args and options work.
  58. */
  59. public function testStandaloneScript() {
  60. if ($this->is_windows()) {
  61. $this->markTestSkipped('Standalone scripts not currently available on Windows.');
  62. }
  63. $this->drush('version', array('drush_version'), array('pipe' => NULL));
  64. $standard = $this->getOutput();
  65. // Write out a hellounish.script into the sandbox. The correct /path/to/drush
  66. // is in the shebang line.
  67. $filename = 'hellounish.script';
  68. $data = '#!/usr/bin/env [PATH-TO-DRUSH]
  69. $arg = drush_shift();
  70. drush_invoke("version", $arg);
  71. ';
  72. $data = str_replace('[PATH-TO-DRUSH]', UNISH_DRUSH, $data);
  73. $script = UNISH_SANDBOX . '/' . $filename;
  74. file_put_contents($script, $data);
  75. chmod($script, 0755);
  76. $this->execute("$script drush_version --pipe");
  77. $standalone = $this->getOutput();
  78. $this->assertEquals($standard, $standalone);
  79. }
  80. function testDrupalDirectory() {
  81. $this->setUpDrupal(1, TRUE);
  82. $root = $this->webroot();
  83. $options = array(
  84. 'root' => $root,
  85. 'uri' => key($this->sites),
  86. 'verbose' => NULL,
  87. 'skip' => NULL, // No FirePHP
  88. 'yes' => NULL,
  89. 'cache' => NULL,
  90. 'invoke' => NULL, // invoke from script: do not verify options
  91. );
  92. $this->drush('pm-download', array('devel'), $options);
  93. $this->drush('pm-enable', array('devel', 'menu'), $options);
  94. $this->drush('drupal-directory', array('devel'), $options);
  95. $output = $this->getOutput();
  96. $this->assertEquals($root . '/sites/all/modules/devel', $output);
  97. $this->drush('drupal-directory', array('%files'), $options);
  98. $output = $this->getOutput();
  99. $this->assertEquals($root . '/sites/dev/files', $output);
  100. $this->drush('drupal-directory', array('%modules'), $options);
  101. $output = $this->getOutput();
  102. $this->assertEquals($root . '/sites/all/modules', $output);
  103. }
  104. function testCoreRequirements() {
  105. $this->setUpDrupal(1, TRUE);
  106. $root = $this->webroot();
  107. $options = array(
  108. 'root' => $root,
  109. 'uri' => key($this->sites),
  110. 'pipe' => NULL,
  111. 'ignore' => 'cron,http requests,update_core', // no network access when running in tests, so ignore these
  112. 'invoke' => NULL, // invoke from script: do not verify options
  113. );
  114. // Verify that there are no severity 2 items in the status report
  115. $this->drush('core-requirements', array(), $options + array('severity' => '2'));
  116. $output = $this->getOutput();
  117. $this->assertEquals('', $output);
  118. $this->drush('core-requirements', array(), $options);
  119. $output = $this->getOutput();
  120. $expected="database_system: -1
  121. database_system_version: -1
  122. drupal: -1
  123. file system: -1
  124. install_profile: -1
  125. node_access: -1
  126. php: -1
  127. php_extensions: -1
  128. php_memory_limit: -1
  129. php_register_globals: -1
  130. settings.php: -1
  131. unicode: 0
  132. update: 0
  133. update access: -1
  134. update status: -1
  135. webserver: -1";
  136. $this->assertEquals($expected, trim($output));
  137. }
  138. }