Пример #1
0
 /**
  * auxiliary function to include requested adapter
  *
  * @param string $type
  * @return boolean
  */
 private static function loadAdapter($name)
 {
     // already loaded
     if (class_exists(self::getAdapterClassName($name))) {
         return true;
     }
     $classFile = PHPFIT_Fixture::fc_incpath('file_exists', self::getAdapterClassFile($name));
     if (false === $classFile) {
         return false;
     }
     require_once self::getAdapterClassFile($name);
     return class_exists(self::getAdapterClassName($name));
 }
Пример #2
0
 public function testEscape()
 {
     $junk = "!@#\$%^*()_-+={}|[]\\:\";',./?`";
     $this->assertEqual($junk, PHPFIT_Fixture::escape($junk));
     $this->assertEqual("", PHPFIT_Fixture::escape(""));
     $this->assertEqual("&lt;", PHPFIT_Fixture::escape("<"));
     $this->assertEqual("&lt;&lt;", PHPFIT_Fixture::escape("<<"));
     $this->assertEqual("x&lt;", PHPFIT_Fixture::escape("x<"));
     $this->assertEqual("&amp;", PHPFIT_Fixture::escape("&"));
     $this->assertEqual("&lt;&amp;&lt;", PHPFIT_Fixture::escape("<&<"));
     $this->assertEqual("&amp;&lt;&amp;", PHPFIT_Fixture::escape("&<&"));
     $this->assertEqual('a &lt; b &amp;&amp; c &lt; d', PHPFIT_Fixture::escape('a < b && c < d'));
     $this->assertEqual('a<br />b', PHPFIT_Fixture::escape('a\\nb'));
 }
Пример #3
0
 /**
  * run test
  *
  * Process all tables in input file and store result in output file.
  *
  * Example:
  * <pre>
  *  $fr = new FileRunner();
  *  $fr->run( 'infilt.html', 'outfile.html' );
  * </pre>
  *
  * @param string $in path to input file
  * @param string $out path to output file
  * @param string $fixturesDirectory path to fixtures
  * @return string results
  */
 public function run($in, $out, $fixturesDirectory = null)
 {
     date_default_timezone_set('UTC');
     // check input file
     if (!PHPFIT_Fixture::fc_incpath('file_exists', $in) || !PHPFIT_Fixture::fc_incpath('is_readable', $in) || !$in) {
         throw new PHPFIT_Exception_FileIO('Input file does not exist!', $in);
     }
     // check output file
     if (!self::isWritable($out)) {
         throw new PHPFIT_Exception_FileIO('Output file is not writable ' . '(probably a problem of file permissions)', $out);
     }
     // summary data
     $this->fixture->summary['input file'] = $in;
     $this->fixture->summary['output file'] = $out;
     $this->fixture->summary['input update'] = PHPFIT_Fixture::getDateString(filemtime(realpath($in))) . '.';
     // load input data
     $this->input = file_get_contents($in, true);
     $result = $this->process($fixturesDirectory);
     // save output
     file_put_contents($out, $this->tables->toString(), true);
     return $result;
 }
Пример #4
0
 /**
  * @param string $filename
  * @return boolean
  */
 protected static function canLoadFile($filename)
 {
     return PHPFIT_Fixture::fc_incpath('is_readable', $filename);
 }
Пример #5
0
 /**
  * @param string $input
  * @return string
  */
 private function processDocument($fixturePath, $input)
 {
     PHPFIT_Fixture::setHtmlRenderer(new PHPFIT_HtmlRenderer_Fitnesse());
     $fixture = new PHPFIT_Fixture($fixturePath);
     try {
         $tables = PHPFIT_Parse::create($input);
         $fixture->doTables($tables);
     } catch (PHPFIT_Exception_Parse $e) {
         $tables = $this->exception($e, $fixture);
     }
     $this->counts = $fixture->counts;
     $this->totalCounts->tally($fixture->counts);
     return $tables->toString();
 }
Пример #6
0
 static function getCssProperty($type)
 {
     if ($type == 'parameter') {
         return sprintf(' style="%s"', 'font-weight: bold');
     }
     if ($type == 'action') {
         return sprintf(' style="%s"', 'font-style: italic');
     }
     return parent::getCssProperty($type);
 }
Пример #7
0
 /**
  * @param PHPFIT_HtmlRenderer_Base $htmlRenderer
  * @return void
  */
 public static function setHtmlRenderer($htmlRenderer)
 {
     self::$htmlRenderer = $htmlRenderer;
 }
Пример #8
0
 public function testCamelWithSpaceAfterEachChar()
 {
     $this->assertEqual('MYSTRING', PHPFIT_Fixture::camel(' m y s t r i n g'));
 }
Пример #9
0
 /**
  * check whether the value of a cell matches
  *
  * @param PHPFIT_Parse $cell,
  * @param PHPFIT_TypeAdapter $a
  * @return bool true on success, false otherwise
  */
 public function checkCell($cell, $a)
 {
     if (!$this->hasExecuted) {
         try {
             $this->execute();
         } catch (Exception $e) {
             $this->exception($cell, $e);
         }
         $this->hasExecuted = true;
     }
     parent::checkCell($cell, $a);
 }