better formatting

This commit is contained in:
James 2019-09-19 18:05:07 +01:00
parent b6ad89e0f3
commit 6bd6de7676

View File

@ -5,23 +5,29 @@ use \JHodges\GiteaBot\Client;
final class Poster{
function __construct($testdox,$xml){
$report=file_get_contents($testdox);
$report=preg_replace('# \[#',' * [',$report);
function __construct($testdox_path,$xml_path){
$testdox=file_get_contents($testdox_path);
$testdox=preg_replace('# \[#',' * [',$testdox);
$xml = simplexml_load_file($xml);
$xml = simplexml_load_file($xml_path);
$project = $xml->testsuite;
//echo sprintf("total: %s msec", ($project['time'])) . PHP_EOL;
$summary='';//sprintf("total: %s sec", ($project['time'])) . PHP_EOL;
$report='';
foreach($project->attributes() as $k=>$v){
//print_r($k);print_r($v);die();
$summary.=" * $k : {$v[0]}\n";
}
foreach ($project->testsuite as $testsuite) {
//echo sprintf(" suite: %s msec : %s", ($testsuite['time']), $testsuite['name']) . PHP_EOL;
//$summary.=sprintf(" suite: %s sec : %s", ($testsuite['time']), $testsuite['name']) . PHP_EOL;
foreach ($testsuite->testcase as $testcase) {
//echo sprintf(" case: %s msec : %s", ($testcase['time']), $testcase['name']) . PHP_EOL;
//$summary.=sprintf(" case: %s sec : %s", ($testcase['time']), $testcase['name']) . PHP_EOL;
foreach($testcase as $k=>$v){
$report.="\n```plain\n".print_r($testcase,true)."\n```";
}
}
}
$this->report=$report;
$this->report=$summary."\n".$testdox.$report;
}
function post($url, $user, $pass, $repoUser, $repo){