-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemeneted remote issue link action(create/get) - fixed #67
- Loading branch information
Showing
5 changed files
with
261 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
namespace JiraRestApi\Issue; | ||
|
||
class RemoteIssueLink implements \JsonSerializable | ||
{ | ||
/** @var integer */ | ||
public $id; | ||
|
||
/** @var string */ | ||
public $self; | ||
|
||
/** @var string */ | ||
public $globalId; | ||
|
||
/** @var array|null */ | ||
public $application; | ||
|
||
/** @var string|null */ | ||
public $relationship; | ||
|
||
/** @var RemoteIssueLinkObject|null */ | ||
public $object; | ||
|
||
public function jsonSerialize() | ||
{ | ||
return array_filter(get_object_vars($this)); | ||
} | ||
|
||
public function setUrl($url) | ||
{ | ||
if(is_null($this->object)) | ||
$this->object = new RemoteIssueLink(); | ||
|
||
$this->object->url = $url; | ||
return $this; | ||
} | ||
|
||
public function setTitle($title) | ||
{ | ||
$this->object->title = $title; | ||
return $this; | ||
} | ||
|
||
public function setSummary($summary) | ||
{ | ||
$this->object->summary = $summary; | ||
return $this; | ||
} | ||
|
||
public function setRelationship($relationship) | ||
{ | ||
$this->relationship = $relationship; | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
namespace JiraRestApi\Issue; | ||
|
||
|
||
class RemoteIssueLinkObject | ||
{ | ||
/** @var string */ | ||
public $url; | ||
|
||
/** @var string */ | ||
public $title; | ||
|
||
/** @var string|null */ | ||
public $summary; | ||
|
||
/** @var array|null */ | ||
public $icon; | ||
|
||
/** | ||
* @var array|null | ||
* | ||
* ```json | ||
* "status": { | ||
* "resolved": true, | ||
* "icon": { | ||
* "url16x16": "http://www.mycompany.com/support/resolved.png", | ||
* "title": "Case Closed", | ||
* "link": "http://www.mycompany.com/support?id=1&details=closed" | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
public $status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
use JiraRestApi\Issue\IssueService; | ||
use JiraRestApi\Issue\RemoteIssueLink; | ||
use JiraRestApi\JiraException; | ||
|
||
class RemoteIssueLinkTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testCreateRemoteIssueLink() | ||
{ | ||
$issueKey = 'TEST-316'; | ||
|
||
try { | ||
$issueService = new IssueService(); | ||
|
||
$ril = new RemoteIssueLink(); | ||
|
||
$ril->setUrl('http://www.mycompany.com/support?id=1') | ||
->setTitle('Remote Link Title') | ||
->setRelationship('causes') | ||
->setSummary('Crazy customer support issue') | ||
; | ||
|
||
$issueService->createOrUpdateRemoteIssueLink($issueKey, $ril); | ||
|
||
return $issueKey; | ||
} catch (JiraException $e) { | ||
$this->assertTrue(false, 'Create Failed : '.$e->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* @depends testCreateRemoteIssueLink | ||
*/ | ||
public function testGetRemoteIssue($issueKey) | ||
{ | ||
|
||
try { | ||
$issueService = new IssueService(); | ||
|
||
$rils = $issueService->getRemoteIssueLink($issueKey); | ||
|
||
$this->assertGreaterThan(0, count($rils)); | ||
|
||
$this->assertInstanceOf(RemoteIssueLink::class, $rils[0]); | ||
|
||
return $issueKey; | ||
} catch (HTTPException $e) { | ||
$this->assertTrue(false, $e->getMessage()); | ||
} | ||
} | ||
|
||
|
||
/** | ||
* @depends testGetRemoteIssue | ||
*/ | ||
public function testDeleteRemoteIssueLink($issueKey) | ||
{ | ||
// not yet impl | ||
$this->markTestIncomplete(); | ||
try { | ||
|
||
return $issueKey; | ||
} catch (JiraException $e) { | ||
$this->assertTrue(false, 'Create Failed : '.$e->getMessage()); | ||
} | ||
} | ||
} |