/**
  * tests config setup, relies on an alternate testing config to be defined,
  * these properties should all point to the batchmake module testfiles dirs.
  */
 public function testIsConfigCorrect()
 {
     // start out with known correct set
     $this->assertTrue($this->kwBatchmakeComponent->isConfigCorrect());
     // now make a change to something that shouldn't work
     $badConfigVals = $this->setupAndGetConfig();
     $badConfigVals[MIDAS_BATCHMAKE_DATA_DIR_PROPERTY] = '/unlikely/to/work/right';
     $badKwBatchmakeComponent = new Batchmake_KWBatchmakeComponent($badConfigVals);
     $this->assertFalse($badKwBatchmakeComponent->isConfigCorrect());
 }
 /**
  * function will create a temporary batchmake config, copying over test data
  * to the the locations in that config needed for the tests, returning an
  * array of config property names to directory locations.
  *
  * @todo figure out a way to copy over Batchmake or else mock it
  * @return array
  * @throws Zend_Exception
  */
 public function setupAndGetConfig()
 {
     // create a test batchmake setup in the temp dir
     // and initialize test data
     $tmpDir = $this->getTempDirectory();
     $subDirs = array('batchmake', 'tests');
     KWUtils::createSubDirectories($tmpDir . '/', $subDirs);
     $configProps = array(MIDAS_BATCHMAKE_TMP_DIR_PROPERTY => $tmpDir . '/batchmake/tests/tmp', MIDAS_BATCHMAKE_BIN_DIR_PROPERTY => $tmpDir . '/batchmake/tests/bin', MIDAS_BATCHMAKE_SCRIPT_DIR_PROPERTY => $tmpDir . '/batchmake/tests/script', MIDAS_BATCHMAKE_APP_DIR_PROPERTY => $tmpDir . '/batchmake/tests/bin', MIDAS_BATCHMAKE_DATA_DIR_PROPERTY => $tmpDir . '/batchmake/tests/data', MIDAS_BATCHMAKE_CONDOR_BIN_DIR_PROPERTY => $tmpDir . '/batchmake/tests/condorbin');
     // now make sure these dirs exist
     // later can actually add some stuff to these dirs
     foreach ($configProps as $dir) {
         if (!file_exists($dir) && !KWUtils::mkDir($dir)) {
             throw new Zend_Exception("couldn't create dir " . $dir);
         }
     }
     // now copy over the bms files
     $srcDir = BASE_PATH . 'modules/batchmake/tests/testfiles/script';
     $targetDir = $configProps[MIDAS_BATCHMAKE_SCRIPT_DIR_PROPERTY];
     $extension = '.bms';
     $this->symlinkFileset($srcDir, $targetDir, $extension);
     // and now the bmms
     $srcDir = BASE_PATH . 'modules/batchmake/tests/testfiles/bin';
     $targetDir = $configProps[MIDAS_BATCHMAKE_APP_DIR_PROPERTY];
     $extension = '.bmm';
     $this->symlinkFileset($srcDir, $targetDir, $extension);
     // the mock object strategy requires both an interface and for
     // executable files to exist on disk in a particular location,
     // so here we will create symlinks to a known executable
     // ls
     // which should be on most systems
     $params = array('ls');
     $cmd = KWUtils::prepareExeccommand('which', $params);
     // dir doesn't matter, just send in srcDir as it is convenient
     KWUtils::exec($cmd, $output, $srcDir, $returnVal);
     if ($returnVal !== 0 || !isset($output) || !isset($output[0])) {
         throw new Zend_Exception('Problem finding ls on your system, used for testing');
     }
     $pathToLs = $output[0];
     // get the applications and their path properties from the component that
     // expects them
     $applicationsPaths = Batchmake_KWBatchmakeComponent::getApplicationsPaths();
     foreach ($applicationsPaths as $application => $pathProperty) {
         // now in the place of each executable, symlink the ls exe
         $link = $configProps[$pathProperty] . '/' . $application;
         if (!file_exists($link) && !symlink($pathToLs, $link)) {
             throw new Zend_Exception($pathToLs . ' could not be sym-linked to ' . $link);
         }
     }
     return $configProps;
 }