class commandCase

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

Hierarchy

Expanded class hierarchy of commandCase

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
commandCase::testGetCommands public function
commandCase::testInvoke public function
commandCase::testRequirementBootstrapPhase public function
Drush_TestCase::create_node_types_php function
Drush_TestCase::drush function Invoke drush in via execute().
Drush_TestCase::drush_major_version function
Drush_TestCase::escapeshellarg public static function
Drush_TestCase::execute function Actually runs the command. Does not trap the error stream output as this need PHP 4.3+.
Drush_TestCase::EXIT_ERROR constant
Drush_TestCase::EXIT_SUCCESS constant
Drush_TestCase::file_aliases function
Drush_TestCase::file_delete_recursive function Same code as drush_delete_dir().
Drush_TestCase::getOutput function Accessor for the last output.
Drush_TestCase::getOutputAsList function Accessor for the last output.
Drush_TestCase::is_windows public static function
Drush_TestCase::setUpBeforeClass public static function Assure that each class starts with an empty sandbox directory and a clean environment - http://drupal.org/node/1103568.
Drush_TestCase::setUpDrupal function
Drush_TestCase::tearDownAfterClass public static function Runs after each test case. Remove sandbox directory.
Drush_TestCase::_escapeshellarg_windows public static function
Drush_TestCase::__construct function

File

tests/commandTest.php, line 3

View source
class commandCase extends Drush_TestCase {
  public function testInvoke() {
    $expected = array(
      'unit_drush_init',
      'drush_unit_invoke_init',
      'drush_unit_invoke_validate',
      'drush_unit_pre_unit_invoke',
      'drush_unit_invoke',
      'drush_unit_post_unit_invoke',
      'drush_unit_post_unit_invoke_rollback',
      'drush_unit_pre_unit_invoke_rollback',
      'drush_unit_invoke_validate_rollback',
    );

    // We expect a return code of 1 so just call execute() directly.
    $exec = sprintf('%s unit-invoke --include=%s', UNISH_DRUSH, self::escapeshellarg(dirname(__FILE__)));
    $this->execute($exec, self::EXIT_ERROR);
    $called = json_decode($this->getOutput());
    $this->assertSame($expected, $called);
  }


  /*
   * Assert that $command has interesting properties. Reference command by
   * it's alias (dl) to assure that those aliases are built as expected.
   */
  public function testGetCommands() {
    $eval = '$commands = drush_get_commands();';
    $eval .= 'print json_encode($commands[\'dl\'])';
    $this->drush('php-eval', array($eval));
    $command = json_decode($this->getOutput());

    $this->assertEquals('dl', current($command->aliases));
    $this->assertEquals('download', current($command->{'deprecated-aliases'}));
    $this->assertObjectHasAttribute('version_control', $command->engines);
    $this->assertObjectHasAttribute('package_handler', $command->engines);
    $this->assertEquals('pm-download', $command->command);
    $this->assertEquals('pm', $command->commandfile);
    $this->assertEquals('drush_command', $command->callback);
    $this->assertObjectHasAttribute('examples', $command->sections);
    $this->assertTrue($command->is_alias);
  }

  /*
   * Assert that minimum bootstrap phase is honored.
   *
   * Not testing dependency on a module since that requires an installed Drupal.
   * Too slow for little benefit.
   */
  public function testRequirementBootstrapPhase() {
    // Assure that core-cron fails when run outside of a Drupal site.
    $return = $this->execute(UNISH_DRUSH . ' core-cron --quiet', self::EXIT_ERROR);
  }
}