function contextCase::ConfigVersionSpecific

6.x contextTest.php contextCase::ConfigVersionSpecific()
4.x contextTest.php contextCase::ConfigVersionSpecific()
5.x contextTest.php contextCase::ConfigVersionSpecific()

Assure that matching version-specific config files are loaded and others are ignored.

1 call to contextCase::ConfigVersionSpecific()
contextCase::testContext in tests/contextTest.php
These should be different tests but I could not work out how to do that without calling setUp() twice. setUpBeforeClass() did not work out (for MW).


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




function ConfigVersionSpecific() {
  $major = $this->drush_major_version();
  // Arbitrarily choose the system search path.
  $path = realpath(UNISH_SANDBOX . '/etc/drush');
  $contents = <<<EOD
// Written by Unish. This file is safe to delete.
\$options['unish_foo'] = 'bar';

  // Write matched and unmatched files to the system search path.
  $files = array(
    $path . '/drush' . $major . 'rc.php',
    $path . '/drush999' . 'rc.php',
  mkdir($path . '/drush' . $major);
  mkdir($path . '/drush999');
  foreach ($files as $file) {
    file_put_contents($file, $contents);

  $this->drush('core-status', array('Drush configuration'), array('pipe' => NULL));
  $loaded = $this->getOutputFromJSON('drush-conf');
  // Next 2 lines needed for Windows compatibility.
  $loaded = array_map(array(&$this, 'convert_path'), $loaded);
  $files = array_map(array(&$this, 'convert_path'), $files);
  $this->assertTrue(in_array($files[0], $loaded), 'Loaded a version-specific config file.');
  $this->assertFalse(in_array($files[1], $loaded), 'Did not load a mismatched version-specific config file.');