function backendCase::testOrigin

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

Covers the following origin responsibilities.

  • A remote host is recognized in site specification.
  • Generates expected ssh command.

General handling of site aliases will be in sitealiasTest.php.

File

tests/backendTest.php, line 58

Namespace

Unish

Class

backendCase
We choose to test the backend system in two parts.

Code

function testOrigin() {
  $site_specification = 'user@server/path/to/drupal#sitename';
  $exec = sprintf('%s %s version arg1 arg2 --simulate --ssh-options=%s 2>%s', UNISH_DRUSH, self::escapeshellarg($site_specification), self::escapeshellarg('-i mysite_dsa'), self::escapeshellarg($this->bit_bucket()));
  $this->execute($exec);
  $bash = $this->escapeshellarg('drush  --uri=sitename --root=/path/to/drupal  version arg1 arg2 2>&1');
  $expected = "Simulating backend invoke: ssh -i mysite_dsa user@server $bash 2>&1";
  $output = $this->getOutput();
  $this->assertContains($expected, $output, 'Expected ssh command was built');

  // Assure that arguments and options are passed along to a command thats not recognized locally.
  $this->drush('non-existent-command', array('foo'), array('bar' => 'baz', 'simulate' => NULL), $site_specification);
  $output = $this->getOutput();
  $this->assertContains('foo', $output);
  $this->assertContains('--bar=baz', $output);
}