diff --git a/tests/ReportOutputTest.php b/tests/ReportOutputTest.php index d180ec52e..c1de6a63d 100644 --- a/tests/ReportOutputTest.php +++ b/tests/ReportOutputTest.php @@ -2,6 +2,7 @@ namespace Psalm\Tests; +use DOMDocument; use Psalm\Context; use Psalm\Internal\Analyzer\FileAnalyzer; use Psalm\Internal\Analyzer\ProjectAnalyzer; @@ -499,6 +500,8 @@ INFO: PossiblyUndefinedGlobalVariable - somefile.php:15:6 - Possibly undefined g $checkstyle_report_options = ProjectAnalyzer::getFileReportOptions([__DIR__ . '/test-report.junit.xml'])[0]; + $xml = IssueBuffer::getOutput($checkstyle_report_options); + $this->assertSame( ' @@ -548,9 +551,18 @@ column_to: 8 ', - IssueBuffer::getOutput($checkstyle_report_options) + $xml ); + // Validate against junit xsd + $dom = new DOMDocument("1.0", "UTF-8"); + $dom->preserveWhiteSpace = false; + $dom->loadXML($xml); + + // Validate against xsd + $valid = $dom->schemaValidate(__DIR__ . "/junit.xsd"); + $this->assertTrue($valid, "Output did not validate against XSD"); + // FIXME: The XML parser only return strings, all int value are casted, so the assertSame failed //$this->assertSame( // ['report' => ['item' => $issue_data]], diff --git a/tests/junit.xsd b/tests/junit.xsd new file mode 100644 index 000000000..b2ab4e9ba --- /dev/null +++ b/tests/junit.xsd @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +