Author: Manuel Pichler (mapi@phpmd.org)
Inheritance: extends PHPMD\AbstractRenderer
 /**
  * testCliAcceptsSingleFileAsInput
  *
  * @return void
  */
 public function testCliAcceptsSingleFileAsInput()
 {
     self::changeWorkingDirectory();
     $renderer = new XMLRenderer();
     $renderer->setWriter(new WriterStub());
     $phpmd = new PHPMD();
     $phpmd->processFiles(self::createFileUri('source/FooBar.php'), 'pmd-refset1', array($renderer), new RuleSetFactory());
 }
Example #2
0
 /**
  * testRendererAddsProcessingErrorsToXmlReport
  *
  * @return void
  * @since 1.2.1
  */
 public function testRendererAddsProcessingErrorsToXmlReport()
 {
     // Create a writer instance.
     $writer = new WriterStub();
     $processingErrors = array(new ProcessingError('Failed for file "/tmp/foo.php".'), new ProcessingError('Failed for file "/tmp/bar.php".'), new 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($processingErrors)));
     $renderer = new XMLRenderer();
     $renderer->setWriter($writer);
     $renderer->start();
     $renderer->renderReport($report);
     $renderer->end();
     $this->assertXmlEquals($writer->getData(), 'renderer/xml_renderer_processing_errors.xml');
 }
Example #3
0
 /**
  * testHasViolationsReturnsTrueForSourceWithViolation
  *
  * @return void
  */
 public function testHasViolationsReturnsTrueForSourceWithViolation()
 {
     self::changeWorkingDirectory();
     $renderer = new XMLRenderer();
     $renderer->setWriter(new WriterStub());
     $phpmd = new PHPMD();
     $phpmd->processFiles(self::createFileUri('source/source_with_npath_violation.php'), 'pmd-refset1', array($renderer), new RuleSetFactory());
     $this->assertTrue($phpmd->hasViolations());
 }