function backendCase::testDispatchUsingAlias

8.0.x backendTest.php backendCase::testDispatchUsingAlias()
6.x backendTest.php backendCase::testDispatchUsingAlias()
7.x backendTest.php backendCase::testDispatchUsingAlias()
5.x backendTest.php backendCase::testDispatchUsingAlias()
master backendTest.php backendCase::testDispatchUsingAlias()

File

tests/backendTest.php, line 21
We choose to test the backend system in two parts. - Origin. These tests assure that we are generate a proper ssh command when a backend invoke is needed. - Target. These tests assure that drush generates a delimited JSON array …

Class

backendCase

Code

function testDispatchUsingAlias() {
  $aliasPath = UNISH_SANDBOX . '/aliases';
  mkdir($aliasPath);
  $aliasFile = $aliasPath . '/foo.aliases.drushrc.php';
  $aliasContents = <<<EOD
  <?php
  // Written by Unish. This file is safe to delete.
  \$aliases['dev'] = array('root' => '/fake/path/to/root', 'uri' => 'default');
EOD;
  file_put_contents($aliasFile, $aliasContents);
  $options = array(
    'alias-path' => $aliasPath,
    'include' => dirname(__FILE__), // Find unit.drush.inc commandfile.
    'backend' => TRUE,
  );
  $php = <<<EOD
    \$valuesUsingAlias = drush_invoke_process("@dev", "unit-return-argv", array(), array(), array("dispatch-using-alias" => TRUE));
    \$valuesWithoutAlias = drush_invoke_process("@dev", "unit-return-argv", array(), array(), array());
    return array('with' => \$valuesUsingAlias['object'], 'without' => \$valuesWithoutAlias['object']);
EOD;
  $this->drush('php-eval', array($php), $options);
  $parsed = parse_backend_output($this->getOutput());

  // $parsed['with'] and $parsed['without'] now contain an array
  // each with the original arguments passed in with and without
  // 'dispatch-using-alias', respectively.
  $argDifference = array_diff($parsed['object']['with'], $parsed['object']['without']);
  $this->assertEquals(array_diff(array_values($argDifference), array('@foo.dev')), array());
  $argDifference = array_diff($parsed['object']['without'], $parsed['object']['with']);
  $this->assertEquals(array_diff(array_values($argDifference), array('--root=/fake/path/to/root', '--uri=default')), array());
}