finshed result printer and fix posting bugs
This commit is contained in:
@@ -5,41 +5,44 @@ use \JHodges\GiteaBot\Client;
|
||||
|
||||
final class Poster{
|
||||
|
||||
function __construct($testdox_path,$xml_path){
|
||||
$testdox=file_get_contents($testdox_path);
|
||||
$testdox=preg_replace('# \[#',' * [',$testdox);
|
||||
private $report;
|
||||
|
||||
function __construct($testdox_path,$xml_path){
|
||||
$testdox=file_get_contents($testdox_path);
|
||||
$testdox=preg_replace('# \[#',' * [',$testdox);
|
||||
|
||||
$this->report.=$testdox;
|
||||
|
||||
$xml = simplexml_load_file($xml_path);
|
||||
$project = $xml->testsuite;
|
||||
$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) {
|
||||
//$summary.=sprintf(" suite: %s sec : %s", ($testsuite['time']), $testsuite['name']) . PHP_EOL;
|
||||
foreach ($testsuite->testcase as $testcase) {
|
||||
//$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=$summary."\n".$testdox.$report;
|
||||
$this->process($xml);
|
||||
}
|
||||
|
||||
function post($url, $user, $pass, $repoUser, $repo){
|
||||
// open connection and repo
|
||||
$client=new Client($url, $user, $pass, $repoUser, $repo);
|
||||
$repo=$client->getRepo($repoUser, $repo);
|
||||
public function post($url, $user, $pass, $repoUser, $repo){
|
||||
// open connection and repo
|
||||
$client=new Client($url, $user, $pass, $repoUser, $repo);
|
||||
$repo=$client->getRepo($repoUser, $repo);
|
||||
|
||||
// create the issue
|
||||
$issue=$repo->createIssue([
|
||||
'title'=>'Test Results',
|
||||
'body'=>$this->report
|
||||
]);
|
||||
// create the issue
|
||||
$issue=$repo->createIssue([
|
||||
'title'=>'Test Results',
|
||||
'body'=>$this->report
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
private function process($item){
|
||||
if(isset($item->testcase)){
|
||||
foreach($item->testcase as $testcase) {
|
||||
foreach($testcase as $k=>$v){
|
||||
$this->report.="\n```plain\n".print_r($testcase,true)."\n```";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($item->testsuite)){
|
||||
foreach($item->testsuite as $testsuite) {
|
||||
$this->process($testsuite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user