Skip to content

Added tests from #56 #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,15 @@ try {
->setDescription("This is a shorthand for a set operation on the summary field")
;

// optionally set some query params
$editParams = array(
'notifyUsers' => false
);

$issueService = new IssueService();

$ret = $issueService->update($issueKey, $issueField);
// You can set the $paramArray param to disable notifications in example
$ret = $issueService->update($issueKey, $issueField, $editParams);

var_dump($ret);
} catch (JiraException $e) {
Expand Down Expand Up @@ -514,7 +520,7 @@ try {
// A null assignee will remove the assignee.
$assignee = 'newAssigneeName';

$ret = $issueService->changeAssignee($this->key, $assignee);
$ret = $issueService->changeAssignee($issueKey, $assignee);

var_dump($ret);
} catch (JiraException $e) {
Expand All @@ -536,7 +542,9 @@ $issueKey = "TEST-879";
try {
$issueService = new IssueService();

$ret = $issueService->deleteIssue($this->key);
$ret = $issueService->deleteIssue($issueKey);
// if you want to delete issues with sub-tasks
//$ret = $issueService->deleteIssue($issueKey, array('deleteSubtasks' => 'true'));

var_dump($ret);
} catch (JiraException $e) {
Expand Down
15 changes: 11 additions & 4 deletions src/Issue/IssueService.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,11 @@ public function addAttachments($issueIdOrKey, $filePathArray)
*
* @param $issueIdOrKey Issue Key
* @param $issueField object of Issue class
* @param array $paramArray Query Parameter key-value Array.
*
* @return created issue key
*/
public function update($issueIdOrKey, $issueField)
public function update($issueIdOrKey, $issueField, $paramArray = [])
{
$issue = new Issue();

Expand All @@ -175,7 +176,9 @@ public function update($issueIdOrKey, $issueField)

$this->log->addInfo("Update Issue=\n".$data);

$ret = $this->exec($this->uri."/$issueIdOrKey", $data, 'PUT');
$queryParam = '?'.http_build_query($paramArray);

$ret = $this->exec($this->uri."/$issueIdOrKey".$queryParam, $data, 'PUT');

return $ret;
}
Expand Down Expand Up @@ -234,13 +237,17 @@ public function changeAssignee($issueIdOrKey, $assigneeName)
* Delete a issue.
*
* @param issueIdOrKey Issue id or key
* @param array $paramArray Query Parameter key-value Array.
* @return true | false
*
*/
public function deleteIssue($issueIdOrKey)
public function deleteIssue($issueIdOrKey, $paramArray = [])
{
$this->log->addInfo("deleteIssue=\n");

$ret = $this->exec($this->uri."/$issueIdOrKey", '', 'DELETE');
$queryParam = '?'.http_build_query($paramArray);

$ret = $this->exec($this->uri."/$issueIdOrKey".$queryParam, '', 'DELETE');

$this->log->addInfo('delete issue '.$issueIdOrKey.' result='.var_export($ret, true));

Expand Down
36 changes: 36 additions & 0 deletions tests/IssueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,42 @@ public function testUpdateIssue($issueKey)
}
}

/**
* @depends testChangeAssignee
*/
public function testChangeAssignee($issueKey)
{
try {
$issueService = new IssueService();

$ret = $issueService->changeAssignee($issueKey, 'lesstif');

print_r($ret);

return $issueKey;
} catch (JiraException $e) {
$this->assertTrue(false, 'Change assignee failed : '.$e->getMessage());
}
}

/**
* @depends testDeleteIssue
*/
public function testDeleteIssue($issueKey)
{
try {
$issueService = new IssueService();

$ret = $issueService->deleteIssue($issueKey);

print_r($ret);

return $issueKey;
} catch (JiraException $e) {
$this->assertTrue(false, 'delete issue failed : '.$e->getMessage());
}
}

/**
* @depends testUpdateIssue
*/
Expand Down