/** * 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. */ 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); }
/** * 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. */ function setUp() { parent::setUp(); $path = UNISH_SANDBOX . '/aliases.drushrc.php'; $aliases['site1'] = array('root' => UNISH_SANDBOX, 'uri' => 'site1.com', 'source-command-specific' => array('core-rsync' => array('exclude-paths' => 'excluded_by_source')), 'target-command-specific' => array('core-rsync' => array('exclude-paths' => 'excluded_by_target')), 'path-aliases' => array('%files' => 'sites/default/files')); $contents = $this->unish_file_aliases($aliases); $return = file_put_contents($path, $contents); }
/** * Write a config file that contains the shell-aliases array. */ function setUp() { parent::setUp(); $contents = "\n <?php\n\n \$options['shell-aliases'] = array(\n 'glopts' => 'topic core-global-options',\n 'pull' => '!git pull',\n 'echosimple' => '!echo {{@target}}',\n 'echotest' => '!echo {{@target}} {{%root}} {{%mypath}}',\n 'compound-command' => '!cd {{%sandbox}} && echo second',\n );\n "; file_put_contents(UNISH_SANDBOX . '/drushrc.php', trim($contents)); if (!file_exists(UNISH_SANDBOX . '/b')) { mkdir(UNISH_SANDBOX . '/b'); } $contents = "\n <?php\n\n \$options['shell-aliases'] = array(\n 'also' => '!echo alternate config file included too',\n );\n "; file_put_contents(UNISH_SANDBOX . '/b/drushrc.php', trim($contents)); $aliases['myalias'] = array('root' => '/path/to/drupal', 'uri' => 'mysite.org', '#peer' => '@live', 'path-aliases' => array('%mypath' => '/srv/data/mypath', '%sandbox' => UNISH_SANDBOX)); $contents = $this->unish_file_aliases($aliases); file_put_contents(UNISH_SANDBOX . '/aliases.drushrc.php', $contents); }