composer update

This commit is contained in:
Manish Verma
2018-12-05 10:50:52 +05:30
parent 9eabcacfa7
commit 4addd1e9c6
3328 changed files with 156676 additions and 138988 deletions

View File

@@ -0,0 +1,63 @@
<?php
use Codacy\Coverage\Parser\CloverParser;
class CloverParserTest extends \PHPUnit\Framework\TestCase
{
public function testThrowsExceptionOnWrongPath()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Unable to load the xml file. Make sure path is properly set. Using: "/home/foo/bar/baz/m.xml"');
new CloverParser("/home/foo/bar/baz/m.xml");
}
/**
* Testing against the clover coverage report 'tests/res/clover/clover.xml'
*/
public function testCanParseCloverXmlWithoutProject()
{
$this->_canParseClover('tests/res/clover/clover.xml', "/home/jacke/Desktop/codacy-php");
}
/**
* Testing against the clover coverage report 'tests/res/clover/clover.xml'
* The test had been made in /home/jacke/Desktop/codacy-php so we need to pass this
* as 2nd (optional) parameter. Otherwise the filename will not be correct and test
* would fail on other machines or in other directories.
*/
public function testCanParseCloverXmlWithProject()
{
$this->_canParseClover('tests/res/clover/clover_without_packages.xml', "/home/jacke/Desktop/codacy-php");
}
private function _canParseClover($path, $rootDir)
{
$parser = new CloverParser($path, $rootDir);
$report = $parser->makeReport();
$this->assertEquals(38, $report->getTotal());
$this->assertEquals(5, sizeof($report->getFileReports()));
$parserFileReports = $report->getFileReports();
$parserFileReport = $parserFileReports[0];
$coverageReportFileReport = $parserFileReports[1];
$this->assertEquals(33, $parserFileReport->getTotal());
$this->assertEquals(33, $coverageReportFileReport->getTotal());
$parserFileName = $parserFileReport->getFileName();
$reportFileName = $coverageReportFileReport->getFileName();
$fileReports = $report->getFileReports();
$fileReport = $fileReports[1];
$expLineCoverage = (object)array(11 => 1, 12 => 1, 13 => 1, 16 => 1,
19 => 0, 30 => 0, 31 => 0, 32 => 0, 33 => 0, 36 => 0, 39 => 0, 42 => 0);
$this->assertEquals($fileReport->getLineCoverage(), $expLineCoverage);
$this->assertEquals("src/Codacy/Coverage/Parser/Parser.php", $parserFileName);
$this->assertEquals("src/Codacy/Coverage/Report/CoverageReport.php", $reportFileName);
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace Codacy\Coverage\Parser;
use Codacy\Coverage\Util\JsonProducer;
class ParserTest extends \PHPUnit\Framework\TestCase
{
/**
* Running against tests/res/phpunit-clover
*/
public function testParsersProduceSameResult()
{
$cloverParser = new CloverParser('tests/res/phpunit-clover/clover.xml', '/home/jacke/Desktop/codacy-php');
$xunitParser = new PhpUnitXmlParser('tests/res/phpunit-clover/index.xml', '/home/jacke/Desktop/codacy-php');
$xunitParser->setDirOfFileXmls('tests/res/phpunit-clover');
$expectedJson = file_get_contents('tests/res/expected.json', true);
$jsonProducer = new JsonProducer();
$jsonProducer->setParser($cloverParser);
$cloverJson = $jsonProducer->makeJson();
$jsonProducer->setParser($xunitParser);
$xunitJson = $jsonProducer->makeJson();
$this->assertJsonStringEqualsJsonString($expectedJson, $cloverJson);
$this->assertJsonStringEqualsJsonString($expectedJson, $xunitJson);
}
public function testConstructorOnNullRootDir()
{
$parser = new PhpUnitXmlParser('tests/res/phpunitxml/index.xml');
$parser->setDirOfFileXmls("tests/res/phpunitxml");
$report = $parser->makeReport();
$this->assertEquals(69, $report->getTotal());
$this->assertEquals(10, sizeof($report->getFileReports()));
}
}

View File

@@ -0,0 +1,59 @@
<?php
use Codacy\Coverage\Parser\PhpUnitXmlParser;
class PhpUnitXmlParserTest extends \PHPUnit\Framework\TestCase
{
public function testThrowsExceptionOnWrongPath()
{
$this->expectException('InvalidArgumentException');
new PhpUnitXmlParser("/home/foo/bar/baz/fake.xml");
}
public function testMakeReportThrowsExceptionOnWrndPath()
{
$parser = new PhpUnitXmlParser('tests/res/phpunitxml/index.xml', '/home/jacke/Desktop/codacy-php');
$this->expectException('InvalidArgumentException');
$parser->makeReport();
}
/**
* Testing against the clover coverage report 'tests/res/clover/clover.xml'
* The test had been made in /home/jacke/Desktop/codacy-php so we need to pass this
* as 2nd (optional) parameter. Otherwise the filename will not be correct and test
* would fail on other machines or in other directories.
*/
public function testCanParsePhpUnitXmlReport()
{
$parser = new PhpUnitXmlParser('tests/res/phpunitxml/index.xml', '/home/jacke/Desktop/codacy-php');
$parser->setDirOfFileXmls("tests/res/phpunitxml");
$report = $parser->makeReport();
$this->assertEquals(69, $report->getTotal());
$this->assertEquals(10, sizeof($report->getFileReports()));
$fileReports = $report->getFileReports();
$configFileReport = $fileReports[2];
$cloverParserFileReport = $fileReports[4];
$this->assertEquals(86, $configFileReport->getTotal());
$this->assertEquals(95, $cloverParserFileReport->getTotal());
$lineCoverage = $configFileReport->getLineCoverage();
$expLineCoverage = (object)array(24 => 4, 25 => 4, 26 => 4, 27 => 4, 28 => 4, 29 => 4);
$this->assertEquals($lineCoverage, $expLineCoverage);
$configFileName = $configFileReport->getFileName();
$cloverParserFileName = $cloverParserFileReport->getFileName();
$this->assertEquals("src/Codacy/Coverage/Config.php", $configFileName);
$this->assertEquals("src/Codacy/Coverage/Parser/CloverParser.php", $cloverParserFileName);
}
}