4 Commits

Author SHA1 Message Date
James
495d4e0d26 upload screenshots 2019-09-23 12:18:16 +01:00
6c0873fc6f Update 'README.md' 2019-09-22 20:09:53 +01:00
cc0eec3b4a Update 'README.md' 2019-09-22 20:03:33 +01:00
James
676c2215c7 update readme 2019-09-22 19:58:46 +01:00
3 changed files with 34 additions and 7 deletions

View File

@@ -1 +1,20 @@
Post PHPUnit test results to Gitea
Enable in phpunit.xml with
```plain
<phpunit ... printerClass="JHodges\GiteaBotPHPUnit\ResultPrinter">
<php>
<env name="GiteaUrl" value="https://try.gitea.io/api/v1/"/>
<env name="GiteaUser" value="bot"/>
<!--env name="GiteaPass" value="xxx"/--> <!--probably set this on the machine env-->
<env name="GiteaRepoUser" value="bobemoe"/>
<env name="GiteaRepo" value="test"/>
</php>
<logging>
<log type="junit" target="/tmp/logfile.xml"/>
<log type="testdox-text" target="/tmp/testdox.txt"/>
</logging>
```

View File

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

View File

@@ -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```";
}
}
}