예제 #1
0
 /**
  * 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);
 }
예제 #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $projectToken = $this->getProjectToken();
     $parser = $this->getParser($input->getArgument("path_to_coverage_results"));
     $jsonProducer = new JsonProducer();
     $jsonProducer->setParser($parser);
     $commit = $this->getCommitHash($input->getOption("git-commit"));
     $baseUrl = $this->getBaseCodacyUrl($input->getOption("base-url"));
     $data = $jsonProducer->makeJson();
     if ($output->isVerbose()) {
         $output->writeln("Sending coverage results to " . $baseUrl);
         $output->writeln("Generated JSON:");
         $output->writeln($data);
     }
     $client = new CodacyApiClient($baseUrl, $projectToken);
     $result = $client->sendCoverage($commit, $data);
     if ($output->isVerbose()) {
         $output->writeln($result);
     }
 }