better report format

This commit is contained in:
James 2019-09-19 16:55:24 +01:00
parent a922237371
commit b6ad89e0f3

View File

@ -7,34 +7,33 @@ final class Poster{
function __construct($testdox,$xml){
$report=file_get_contents($testdox);
$this->report=preg_replace('# \[#',' * [',$report);
$report=preg_replace('# \[#',' * [',$report);
$log=file_get_contents($xml);
$p = xml_parser_create();
xml_parse_into_struct($p, $log, $vals, $index);
xml_parser_free($p);
$this->vals=$vals;
$this->index=$index;
$xml = simplexml_load_file($xml);
$project = $xml->testsuite;
//echo sprintf("total: %s msec", ($project['time'])) . PHP_EOL;
foreach ($project->testsuite as $testsuite) {
//echo sprintf(" suite: %s msec : %s", ($testsuite['time']), $testsuite['name']) . PHP_EOL;
foreach ($testsuite->testcase as $testcase) {
//echo sprintf(" case: %s msec : %s", ($testcase['time']), $testcase['name']) . PHP_EOL;
foreach($testcase as $k=>$v){
$report.="\n```plain\n".print_r($testcase,true)."\n```";
}
}
}
$this->report=$report;
}
function post($url, $user, $pass, $repoUser, $repo){
//open connection and repo
// open connection and repo
$client=new Client($url, $user, $pass, $repoUser, $repo);
$repo=$client->getRepo($repoUser, $repo);
//create a test issue
// create the issue
$issue=$repo->createIssue([
'title'=>'Test Results',
'body'=>$this->report
]);
//$issue->addLabel($label);
foreach($this->index['FAILURE'] as $id){
$msg=$this->vals[$id]['value'];
$msg=str_replace('\n','',$msg);
$issue->addComment("```plain\n$msg\n```");
}
$issue->save();
}
}