initial commit
This commit is contained in:
commit
5fb4134631
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/src/config.php
|
||||
/vendor/
|
19
composer.json
Normal file
19
composer.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "jhodges/giteabot-phpunit",
|
||||
"description": "Some examples for the giteabot php api",
|
||||
"authors": [
|
||||
{
|
||||
"name": "James",
|
||||
"email": "inbox.dev@jhodges.co.uk"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"jhodges/giteabot": "~1.2.0"
|
||||
},
|
||||
"repositories": {
|
||||
"repo-name": {
|
||||
"type": "composer",
|
||||
"url": "https://git.jhodges.co.uk/composer"
|
||||
}
|
||||
}
|
||||
}
|
44
composer.lock
generated
Normal file
44
composer.lock
generated
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "8e21cb9a16c0817b84a9643dc47c1a78",
|
||||
"packages": [
|
||||
{
|
||||
"name": "jhodges/giteabot",
|
||||
"version": "v1.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.jhodges.co.uk/jhodges/GiteaBot",
|
||||
"reference": "a2c44392b2b4eede6be4b132e55e3479232fda93"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"JHodges\\GiteaBot\\": "src/"
|
||||
}
|
||||
},
|
||||
"license": [
|
||||
"GPL3"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "James",
|
||||
"email": "inbox.dev@jhodges.co.uk"
|
||||
}
|
||||
],
|
||||
"description": "Simple PHP library to interface with Gitea API",
|
||||
"time": "2019-09-07T08:43:48+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": []
|
||||
}
|
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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user