Skip to content

Commit 37d938f

Browse files
authored
Merge pull request #186 from sobyte/remove-ril
Remove remote issue link
2 parents 13f825c + ed81c83 commit 37d938f

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

src/Issue/IssueService.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,34 @@ public function createOrUpdateRemoteIssueLink($issueIdOrKey, RemoteIssueLink $ri
879879
return $res;
880880
}
881881

882+
/**
883+
* @param string|int $issueIdOrKey
884+
* @param string|int $globalId
885+
*
886+
* @throws JiraException
887+
*
888+
* @return string|bool
889+
*/
890+
public function removeRemoteIssueLink($issueIdOrKey, $globalId)
891+
{
892+
$query = http_build_query(['globalId' => $globalId]);
893+
894+
$full_uri = sprintf('%s/%s/remotelink?%s', $this->uri, $issueIdOrKey, $query);
895+
896+
$ret = $this->exec($full_uri, '', 'DELETE');
897+
898+
$this->log->addInfo(
899+
sprintf(
900+
'delete remote issue link for issue "%s" with globalId "%s". Result=%s',
901+
$issueIdOrKey,
902+
$globalId,
903+
var_export($ret, true)
904+
)
905+
);
906+
907+
return $ret;
908+
}
909+
882910
/**
883911
* get all issue security schemes.
884912
*

tests/RemoteIssueLinkTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,26 @@ public function testGetRemoteIssue($issueKey)
5757
*/
5858
public function testDeleteRemoteIssueLink($issueKey)
5959
{
60-
// not yet impl
61-
$this->markTestIncomplete();
6260
try {
61+
$issueService = new IssueService();
62+
63+
$rils = $issueService->getRemoteIssueLink($issueKey);
64+
$countBefore = count($rils);
65+
66+
/** @var RemoteIssueLink $firstRil */
67+
$firstRil = $rils[0];
68+
69+
$ret = $issueService->removeRemoteIssueLink($issueKey, $firstRil->globalId);
70+
71+
$this->assertTrue($ret);
72+
73+
$rilsAfter = $issueService->getRemoteIssueLink($issueKey);
74+
75+
$this->assertLessThan($countBefore, count($rilsAfter));
6376

6477
return $issueKey;
6578
} catch (JiraException $e) {
66-
$this->assertTrue(false, 'Create Failed : '.$e->getMessage());
79+
$this->assertTrue(false, 'Remove Failed : '.$e->getMessage());
6780
}
6881
}
6982
}

0 commit comments

Comments
 (0)