diff --git a/composer.json b/composer.json index df4242f..b1750a5 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ } ], "require": { - "jhodges/giteabot": "~1.2.0" + "jhodges/giteabot": "~1.2.2" }, "autoload": { "psr-4": { diff --git a/src/Poster.php b/src/Poster.php index 7d1f107..64fbc16 100644 --- a/src/Poster.php +++ b/src/Poster.php @@ -13,17 +13,18 @@ final class Poster{ $this->report.=$testdox; - $xml = simplexml_load_file($xml_path); - $this->process($xml); + $this->xml = simplexml_load_file($xml_path); } public function post($url, $user, $pass, $repoUser, $repo){ // open connection and repo - $client=new Client($url, $user, $pass); - $repo=$client->getRepo($repoUser, $repo); + $this->client=new Client($url, $user, $pass, true); + $this->repo=$this->client->getRepo($repoUser, $repo); + + $this->process($this->xml); //process xml and upload screenshots // create the issue - $issue=$repo->createIssue([ + $issue=$this->repo->createIssue([ 'title'=>'Test Results', 'body'=>$this->report ]); @@ -34,7 +35,14 @@ final class Poster{ if(isset($item->testcase)){ foreach($item->testcase as $testcase) { 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```"; } } }