/**
  * testRendererAddsProcessingErrorsToHtmlReport
  *
  * @return void
  */
 public function testRendererAddsProcessingErrorsToHtmlReport()
 {
     // Create a writer instance.
     $writer = new PHP_PMD_Stubs_WriterStub();
     $errors = array(new PHP_PMD_ProcessingError('Failed for file "/tmp/foo.php".'), new PHP_PMD_ProcessingError('Failed for file "/tmp/bar.php".'), new PHP_PMD_ProcessingError('Failed for file "/tmp/baz.php".'));
     $report = $this->getReportMock(0);
     $report->expects($this->once())->method('getRuleViolations')->will($this->returnValue(new ArrayIterator(array())));
     $report->expects($this->once())->method('getErrors')->will($this->returnValue(new ArrayIterator($errors)));
     $renderer = new PHP_PMD_Renderer_HTMLRenderer();
     $renderer->setWriter($writer);
     $renderer->start();
     $renderer->renderReport($report);
     $renderer->end();
     $this->assertContains('<tr>' . '<td>/tmp/bar.php</td>' . '<td>Failed for file &quot;/tmp/bar.php&quot;.</td>' . '</tr>', $writer->getData());
 }
Пример #2
0
 /**
  * testRendererCreatesExpectedNumberOfTextEntries
  *
  * @return void
  * @covers PHP_PMD_Renderer_HTMLRenderer
  * @group phpmd
  * @group phpmd::renderer
  * @group unittest
  */
 public function testRendererCreatesExpectedHtmlTableRow()
 {
     // Create a writer instance.
     $writer = new PHP_PMD_Stubs_WriterStub();
     $violations = array($this->getRuleViolationMock('/bar.php', 1), $this->getRuleViolationMock('/foo.php', 2), $this->getRuleViolationMock('/foo.php', 3));
     $report = $this->getReportMock(0);
     $report->expects($this->once())->method('getRuleViolations')->will($this->returnValue(new ArrayIterator($violations)));
     $renderer = new PHP_PMD_Renderer_HTMLRenderer();
     $renderer->setWriter($writer);
     $renderer->start();
     $renderer->renderReport($report);
     $renderer->end();
     $this->assertContains('<tr>' . PHP_EOL . '<td align="center">2</td>' . PHP_EOL . '<td>/foo.php</td>' . PHP_EOL . '<td align="center" width="5%">2</td>' . PHP_EOL . '<td><a href="http://phpmd.org/rules/index.html">Test description</a></td>' . PHP_EOL . '</tr>', $writer->getData());
 }