Example #1
0
 /**
  * @dataProvider providerFiles
  */
 public function testWorkflow($sFile, $sTestfile, $sCommand = '', $sExpectedCommand = '')
 {
     $oMapper = new \Testy\Project\File\Mapper($sCommand, $sFile);
     $this->assertInstanceOf('\\Testy\\Project\\File\\Mapper', $oMapper->map());
     $this->assertEquals($oMapper->get(), $sExpectedCommand);
     $this->assertEquals($oMapper->getTestFile(), $sTestfile);
     unset($oMapper);
 }
Example #2
0
 /**
  * Enrich the command with placeholders
  *
  * @param  boolean $bSingle
  *
  * @return string
  */
 protected function _getCommand($bSingle = false)
 {
     $sCommand = $this->_sCommand;
     if ($bSingle === true) {
         $oTestMapper = new \Testy\Project\File\Mapper($sCommand, $this->_sFile);
         $sCommand = $oTestMapper->map()->get();
         unset($oTestMapper);
     }
     if (empty($this->_sSyncPath) !== true) {
         $sCommand = str_replace($this->_sSyncPath->from, $this->_sSyncPath->to, $sCommand);
     }
     $sCommand = trim(preg_replace('!{.*?}!i', '', $sCommand));
     if (empty($this->_sChangeDir) !== true) {
         $sCommand = sprintf('cd %s; %s', $this->_sChangeDir, $sCommand);
     }
     if (empty($this->_sSyncPath) !== true) {
         $sCommand = sprintf('rsync -azq %s %s; %s', $this->_sSyncPath->from, $this->_sSyncPath->to, $sCommand);
     }
     $aReplace = array(self::FILE_PLACEHOLDER => '', self::TIME_PLACEHOLDER => time(), self::MTIME_PLACEHOLDER => filemtime($this->_sFile), self::PROJECT_PLACEHOLDER => $this->_oProject->getName());
     return str_replace(array_keys($aReplace), array_values($aReplace), $sCommand);
 }