/**
  * @medium
  */
 public function testXmlReportIsCorrectlyGenerated()
 {
     $file1 = new File('foobar.tys');
     $file1->addWarning(new Warning(123, 12, 'Message #1', Warning::SEVERITY_INFO, 'foobar'));
     $file1->addWarning(new Warning(124, NULL, 'Message #2', Warning::SEVERITY_WARNING, 'foobar'));
     $file2 = new File('bar.txt');
     $file2->addWarning(new Warning(412, 141, 'Message #3', Warning::SEVERITY_ERROR, 'barbaz'));
     $report = new Report();
     $report->addFile($file1);
     $report->addFile($file2);
     $this->output->expects($this->once())->method('write')->with(self::EXPECTED_XML_DOCUMENT);
     $this->printer->writeReport($report);
 }
 /**
  * @medium
  */
 public function testPlaintextReportIsCorrectlyGenerated()
 {
     $file1 = new File('foobar.tys');
     $file1->addWarning(new Warning(123, 12, 'Message #1', Warning::SEVERITY_INFO, 'foobar'));
     $file1->addWarning(new Warning(124, NULL, 'Message #2', Warning::SEVERITY_WARNING, 'foobar'));
     $file2 = new File('bar.txt');
     $file2->addWarning(new Warning(412, 141, 'Message #3', Warning::SEVERITY_ERROR, 'barbaz'));
     $report = new Report();
     $report->addFile($file1);
     $report->addFile($file2);
     $this->printer->writeReport($report);
     $this->assertEquals(self::EXPECTED_XML_DOCUMENT, $this->output->fetch());
 }
Exemplo n.º 3
0
 /**
  * @param string                                            $filename
  * @param \Helmich\TypoScriptLint\Linter\Report\Report            $report
  * @param \Helmich\TypoScriptLint\Linter\LinterConfiguration      $configuration
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  */
 public function lintFile($filename, Report $report, LinterConfiguration $configuration, OutputInterface $output)
 {
     $file = new File($filename);
     try {
         $tokens = $this->tokenizer->tokenizeStream($filename);
         $statements = $this->parser->parseTokens($tokens);
         $this->lintTokenStream($tokens, $file, $configuration, $output);
         $this->lintSyntaxTree($statements, $file, $configuration, $output);
     } catch (TokenizerException $tokenizerException) {
         $file->addWarning(Warning::createFromTokenizerError($tokenizerException));
     } catch (ParseError $parseError) {
         $file->addWarning(Warning::createFromParseError($parseError));
     }
     if (count($file->getWarnings()) > 0) {
         $report->addFile($file);
     }
 }