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).

File

tests/contextTest.php, line 101

Class

contextCase

Code

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

  // 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));
  $output = trim($this->getOutput());
  $loaded = explode(' ', $output);
  $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.');
}