* Dariusz Rumiński * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer\Tests\Report; use PhpCsFixer\PhpunitConstraintXmlMatchesXsd\Constraint\XmlMatchesXsd; use PhpCsFixer\Report\JunitReporter; use Symfony\Component\Console\Formatter\OutputFormatter; /** * @author Boris Gorbylev * @author Dariusz Rumiński * * @internal * * @covers \PhpCsFixer\Report\JunitReporter */ final class JunitReporterTest extends AbstractReporterTestCase { /** * JUnit XML schema from Jenkins. * * @var null|string * * @see https://github.com/jenkinsci/xunit-plugin/blob/master/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd */ private static $xsd; public static function setUpBeforeClass() { parent::setUpBeforeClass(); self::$xsd = file_get_contents(__DIR__.'/../../doc/report-schema/junit-10.xsd'); } public static function tearDownAfterClass() { parent::tearDownAfterClass(); self::$xsd = null; } protected function getFormat() { return 'junit'; } protected function createNoErrorReport() { return <<<'XML' XML; } protected function createSimpleReport() { return <<<'XML' Wrong code style XML; } protected function createWithDiffReport() { return <<<'XML' XML; } protected function createWithAppliedFixersReport() { return <<<'XML' applied fixers: --------------- * some_fixer_name_here_1 * some_fixer_name_here_2 XML; } protected function createWithTimeAndMemoryReport() { return <<<'XML' Wrong code style XML; } protected function createComplexReport() { return <<<'XML' applied fixers: --------------- * some_fixer_name_here_1 * some_fixer_name_here_2 Diff: --------------- this text is a diff ;) applied fixers: --------------- * another_fixer_name_here Diff: --------------- another diff here ;) XML; } protected function assertFormat($expected, $input) { $formatter = new OutputFormatter(); $input = $formatter->format($input); static::assertThat($input, new XmlMatchesXsd(self::$xsd)); static::assertXmlStringEqualsXmlString($expected, $input); } protected function createReporter() { return new JunitReporter(); } }