function contextCase::setUp

8.0.x contextTest.php contextCase::setUp()
6.x contextTest.php contextCase::setUp()
7.x contextTest.php contextCase::setUp()
4.x contextTest.php contextCase::setup()
5.x contextTest.php contextCase::setUp()
master contextTest.php contextCase::setUp()

Try to write a tiny drushrc.php to each place that Drush checks. Also write a sites/dev/aliases.drushrc.php file to the sandbox.

File

tests/contextTest.php, line 41
Assure that context API behaves as designed. Mostly implicitly tested, but we do have some edges that need explicit testing. *

Namespace

Unish

Class

contextCase

Code

function setUp() {
  parent::setUp();

  if (!$this->getSites()) {
    $this->setUpDrupal();
  }
  $this->setUpPaths();

  // These files are only written to sandbox so get automatically cleaned up.
  foreach ($this->paths as $key => $path) {
    $contents = <<<EOD
<?php
// Written by Drush's contextCase::setUp(). This file is safe to delete.
\$options['contextConfig'] = '$key';
\$command_specific['unit-eval']['contextConfig'] = '$key-specific';
EOD;
    $path .= $key == 'user' ? '/.drushrc.php' : '/drushrc.php';
    if (file_put_contents($path, $contents)) {
      $this->written[] = $this->convert_path($path);
    }
  }

  // Also write a site alias so we can test its supremacy in context hierarchy.
  $path = $this->webroot() . '/sites/' . $this->env . '/aliases.drushrc.php';
  $aliases['contextAlias'] = array(
    'contextConfig' => 'alias1',
    'command-specific' => array(
      'unit-eval' => array(
        'contextConfig' => 'alias-specific',
      ),
    ),
  );
  $contents = $this->unish_file_aliases($aliases);
  $return = file_put_contents($path, $contents);
}