upload screenshots

This commit is contained in:
James 2019-09-23 12:16:08 +01:00
parent 6c0873fc6f
commit 495d4e0d26
2 changed files with 15 additions and 7 deletions

View File

@ -8,7 +8,7 @@
} }
], ],
"require": { "require": {
"jhodges/giteabot": "~1.2.0" "jhodges/giteabot": "~1.2.2"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

@ -13,17 +13,18 @@ final class Poster{
$this->report.=$testdox; $this->report.=$testdox;
$xml = simplexml_load_file($xml_path); $this->xml = simplexml_load_file($xml_path);
$this->process($xml);
} }
public function post($url, $user, $pass, $repoUser, $repo){ public function post($url, $user, $pass, $repoUser, $repo){
// open connection and repo // open connection and repo
$client=new Client($url, $user, $pass); $this->client=new Client($url, $user, $pass, true);
$repo=$client->getRepo($repoUser, $repo); $this->repo=$this->client->getRepo($repoUser, $repo);
$this->process($this->xml); //process xml and upload screenshots
// create the issue // create the issue
$issue=$repo->createIssue([ $issue=$this->repo->createIssue([
'title'=>'Test Results', 'title'=>'Test Results',
'body'=>$this->report 'body'=>$this->report
]); ]);
@ -34,7 +35,14 @@ final class Poster{
if(isset($item->testcase)){ if(isset($item->testcase)){
foreach($item->testcase as $testcase) { foreach($item->testcase as $testcase) {
foreach($testcase as $k=>$v){ foreach($testcase as $k=>$v){
$this->report.="\n```plain\n".print_r($testcase,true)."\n```"; $img='';
$name=$testcase->attributes()->class[0]."::".$testcase->attributes()->name[0];
if(file_exists("/tmp/$name.png")){
$data=$this->repo->addAttachment("/tmp/$name.png");
$url=$data->browser_download_url;
$img="\n![]($url)\n";
}
$this->report.="\n------\n# $name\n$img\n```plain\n".print_r($testcase,true)."\n```";
} }
} }
} }