initial commit

This commit is contained in:
James
2019-09-18 19:41:13 +01:00
commit 5fb4134631
5 changed files with 104 additions and 0 deletions

38
src/Poster.php Normal file
View 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();
}
}