/** * 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; }
/** * get a fixture with arguments * * @param PHPFIT_Parser $tables * @return PHPFIT_Fixture * @see loadFixture() */ protected function getFixture($tables) { $header = $tables->at(0, 0, 0); $fixture = $this->loadFixture($header->text()); $fixture->counts = $this->counts; $fixture->summary = $this->summary; return $fixture; }