initial commit
This commit is contained in:
38
src/Poster.php
Normal file
38
src/Poster.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace JHodges\GiteaBotPHPUnit;
|
||||
|
||||
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($config['url'],$config['user'],$config['pass'],$debug);
|
||||
$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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user