8 class commandCase extends CommandUnishTestCase {
9 public function testInvoke() {
12 'drush_unit_invoke_init',
13 'drush_unit_invoke_validate',
14 'drush_unit_pre_unit_invoke',
15 'drush_unit_invoke_primary',
16 // Primary callback is not invoked when command specifies a 'callback'.
17 // 'drush_unit_invoke',
18 'drush_unit_post_unit_invoke',
19 'drush_unit_post_unit_invoke_rollback',
20 'drush_unit_pre_unit_invoke_rollback',
21 'drush_unit_invoke_validate_rollback',
25 'include' => dirname(__FILE__),
27 $this->drush('unit-invoke', array(), $options, NULL, NULL, self::EXIT_ERROR);
28 $called = $this->getOutputFromJSON();
29 $this->assertSame($expected, $called);
33 * Assert that minimum bootstrap phase is honored.
35 * Not testing dependency on a module since that requires an installed Drupal.
36 * Too slow for little benefit.
38 public function testRequirementBootstrapPhase() {
39 // Assure that core-cron fails when run outside of a Drupal site.
40 $return = $this->drush('core-cron', array(), array('quiet' => NULL), NULL, NULL, self::EXIT_ERROR);
44 * Assert that unknown options are caught and flagged as errors
46 public function testUnknownOptions() {
47 // Make sure an ordinary 'version' command works
48 $return = $this->drush('version', array(), array('pipe' => NULL));
49 // Add an unknown option --magic=1234 and insure it fails
50 $return = $this->drush('version', array(), array('pipe' => NULL, 'magic' => 1234), NULL, NULL, self::EXIT_ERROR);
51 // Finally, add in a hook that uses hook_drush_help_alter to allow the 'magic' option.
52 // We need to run 'drush cc drush' to clear the commandfile cache; otherwise, our include will not be found.
53 $include_path = dirname(__FILE__) . '/hooks/magic_help_alter';
54 $this->drush('version', array(), array('include' => $include_path, 'pipe' => NULL, 'magic' => '1234', 'strict' => NULL));
58 * Assert that errors are thrown for commands with missing callbacks.
60 public function testMissingCommandCallback() {
62 'include' => dirname(__FILE__), // Find unit.drush.inc commandfile.
63 //'show-invoke' => TRUE,
65 $this->drush('missing-callback', array(), $options, NULL, NULL, self::EXIT_ERROR);
69 * Assert that commands depending on unknown commandfiles are detected.
71 public function testMissingDrushDependency() {
73 'include' => dirname(__FILE__), // Find unit.drush.inc commandfile.
74 'backend' => NULL, // To obtain and parse the error log.
76 $this->drush('unit-drush-dependency', array(), $options, NULL, NULL, self::EXIT_ERROR);
77 $parsed = $this->parse_backend_output($this->getOutput());
78 $this->assertArrayHasKey("DRUSH_COMMANDFILE_DEPENDENCY_ERROR", $parsed['error_log']);
82 * Assert that commands in disabled/uninstalled modules throw an error.
84 public function testDisabledModule() {
85 $sites = $this->setUpDrupal(1, TRUE);
87 $root = $this->webroot();
93 $this->drush('pm-download', array('devel'), $options);
95 'backend' => NULL, // To obtain and parse the error log.
97 $this->drush('devel-reinstall', array(), $options, NULL, NULL, self::EXIT_ERROR);
98 $parsed = $this->parse_backend_output($this->getOutput());
99 $this->assertArrayHasKey("DRUSH_COMMAND_DEPENDENCY_ERROR", $parsed['error_log']);