Exemplo n.º 1
0
 /**
  * @param \CliTester            $I
  * @param \Codeception\Scenario $scenario
  */
 public function testDocumentValidHtml(\CliTester $I, \Codeception\Scenario $scenario)
 {
     $I->wantTo('verify that the default template produces valid HTML');
     if (!class_exists('Tidy')) {
         $scenario->skip('Tidy is not available. See http://php.net/manual/en/tidy.installation.php');
     }
     $template = dirname(dirname(__DIR__)) . '/src/Task/CodeSniffer/codestyle.html';
     $outfile = dirname(__DIR__) . '/_output/codestyle.html';
     if (file_exists($outfile)) {
         unlink($outfile);
     }
     $I->dontSeeFileFound($outfile);
     $I->runShellCommand('vendor/bin/robo document:codestyle --outfile ' . $outfile . ' --template ' . $template);
     $I->seeFileFound($outfile);
     $tidy = new \Tidy();
     $tidy->parseFile($outfile);
     $I->assertEquals(0, $tidy->getStatus());
     unlink($outfile);
 }
Exemplo n.º 2
0
error_reporting(E_ALL);
if (!version_compare(phpversion(), "5.0", ">=")) {
    echo "Error: tidy.php requires PHP 5 or newer.\n";
    exit(1);
}
$tidy = new Tidy();
$tmpfile = '';
// merge default options with command line arguments
$config = parseArguments($default_options);
// check if input file exists
if (!file_exists($tmpfile)) {
    echo "Error: tidy.php cannot find tmpfile at: {$tmpfile} \n";
    exit(1);
}
// let tidy do the work
$tidy->parseFile($tmpfile, $config, 'utf8');
// other things you can do with php's Tidy():
// $tidy->parseString($html, $options);
// $tidy->cleanRepair();
// echo $tidy;
// write buffer back to tmpfile
if (!file_put_contents($tmpfile, (string) $tidy)) {
    echo "Error: The file '" . $tmpfile . "' could not be written.\n";
    exit(1);
}
/**
 * parseArguments: parse command line arguments and modify $defaults array
 * @param  array $defaults tidy config array to be modified
 * @return array modified config array
 */
function parseArguments($defaults)