41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?php
|
|
namespace JHodges\GiteaBotPHPUnit;
|
|
|
|
use \JHodges\GiteaBot\Client;
|
|
|
|
final class Poster{
|
|
|
|
function __construct($testdox,$xml){
|
|
$report=file_get_contents($testdox);
|
|
$this->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;
|
|
}
|
|
|
|
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 a test 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();
|
|
}
|
|
}
|