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 39

Class

contextCase

Code

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

  $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->site . '/aliases.drushrc.php';
  $aliases['contextAlias'] = array(
    'contextConfig' => 'alias1',
    'command-specific' => array(
      'unit-eval' => array(
        'contextConfig' => 'alias-specific',
      ),
    ),
  );
  $contents = $this->file_aliases($aliases);
  $return = file_put_contents($path, $contents);
}